Add Atom feed support to list pages

Introduce `feed` metadata option to enable Atom feeds
Update list item structure with standardized fields
Add `$feedUrl` template variable for autodiscovery
Improve date handling with raw/processed date separation
Document feed generation in architecture and rendering docs
Update template examples to use new item structure
This commit is contained in:
Ruben 2026-02-06 18:24:39 +01:00
parent 1cbfb67a4c
commit 069ce389ea
7 changed files with 128 additions and 48 deletions

View file

@ -211,6 +211,21 @@ MD5 hash of page-specific CSS for cache busting.
**Optional:** Only set if `$pageCssUrl` exists
**Example:** See `$pageCssUrl` above
### `$feedUrl`
URL to the Atom feed for the current list page.
**Type:** String (URL path)
**Optional:** Only set on list pages with `feed = true` in metadata
**Example:**
```php
<?php if (!empty($feedUrl)): ?>
<link rel="alternate" type="application/atom+xml" title="<?= htmlspecialchars($pageTitle ?? 'Feed') ?>" href="<?= htmlspecialchars($feedUrl) ?>">
<?php endif; ?>
```
**Source:** Set when `feed = true` in the list directory's `metadata.ini`
## Page Template Variables
Available in `page.php`:
@ -238,7 +253,6 @@ All metadata for the current page.
'title' => 'Page Title',
'summary' => 'Short description',
'date' => '2024-12-15',
'formatted_date' => '15. desember 2024',
'show_date' => true,
'author' => 'Jane Doe', // Custom fields
'tags' => 'web,design',
@ -254,7 +268,7 @@ All metadata for the current page.
<?php if (isset($metadata['date']) && ($metadata['show_date'] ?? true)): ?>
<time datetime="<?= $metadata['date'] ?>">
<?= $metadata['formatted_date'] ?? $metadata['date'] ?>
<?= $metadata['date'] ?>
</time>
<?php endif; ?>
```
@ -289,16 +303,15 @@ Array of items to display in the list.
```php
[
[
'url' => '/blog/my-post/',
'path' => '/content/blog/2024-12-15-my-post',
'title' => 'My Post',
'url' => '/blog/my-post/',
'date' => '15. desember 2024', // Formatted for display
'rawDate' => '2024-12-15', // ISO YYYY-MM-DD
'summary' => 'Short description',
'date' => '2024-12-15',
'formatted_date' => '15. desember 2024',
'cover_image' => '/blog/my-post/cover.jpg',
// All custom metadata fields...
'author' => 'Jane Doe',
'category' => 'Tutorial',
'cover' => '/blog/2024-12-15-my-post/cover.jpg',
'pdf' => null,
'redirect' => null,
'dirPath' => '/path/to/content/blog/2024-12-15-my-post',
],
// ... more items
]
@ -308,8 +321,8 @@ Array of items to display in the list.
```php
<?php foreach ($items as $item): ?>
<article>
<?php if (isset($item['cover_image'])): ?>
<img src="<?= $item['cover_image'] ?>"
<?php if ($item['cover']): ?>
<img src="<?= $item['cover'] ?>"
alt="<?= htmlspecialchars($item['title']) ?>">
<?php endif; ?>
@ -319,13 +332,13 @@ Array of items to display in the list.
</a>
</h2>
<?php if (isset($item['date'])): ?>
<time datetime="<?= $item['date'] ?>">
<?= $item['formatted_date'] ?? $item['date'] ?>
<?php if ($item['date']): ?>
<time datetime="<?= $item['rawDate'] ?>">
<?= $item['date'] ?>
</time>
<?php endif; ?>
<?php if (isset($item['summary'])): ?>
<?php if ($item['summary']): ?>
<p><?= htmlspecialchars($item['summary']) ?></p>
<?php endif; ?>
</article>
@ -351,14 +364,15 @@ Each item in `$items` has these properties:
| Property | Type | Description | Optional |
|----------|------|-------------|----------|
| `url` | String | Full URL to the item | No |
| `path` | String | Filesystem path to item | No |
| `title` | String | Item title | No |
| `summary` | String | Short description | Yes |
| `date` | String | ISO date (YYYY-MM-DD) | Yes |
| `formatted_date` | String | Localized date string | Yes |
| `cover_image` | String | URL to cover image | Yes |
| Custom fields | Mixed | Any metadata fields | Yes |
| `title` | String | Item title (from metadata, heading, or folder name) | No |
| `url` | String | Full URL to the item (with trailing slash + lang prefix) | No |
| `date` | String | Formatted date string (plugin-processed for display) | Yes |
| `rawDate` | String | ISO date (YYYY-MM-DD) for feeds and `<time>` elements | Yes |
| `summary` | String | Short description from metadata | Yes |
| `cover` | String | URL to cover image | Yes |
| `pdf` | String | URL to first PDF file | Yes |
| `redirect` | String | External redirect URL | Yes |
| `dirPath` | String | Filesystem path to item directory (internal use) | No |
## Adding Custom Variables
@ -401,6 +415,7 @@ Then use in templates:
| `$translations` | ✓ | — | — |
| `$pageCssUrl` | ✓ | — | — |
| `$pageCssHash` | ✓ | — | — |
| `$feedUrl` | ✓ | — | — |
| `$metadata` | — | ✓ | ✓ |
| `$pageContent` | — | — | ✓ |
| `$items` | — | — | ✓ |