Compare commits

...

2 commits

Author SHA1 Message Date
Ruben
33943a907b Document author setting for Atom feeds
**Date deduplication:** Atom requires unique `<updated>` timestamps per
entry. Items sharing the same date get seconds incremented to preserve
sort order.

**Cache-Control for assets:** JSON/GeoJSON get 60s TTL; others get 1
year immutable.
2026-03-17 11:23:19 +01:00
Ruben
611bf75576 Add social image URL and metadata to template context 2026-03-17 11:23:07 +01:00
5 changed files with 27 additions and 12 deletions

View file

@ -46,10 +46,7 @@ Hooks::add(Hook::PROCESS_CONTENT, function(mixed $data, string $dirOrType, strin
// Filter content files by language variant
if (is_array($data) && !empty($data) && isset($data[0]['path'])) {
error_log("filterFilesByLanguage called with " . count($data) . " files, current lang: $currentLang");
$filtered = filterFilesByLanguage($data, $dirOrType, $ctx);
error_log("Filtered to " . count($filtered) . " files");
return $filtered;
return filterFilesByLanguage($data, $dirOrType, $ctx);
}
return $data;

View file

@ -59,7 +59,8 @@ function renderTemplate(Context $ctx, string $content, int $statusCode = 200): v
'pageCssHash' => $ctx->get('pageCssHash'),
'pageJsUrl' => $ctx->get('pageJsUrl'),
'pageJsHash' => $ctx->get('pageJsHash'),
'feedUrl' => $ctx->get('feedUrl')
'feedUrl' => $ctx->get('feedUrl'),
'socialImageUrl' => $ctx->get('socialImageUrl')
], $ctx);
extract($templateVars);
@ -73,8 +74,8 @@ function renderTemplate(Context $ctx, string $content, int $statusCode = 200): v
function renderMultipleFiles(Context $ctx, array $files, string $pageDir): void {
// Load metadata and page plugins BEFORE rendering content files
// so that plugin-provided template variables are available to PHP content files
$pageMetadata = loadMetadata($pageDir);
getPluginManager()->loadPagePlugins($pageMetadata);
$metadata = loadMetadata($pageDir);
getPluginManager()->loadPagePlugins($metadata);
$content = '';
foreach ($files as $file) {
@ -83,8 +84,8 @@ function renderMultipleFiles(Context $ctx, array $files, string $pageDir): void
$navigation = $ctx->navigation;
$homeLabel = $ctx->homeLabel;
$pageTitle = $pageMetadata['title'] ?? null;
$metaDescription = extractMetaDescription($pageDir, $pageMetadata);
$pageTitle = $metadata['title'] ?? null;
$metaDescription = extractMetaDescription($pageDir, $metadata);
$pageCss = findPageCss($pageDir, $ctx->contentDir);
$pageCssUrl = $pageCss['url'] ?? null;
@ -112,7 +113,8 @@ function renderMultipleFiles(Context $ctx, array $files, string $pageDir): void
'pageCssHash' => $pageCssHash,
'pageJsUrl' => $pageJsUrl,
'pageJsHash' => $pageJsHash,
'socialImageUrl' => $socialImageUrl
'socialImageUrl' => $socialImageUrl,
'metadata' => $metadata
], $ctx);
extract($templateVars);

View file

@ -249,6 +249,14 @@ switch ($parsedPath['type']) {
? $langPrefix . '/' . trim($ctx->requestPath, '/') . '/feed.xml'
: null;
// Build social image URL from cover image if present
$coverImage = findCoverImage($dir);
$socialImageUrl = null;
if ($coverImage) {
$relativePath = trim(str_replace($ctx->contentDir, '', $dir), '/');
$socialImageUrl = '/' . ($relativePath ? $relativePath . '/' : '') . $coverImage;
}
// Store for base template (renderTemplate reads these from context)
$ctx->set('pageTitle', $pageTitle);
$ctx->set('metaDescription', $metaDescription);
@ -257,6 +265,7 @@ switch ($parsedPath['type']) {
$ctx->set('pageJsUrl', $pageJsUrl);
$ctx->set('pageJsHash', $pageJsHash);
$ctx->set('feedUrl', $feedUrl);
$ctx->set('socialImageUrl', $socialImageUrl);
// Let plugins add template variables
$templateVars = Hooks::apply(Hook::TEMPLATE_VARS, [
@ -270,7 +279,9 @@ switch ($parsedPath['type']) {
'pageJsHash' => $pageJsHash,
'items' => $items,
'pageContent' => $pageContent,
'feedUrl' => $feedUrl
'feedUrl' => $feedUrl,
'socialImageUrl' => $socialImageUrl,
'metadata' => $metadata
], $ctx);
extract($templateVars);

View file

@ -54,6 +54,7 @@ Returns flat key-value array with a special `_raw` key containing the full parse
| `order` | string | `"descending"` | List sort direction (`ascending`\|`descending`) |
| `redirect` | string | — | External URL (list items can redirect) |
| `feed` | bool | `false` | Enable Atom feed on list pages (`feed.xml`) |
| `author` | string | title | Atom feed author name (falls back to page title) |
| `plugins` | string | — | Comma-separated page-level plugin names |
### Settings Section

View file

@ -57,6 +57,8 @@ Handled in `router.php` before `parseRequestPath()`. When a request path ends wi
Feed piggybacks on the existing Markdown cache — no separate feed cache needed. The `rawDate` field on items provides ISO dates for Atom `<updated>` elements. Content is wrapped in `<![CDATA[...]]>` with `]]>` safely escaped.
**Date deduplication:** Atom requires unique `<updated>` timestamps per entry. Items sharing the same date get seconds incremented (`T00:00:00Z`, `T00:00:01Z`, etc.) to ensure uniqueness while preserving sort order.
## Markdown Caching
Defined in `app/cache.php`. File-based cache in `/tmp/folderweb_cache/`.
@ -87,7 +89,9 @@ Files not in this list are not served as static assets.
### Custom Assets (router.php)
Files in `custom/assets/` are served at the document root URL. Example: `custom/assets/favicon.ico``/favicon.ico`. Uses `mime_content_type()` for MIME detection.
Files in `custom/assets/` are served at the document root URL. Example: `custom/assets/favicon.ico``/favicon.ico`. Uses an explicit MIME type map; falls back to `application/octet-stream`.
Cache-Control headers: `json` and `geojson` files get `max-age=60` (short TTL for data files); all other asset types get `max-age=31536000` (1 year, immutable).
### Framework Assets (static.php)