diff --git a/app/router.php b/app/router.php index 733eb7c..58fea05 100644 --- a/app/router.php +++ b/app/router.php @@ -96,20 +96,30 @@ if (str_ends_with($ctx->requestPath, 'feed.xml')) { $items = buildListItems($dir, $ctx, $metadata); // Render full content for each item + // Load feed exclusion patterns from config (comma-separated substrings) + $customConfigPath = dirname(__DIR__) . '/custom/config.ini'; + $feedConfig = file_exists($customConfigPath) ? (parse_ini_file($customConfigPath, true)['feed'] ?? []) : []; + $excludePatterns = array_map('trim', explode(',', $feedConfig['exclude_files'] ?? '')); + $excludePatterns = array_filter($excludePatterns); + foreach ($items as &$item) { $item['content'] = ''; $itemMetadata = loadMetadata($item['dirPath']); getPluginManager()->loadPagePlugins($itemMetadata); $contentFiles = findAllContentFiles($item['dirPath']); foreach ($contentFiles as $file) { - $item['content'] .= renderContentFile($file, $ctx); + $basename = basename($file); + $excluded = false; + foreach ($excludePatterns as $pattern) { + if (str_contains($basename, $pattern)) { + $excluded = true; + break; + } + } + if (!$excluded) { + $item['content'] .= renderContentFile($file, $ctx); + } } - // Strip #is', '', $item['content']); - if ($stripped !== null) { - $stripped = preg_replace('#]*>.*?#is', '', $stripped); - } - $item['content'] = $stripped ?? $item['content']; } unset($item); diff --git a/docs/03-reference/01-configuration.md b/docs/03-reference/01-configuration.md index 7c3a7fc..424b112 100644 --- a/docs/03-reference/01-configuration.md +++ b/docs/03-reference/01-configuration.md @@ -85,6 +85,18 @@ To disable all plugins, leave the value empty: enabled = "" ``` +### `[feed]` + +Exclude content files from Atom feed rendering. Files are matched by substring against their basename. + +```ini +[feed] +exclude_files = "nyhetsbrev, petition-form" +``` + +Comma-separated substrings. `"nyhetsbrev"` excludes `20-nyhetsbrev.php`, `_35-nyhetsbrev.php` etc. +Excluded files still render on actual pages — only feed output is affected. + ### Custom Sections Add your own configuration sections for custom plugins: @@ -275,6 +287,7 @@ FolderWeb doesn't enforce a schema—you can add any sections and keys you need. | `languages` | `default` | string | `"en"` | Default language code | | `languages` | `available` | string | `"en,no"` | Comma-separated language codes | | `plugins` | `enabled` | string | `"languages"` | Comma-separated plugin names | +| `feed` | `exclude_files` | string | `""` | Comma-separated substrings to exclude from feed rendering | All other sections are custom and plugin-specific. diff --git a/docs/03-reference/02-metadata.md b/docs/03-reference/02-metadata.md index 4dd742c..c99cbcd 100644 --- a/docs/03-reference/02-metadata.md +++ b/docs/03-reference/02-metadata.md @@ -208,6 +208,10 @@ feed = true **Applies to:** List pages only (directories with subdirectories) **Effect:** Generates an Atom XML feed containing the full rendered content of each list item. Also adds an autodiscovery `` tag in the HTML ``. +**Content inclusion:** By default, all content files in each item's directory are rendered into the feed entry. This includes `.md` files and `.php` templates — anything that would render on the actual page. + +If certain files should be excluded from the feed (e.g., newsletter signup forms, interactive widgets), use the `[feed] exclude_files` config option in `custom/config.ini`. See [Configuration Reference → Feed](01-configuration.md#feed). + ## Language-Specific Overrides Add language-specific sections to override fields: