From bef6538cb6fedbf110b975862e4f3acd055ee4ca Mon Sep 17 00:00:00 2001 From: biosias Date: Tue, 27 Oct 2026 00:05:44 +0100 Subject: [PATCH] Stop overriding page title and #site-title with siteName (AI) Co-Authored-By: Claude Opus 5.5 --- README.md | 16 +++++----------- js/router.js | 7 ------- js/views.js | 11 +++++++++-- strings/cs.json | 1 - strings/en.json | 1 - strings/sk.json | 1 - 6 files changed, 14 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 39f4066..957bb22 100644 --- a/README.md +++ b/README.md @@ -271,12 +271,11 @@ The resolved locale also drives date formatting (`Intl.DateTimeFormat`), search tag-label sorting (`localeCompare`), via `getLocale()` in the same module — so a translation file doesn't just relabel text, it affects how dates and sorting behave too. -The page `` and an optional `#site-title` header link (see "Embedding in an existing -page" below) are both set from the `siteName` string at startup, so they stay in sync with the -resolved locale automatically — translate `siteName` in `strings/xx.json` rather than editing -the page. Other site-specific branding in the embedding page itself (the header search -placeholder, the sidebar section headings) is plain static HTML, not JS-templated — translate -that by editing the page directly (`demo/index.html` for this repo's own demo). +cmkiss never names the page: the `<title>`, the site header, and any other branding (the header +search placeholder, the sidebar section headings) belong to the embedding page and are plain +static HTML — translate them by editing the page directly (`demo/index.html` for this repo's own +demo). The only change cmkiss makes to the tab title is in the article view, where it shows +`<article title> | <page's own title>`; list views restore the page's original `<title>` exactly. ## Embedding in an existing page @@ -353,11 +352,6 @@ demo does. ```html <nav id="tag-filters" aria-label="Filter by tag"></nav> ``` -- **Site title link — `#site-title`.** Optional; its text is set to the `siteName` string once at - startup, so it stays in sync with the resolved locale without editing the page per language. - ```html - <a href="#" id="site-title">My Site</a> - ``` `#tag-filters` is optional — omit it and nothing breaks, the article list and search still work standalone. diff --git a/js/router.js b/js/router.js index e9fa7e1..bcdf633 100644 --- a/js/router.js +++ b/js/router.js @@ -78,13 +78,6 @@ function init() { if (!document.getElementById('list-view') || !document.getElementById('article-view')) { throw new Error('Missing required #list-view and/or #article-view element — see the "Embedding in an existing page" section of the README.'); } - // Optional embedding-page markup (see "Embedding in an existing - // page" in the README) — set once here rather than in - // showListView()/loadArticle() so a page that loads straight into - // an article route (a direct link) still gets it, not just one that - // starts on the list view. - const siteTitle = document.getElementById('site-title'); - if (siteTitle) siteTitle.textContent = t('siteName'); }); // Show a top-level error if dependencies fail to load (or a mount point diff --git a/js/views.js b/js/views.js index 2bedb1d..be652bc 100644 --- a/js/views.js +++ b/js/views.js @@ -18,6 +18,12 @@ let currentGeneration = 0; // everything. let lastListHash = '#'; +// The embedding page's own <title>, captured once when this module first +// runs (module scripts are deferred, so <title> is already parsed). cmkiss +// never names the page itself — list views restore this exactly, and the +// article view only prefixes it with the article's title. +const pageTitle = document.title; + function formatDate(value) { if (!value) return ''; const date = new Date(`${String(value).slice(0, 10)}T12:00:00`); @@ -27,7 +33,7 @@ function formatDate(value) { export function showListView() { document.getElementById('list-view').hidden = false; document.getElementById('article-view').hidden = true; - document.title = t('siteName'); + document.title = pageTitle; } export function showArticleView() { @@ -552,7 +558,8 @@ export async function loadArticle(hash) { // cards, the description field here stays frontmatter-only (no // auto-excerpt) — the full content is right below it either way. const { readingTime, coverUrl } = deriveContentFields(meta, content, article.path); - document.title = `${meta.title || article.slug} | ${t('siteName')}`; + // Skip the separator when the embedding page has no <title> of its own. + document.title = `${meta.title || article.slug}${pageTitle ? ` | ${pageTitle}` : ''}`; const element = document.importNode(templates.article, true); const field = name => element.querySelector(`[data-field="${name}"]`); field('title').textContent = meta.title || article.slug; diff --git a/strings/cs.json b/strings/cs.json index d82ed90..d9c4c2f 100644 --- a/strings/cs.json +++ b/strings/cs.json @@ -1,5 +1,4 @@ { - "siteName": "Ukázkový blog", "appStartError": "Blog se nepodařilo spustit: {message}", "articleNotFound": "Článek nebyl nalezen", diff --git a/strings/en.json b/strings/en.json index 02f9964..ed633b8 100644 --- a/strings/en.json +++ b/strings/en.json @@ -1,5 +1,4 @@ { - "siteName": "Example Blog", "appStartError": "Failed to start the blog: {message}", "articleNotFound": "Article not found", diff --git a/strings/sk.json b/strings/sk.json index ff81b7b..351af10 100644 --- a/strings/sk.json +++ b/strings/sk.json @@ -1,5 +1,4 @@ { - "siteName": "Ukážkový blog", "appStartError": "Blog sa nepodarilo spustiť: {message}", "articleNotFound": "Článok nebol nájdený", -- 2.54.0