Add Blog RSS feed, footer feed/sitemap links, and expanded docs
Blog RSS feed (novaconium/ISSUES.md): - App/pages/blog/feed/index.php - main feed, built from the same hand-written $posts array App/pages/blog/index.php renders from, so it works with content_index_enabled left at its default false. Added a published date field per post entry. - App/pages/blog/tag/[tag]/feed/index.php - per-tag feed, gated on content_index_enabled the same way blog/tag/[tag]/index.php is. - novaconium/lib/Rss.php - shared RSS 2.0 envelope builder both feeds use, generic (title/link/description/items in, XML string out). - New head_extra block in the root layout (empty by default) so App/pages/blog/_layout/layout.twig can add feed auto-discovery scoped to /blog/* only. Footer: - New content_index_enabled Twig global (Renderer/bootstrap.php), same pattern as admin_auth_enabled. - Right-aligned footer menu linking to /sitemap.xml (only shown when content_index_enabled, so it never links to a 404) and /blog/feed (always shown, no content-index dependency). Docs: - New /admin/docs/rss page: Lib\Rss API, the two shipped feeds, a worked example of adding a feed for another content collection, and how to advertise multiple feeds via head_extra. - New /admin/docs/sitemap page: changefreq/priority blocks, what's included/excluded, an honest callout on the relative-<loc>-URL spec deviation (consistent with how canonical/og:url already work) with an override path for strict compliance, and submitting it to search engines. - /admin/docs (Overview) gains a Requirements section: minimum requirements, then optional requirements for the database/content-index features (pdo_sqlite, optional pdo_mysql, FTS5) - and a Documentation heading separating it from the doc links list. - /admin/docs/getting-started's Requirements line was stale (missing pdo_sqlite entirely, unlike README) - fixed and cross-linked to the Overview page's fuller list. - /admin/docs/content-index trimmed to point at the new RSS/sitemap pages instead of duplicating their detail. Also adds an "In-house comments" entry to novaconium/ISSUES.md's Backlog - a Lib\ class for sidecar-attached comments on any page, depending on the not-yet-built Admin login & user management for real user accounts. Closes the "Blog RSS feed" backlog item.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
// /blog/feed — sidecar-only (no index.twig), like sitemap.xml/search: no
|
||||
// point rendering Twig just to return XML. Project-owned (App/pages/),
|
||||
// since this is blog content specifically, not generic framework
|
||||
// machinery like sitemap.xml/search are. Deliberately has zero dependency
|
||||
// on the (off-by-default) content index — it reads the exact same
|
||||
// hand-written $posts array App/pages/blog/index.php itself renders from,
|
||||
// so this feed works on a bare install with content_index_enabled left at
|
||||
// its shipped default of false. Only the per-tag variant
|
||||
// (App/pages/blog/tag/[tag]/feed/index.php) needs the content index, since
|
||||
// tags only exist there.
|
||||
|
||||
use App\Response;
|
||||
use Lib\Rss;
|
||||
|
||||
$config = require __DIR__ . '/../../../../novaconium/config.php';
|
||||
$appConfigFile = __DIR__ . '/../../../../App/config.php';
|
||||
if (is_file($appConfigFile)) {
|
||||
$config = array_merge($config, require $appConfigFile);
|
||||
}
|
||||
|
||||
$posts = (require __DIR__ . '/../index.php')['posts'];
|
||||
|
||||
// Newest first, the RSS convention — the array itself (and therefore the
|
||||
// /blog listing page, which isn't touched here) keeps its own order;
|
||||
// sorting only affects this feed's output.
|
||||
usort($posts, fn (array $a, array $b) => strcmp($b['published'], $a['published']));
|
||||
|
||||
$items = array_map(
|
||||
fn (array $post) => [
|
||||
'title' => $post['title'],
|
||||
'link' => '/blog/' . $post['slug'],
|
||||
'guid' => '/blog/' . $post['slug'],
|
||||
'pubDateTimestamp' => strtotime($post['published']),
|
||||
'description' => $post['excerpt'],
|
||||
],
|
||||
$posts
|
||||
);
|
||||
|
||||
$xml = Rss::render(
|
||||
$config['site_name'] . ' Blog',
|
||||
'/blog',
|
||||
'Posts from ' . $config['site_name'] . '.',
|
||||
$items
|
||||
);
|
||||
|
||||
return Response::xml($xml);
|
||||
Reference in New Issue
Block a user