feat(cms): U3 derive article dates from content/ front-matter
Replace the hand-maintained ARTICLE_DATES registry as the source of
truth with dates read from content/ front-matter, so publishing a post
via the CMS needs no manual registry edit (plan R4).
- tools/content_index.py: load_dates() reads content/ front-matter into
{source_folder/slug: {published|modified: iso}}. Standalone (os+yaml),
no import cycle with seo_inject.
- tools/seo_inject.py: ARTICLE_DATES is now {**static_fallback,
**content_dates}; content wins. The static table is kept only as a
fallback for entries not present in content/.
- migration now preserves the published-vs-modified distinction
(date_type), so the switch is byte-identical: content-derived dates
equal the old static table exactly (17/17, incl. the one 'modified').
Verified: full `seo_inject --all --sitemap` + build_listings +
build_botlinks run produces ZERO changes to any site page. build_content
--check still reproduces all 51 pages.
build_botlinks.py needs no change (it scrapes built pages, which are a
pure function of content/). Listings get content-driven dates for free
via seo_inject.ARTICLE_DATES.
tools/tests/test_content_index.py: 5 tests (dates == legacy registry,
merged registry unchanged, published/modified distinction, events key on
projects/<slug>, one ISO date per entry).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
596290acf8
commit
8ff968739a
9 files changed
+174
-14
No files matched your search
+13
-3
@@ -18,6 +18,8 @@ except Exception:
|
||||
|
||||
# Repo root = parent of this tools/ directory (portable; no hardcoded path).
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
import content_index # noqa: E402 (dates from content/ front-matter, U3)
|
||||
DOMAIN = "https://msosorg.com"
|
||||
SITE_NAME = {"en": "Macedonian Student Organisation in Slovenia",
|
||||
"mk": "Македонска студентска организација во Словенија",
|
||||
@@ -39,9 +41,10 @@ SECTION_NAMES = {
|
||||
}
|
||||
HOME_CRUMB = {"en": "Home", "mk": "Дома", "si": "Domov"}
|
||||
|
||||
# Article dates (ISO), curated once from the English pages (dates are
|
||||
# language-independent). Emitted as datePublished/dateModified in Article schema.
|
||||
ARTICLE_DATES = {
|
||||
# Article dates (ISO). Emitted as datePublished/dateModified in Article schema.
|
||||
# Source of truth is now content/ front-matter (see content_index / U3); this
|
||||
# static table is only a fallback for any entry not present in content/.
|
||||
_STATIC_ARTICLE_DATES = {
|
||||
"blog/how-to-open-slovenian-bank-account": {"modified": "2026-08-01"},
|
||||
"blog/where-to-search-for-accommodation-in-slovenia": {"published": "2026-08-03"},
|
||||
"blog/learning-slovene-where-to-start": {"published": "2026-07-28"},
|
||||
@@ -61,6 +64,13 @@ ARTICLE_DATES = {
|
||||
"projects/watching-handball-together-in-slovenia": {"published": "2025-01-25"},
|
||||
}
|
||||
|
||||
# Content front-matter is authoritative; it overrides the static fallback above.
|
||||
# A new post published via the CMS therefore needs no manual date entry here.
|
||||
try:
|
||||
ARTICLE_DATES = {**_STATIC_ARTICLE_DATES, **content_index.load_dates()}
|
||||
except Exception:
|
||||
ARTICLE_DATES = dict(_STATIC_ARTICLE_DATES)
|
||||
|
||||
# OPTIONAL location overrides for Event schema on /projects/ pages.
|
||||
# By default a project's city is auto-detected from its English page body
|
||||
# (see detect_city), so NEW projects need NO entry here — just publish them.
|
||||
|
||||
Reference in new issue
Block a user