From 7ab7d468e5b8c7823ef9723b3693c7cf435f81ec Mon Sep 17 00:00:00 2001 From: kbenestad Date: Thu, 21 May 2026 12:13:45 +0700 Subject: [PATCH 1/5] Improve markdown structure in reference pages Update markdown formatting and clarify frontmatter section. --- docs/reference-pages.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference-pages.md b/docs/reference-pages.md index f1e4607..571aa74 100644 --- a/docs/reference-pages.md +++ b/docs/reference-pages.md @@ -17,7 +17,7 @@ toc ``` Regular markdown, plus mdcms code blocks for callouts, table of contents, post lists. -``` +`````` --- From 80877cbaea395851ffcf6b849b1e10b5ea892b4d Mon Sep 17 00:00:00 2001 From: kbenestad Date: Thu, 21 May 2026 12:14:14 +0700 Subject: [PATCH 2/5] Fix markdown syntax in reference pages documentation Correct markdown formatting for code blocks and frontmatter. --- docs/reference-pages.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/reference-pages.md b/docs/reference-pages.md index 571aa74..d5afae0 100644 --- a/docs/reference-pages.md +++ b/docs/reference-pages.md @@ -4,7 +4,7 @@ All keys you can use inside a markdown page in `pages/` or `posts/`. A page has two parts: -```markdown +````markdown --- # Frontmatter (YAML, optional except for title) title: My Page @@ -17,7 +17,8 @@ toc ``` Regular markdown, plus mdcms code blocks for callouts, table of contents, post lists. -`````` +``` +```` --- From a939883bef90929f89f0dc206a717b53108810f0 Mon Sep 17 00:00:00 2001 From: kbenestad Date: Thu, 21 May 2026 12:14:37 +0700 Subject: [PATCH 3/5] Clarify markdown usage in reference pages Update documentation to clarify markdown usage. --- docs/reference-pages.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference-pages.md b/docs/reference-pages.md index d5afae0..6598ad9 100644 --- a/docs/reference-pages.md +++ b/docs/reference-pages.md @@ -17,7 +17,7 @@ toc ``` Regular markdown, plus mdcms code blocks for callouts, table of contents, post lists. -``` + ```` --- From cc4ed7b8817c0be88372f692abc27aac3bcbabce Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 21 May 2026 14:46:46 +0000 Subject: [PATCH 4/5] docs: add missing per-category config keys to reference-config.md Documents all keys that can appear under default-category and categories entries: message, name-latin, notfoundmessage, pagenotfoundmessage, font, and line-height. Adds a summary table and updates the full example to show these keys in context. --- docs/reference-config.md | 67 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/docs/reference-config.md b/docs/reference-config.md index 6c91062..c0b429f 100644 --- a/docs/reference-config.md +++ b/docs/reference-config.md @@ -151,16 +151,40 @@ categories-use: yes # Enable the category system. Default: no. default-category: # The category used when no ?cat= parameter is in the URL. code: en # Short code. Used in filenames (page.en.md) and URL params. - name: English # Display name shown in the category selector. + name: English # Display name shown in the category dropdown list. + message: English # Label shown on the selector bar (trigger button). Falls back to name. + name-latin: English # Secondary label shown in the dropdown alongside name. Use when name + # is in a non-Latin script (e.g. Arabic, Devanagari) to aid recognition. + # Omit if name is already Latin or identical to name. direction: ltr # Text direction. ltr or rtl. Default: ltr. + # rtl flips the nav position and content text direction. + notfoundmessage: "Not available in this language" + # Short note shown in the dropdown when no variant exists for the + # current page. Also enables fallback: the renderer will fall back to + # the default-category content instead of hiding the page. + # Omit to hide the category from the dropdown when no variant exists. + pagenotfoundmessage: "This page is not yet available in English." + # Message shown in the content area when a page cannot be fetched for + # this category. Overrides the top-level pagenotfoundmessage. + font: NotoNastaliqUrdu-Regular.ttf + # Font filename inside assets/fonts/. Loaded on demand when this + # category is activated. Useful for scripts that need a specific font. + line-height: 2.8 # Line height override for this category. Useful for scripts like + # Nastaliq that need extra vertical space. Restores to theme default + # when switching away. -categories: # Additional categories. +categories: # Additional categories. Each entry supports the same keys as + # default-category above. - code: nb name: Norsk direction: ltr - code: ar name: عربي - direction: rtl # RTL flips nav position and content text direction. + name-latin: Arabic + direction: rtl + notfoundmessage: "غير متاح" + font: NotoNastaliqUrdu-Regular.ttf + line-height: 2.8 categories-sectionnames: same # How section names are shown per category. # same: all categories share one section name (defaultname in nav.yml). @@ -170,6 +194,20 @@ categories-selecticon: globe # Icon shown in the category selector bar. SVG na categories-selecttext: "Language" # Label shown next to the icon in the category selector bar. ``` +### Per-category keys summary + +| Key | Required | Description | +|---|---|---| +| `code` | Yes | Short identifier used in filenames (`page.nb.md`) and the `?cat=` URL param. | +| `name` | Yes | Display name shown in the dropdown list. | +| `message` | No | Label shown on the selector trigger button. Falls back to `name`. | +| `name-latin` | No | Secondary label in the dropdown, shown alongside `name` when `name` uses a non-Latin script. | +| `direction` | No | `ltr` or `rtl`. Default: `ltr`. RTL flips nav and content direction. | +| `notfoundmessage` | No | Short note shown in the dropdown when no variant exists for the current page. Also enables fallback to default-category content. | +| `pagenotfoundmessage` | No | Message shown in the content area when a page cannot be fetched for this category. Overrides the top-level `pagenotfoundmessage`. | +| `font` | No | Font filename from `assets/fonts/`. Loaded on demand when this category is activated. | +| `line-height` | No | Body line height override for this category. Restores to theme default when switching away. | + --- ## Reusable callout messages @@ -228,6 +266,29 @@ offline-message: nb: "Du er frakoblet. Koble til og last inn på nytt." language: en +pagenotfoundmessage: "Please select a page to continue." + +categories-use: yes +default-category: + code: en + name: English + direction: ltr +categories: + - code: nb + name: Norsk + direction: ltr + notfoundmessage: "Ikke tilgjengelig på norsk" + - code: ar + name: عربي + name-latin: Arabic + direction: rtl + notfoundmessage: "غير متاح" + pagenotfoundmessage: "هذه الصفحة غير متاحة." + font: NotoNastaliqUrdu-Regular.ttf + line-height: 2.8 +categories-sectionnames: same +categories-selecticon: globe +categories-selecttext: "Language" callouts: aitranslation: From ef4197fa83e8b3b1157c2d78ffe82adc8ada5701 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 21 May 2026 15:02:31 +0000 Subject: [PATCH 5/5] feat: add visibilityifnocontent per-category config key When set to visible, the category always appears in the selector even when no variant exists for the current page. Navigating to such a page shows pagenotfoundmessage with no fallback to default-category content. Default behaviour (hidden) is unchanged. Updates pageShouldDisplay and visibleCategoryCodesForCurrentPage to honour the new key alongside the existing notfoundmessage logic. Docs updated with key description, summary table, and full example. --- app/index.html | 12 +++++++----- docs/reference-config.md | 10 +++++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/index.html b/app/index.html index d811dc9..bb19f87 100644 --- a/app/index.html +++ b/app/index.html @@ -952,7 +952,7 @@ body { // Category state (phase 3) let categoriesUse = false; - let categoriesList = []; // [{code, name, direction, message, notfoundmessage, pagenotfoundmessage, font, ...}] + let categoriesList = []; // [{code, name, direction, message, notfoundmessage, pagenotfoundmessage, visibilityifnocontent, font, ...}] let categoriesByCode = {}; // code → category object let defaultCategoryCode = null; let activeCategory = null; // current code @@ -1202,13 +1202,14 @@ body { // - Home page: always show (per config.homepage or default 'pages/home.md') // - Variant exists for active category: show // - Active category has notfoundmessage: show (renderer falls back to default language) + // - Active category has visibilityifnocontent: visible: show (renderer shows pagenotfoundmessage) // - Otherwise: hide if (!categoriesUse) return true; if (page.file === defaultPage()) return true; const variants = page.variants || []; if (variants.includes(activeCategory)) return true; const cat = categoriesByCode[activeCategory]; - return !!(cat && cat.notfoundmessage); + return !!(cat && (cat.notfoundmessage || cat.visibilityifnocontent === 'visible')); } // ─── Theme ──────────────────────────────────────────────── @@ -2243,7 +2244,8 @@ function fmtDatetime(dtStr) { function visibleCategoryCodesForCurrentPage() { // Which categories should appear in the dropdown: // - the variant exists for this page, OR - // - the category has a notfoundmessage + // - the category has a notfoundmessage (fallback to default content), OR + // - the category has visibilityifnocontent: visible (shows pagenotfoundmessage instead) // - always include the active category so user can see what they're on const out = new Set(); const page = currentPage @@ -2251,8 +2253,8 @@ function fmtDatetime(dtStr) { : null; categoriesList.forEach(cat => { const hasVariant = !page || !page.variants || page.variants.includes(cat.code); - const hasMsg = !!cat.notfoundmessage; - if (hasVariant || hasMsg || cat.code === activeCategory) out.add(cat.code); + const alwaysVisible = !!cat.notfoundmessage || cat.visibilityifnocontent === 'visible'; + if (hasVariant || alwaysVisible || cat.code === activeCategory) out.add(cat.code); }); return out; } diff --git a/docs/reference-config.md b/docs/reference-config.md index c0b429f..0c0d829 100644 --- a/docs/reference-config.md +++ b/docs/reference-config.md @@ -163,6 +163,12 @@ default-category: # The category used when no ?cat= parameter is in # current page. Also enables fallback: the renderer will fall back to # the default-category content instead of hiding the page. # Omit to hide the category from the dropdown when no variant exists. + visibilityifnocontent: hidden # hidden (default) or visible. + # hidden: category disappears from the selector when no variant exists + # for the current page (unless notfoundmessage is also set). + # visible: category stays in the selector regardless. When the user + # navigates to a page with no variant, pagenotfoundmessage is shown + # in the content area. No fallback to default-category content. pagenotfoundmessage: "This page is not yet available in English." # Message shown in the content area when a page cannot be fetched for # this category. Overrides the top-level pagenotfoundmessage. @@ -204,6 +210,7 @@ categories-selecttext: "Language" # Label shown next to the icon in the categor | `name-latin` | No | Secondary label in the dropdown, shown alongside `name` when `name` uses a non-Latin script. | | `direction` | No | `ltr` or `rtl`. Default: `ltr`. RTL flips nav and content direction. | | `notfoundmessage` | No | Short note shown in the dropdown when no variant exists for the current page. Also enables fallback to default-category content. | +| `visibilityifnocontent` | No | `hidden` (default) or `visible`. `visible` keeps the category in the selector when no variant exists; navigating to it shows `pagenotfoundmessage` with no fallback to default content. | | `pagenotfoundmessage` | No | Message shown in the content area when a page cannot be fetched for this category. Overrides the top-level `pagenotfoundmessage`. | | `font` | No | Font filename from `assets/fonts/`. Loaded on demand when this category is activated. | | `line-height` | No | Body line height override for this category. Restores to theme default when switching away. | @@ -277,7 +284,8 @@ categories: - code: nb name: Norsk direction: ltr - notfoundmessage: "Ikke tilgjengelig på norsk" + visibilityifnocontent: visible + pagenotfoundmessage: "Denne siden er ikke tilgjengelig på norsk ennå." - code: ar name: عربي name-latin: Arabic