From a040cb80a4a25f208c645f44fbd6d1f6b2e6f8f0 Mon Sep 17 00:00:00 2001 From: kaby76 Date: Mon, 1 Jun 2026 05:58:41 -0400 Subject: [PATCH 1/4] Fix subdirectory pages having wrong baseUrl due to settings.scroll override root header.scroll imported settings.scroll (baseUrl http://pldb.info/), which overrode subdirectory-specific baseUrl settings (blog/, lists/, features/, pages/) since it was always imported last. This caused canonical URLs, OG image URLs, and "Continue reading" links to point to the root instead of the correct subdirectory path. Fix by removing settings.scroll from header.scroll and placing it in rootHeader.scroll (used only by root-level pages) and 404.scroll (the only root-level file that imports header.scroll directly). Co-Authored-By: Claude Sonnet 4.6 --- 404.scroll | 1 + header.scroll | 1 - rootHeader.scroll | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/404.scroll b/404.scroll index 73370b1c454d..87328de56126 100644 --- a/404.scroll +++ b/404.scroll @@ -3,6 +3,7 @@ editBaseUrl /edit.html?folderName=pldb.info&fileName= replace BASE_URL title Page not found +settings.scroll header.scroll theme gazette diff --git a/header.scroll b/header.scroll index fd212e40b4f0..34d32ee4839b 100644 --- a/header.scroll +++ b/header.scroll @@ -1,7 +1,6 @@ importOnly rssFeedUrl BASE_URL/blog/feed.xml -settings.scroll metaTags emailBanner.scroll diff --git a/rootHeader.scroll b/rootHeader.scroll index a9e33aa0412f..f9a27af2c6be 100644 --- a/rootHeader.scroll +++ b/rootHeader.scroll @@ -6,4 +6,5 @@ tags All // Set the base url. Without this trick, browsing the site locally would require serving it via localhost to get relative url paths to work since we reuse the header and footer in nested folders. (There could be a better way to do this.) keyboardNav +settings.scroll header.scroll From 7ff55ce90d0cd23cf57397f4371fa6b2f62b0183 Mon Sep 17 00:00:00 2001 From: kaby76 Date: Mon, 1 Jun 2026 07:28:33 -0400 Subject: [PATCH 2/4] Fix snippet links pointing to wrong path when URL lacks trailing slash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit printSnippetsParser and printTitleParser generated relative links (e.g. chrisLattner.html) which break when a directory page is served without a trailing slash (e.g. /blog instead of /blog/) — the browser resolves the link against the parent path, stripping the /blog/ prefix. Patch scroll-cli at build time to use root-relative paths derived from scrollProgram.absoluteLink (e.g. /blog/chrisLattner.html) instead of the bare permalink. This makes all snippet and title links work regardless of whether the URL includes a trailing slash. Co-Authored-By: Claude Sonnet 4.6 --- build.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/build.js b/build.js index cc5b16f60534..7774117c8479 100644 --- a/build.js +++ b/build.js @@ -148,6 +148,10 @@ async function build() { console.log('\n🔧 Step 2b: Patching scroll-cli copy button for non-HTTPS contexts...') patchScrollCliCopyButton() + // Step 2c: Patch scroll-cli snippets to use root-relative links + console.log('\n🔧 Step 2c: Patching scroll-cli snippets links to be root-relative...') + patchScrollCliSnippetLinks() + // Step 2.5: Fetch TIOBE top 10 and write topTiobeLangs.scroll console.log('\n📋 Step 2.5: Fetching TIOBE top 10 languages...') try { @@ -299,6 +303,42 @@ function patchScrollCliCopyButton() { } } +function patchScrollCliSnippetLinks() { + const patchFile = (filePath, oldStr, patchedStr, label) => { + if (!fs.existsSync(filePath)) return + const content = fs.readFileSync(filePath, 'utf8') + if (content.includes(oldStr)) { + fs.writeFileSync(filePath, content.replace(oldStr, patchedStr)) + console.log(` ✅ Patched ${label} in ${path.relative(ROOT, filePath)}`) + } else if (content.includes(patchedStr)) { + console.log(` Already patched ${label}: ${path.relative(ROOT, filePath)}`) + } else { + console.log(` ⚠️ ${label} pattern not found in ${path.relative(ROOT, filePath)} — scroll-cli may have changed`) + } + } + + for (const base of [ + path.join(ROOT, 'node_modules', 'scroll-cli'), + path.join(ROOT, 'node_modules', 'scroll-cli', 'node_modules', 'scroll-cli') + ]) { + // Patch "Continue reading" link in makeSnippet + patchFile( + path.join(base, 'parsers', 'snippets.parsers'), + ` const linkRelativeToCompileTarget = buildSettings.relativePath + scrollProgram.permalink`, + ` const _absLink = scrollProgram.absoluteLink\n const linkRelativeToCompileTarget = _absLink.includes("://") ? new URL(_absLink).pathname : buildSettings.relativePath + scrollProgram.permalink`, + 'snippet continue-reading link' + ) + + // Patch printTitle link in title.parsers + patchFile( + path.join(base, 'parsers', 'title.parsers'), + ` const { permalink } = this.root`, + ` const _absLink = this.root.absoluteLink\n const permalink = (_absLink && _absLink.includes("://")) ? new URL(_absLink).pathname : this.root.permalink`, + 'printTitle link' + ) + } +} + function writeMaintenancePage() { const maintenanceHtml = ` From 6a4617bcc819cd1c6564bf65544412d182254c0b Mon Sep 17 00:00:00 2001 From: kaby76 Date: Mon, 1 Jun 2026 08:23:41 -0400 Subject: [PATCH 3/4] Address Copilot review feedback - Add null guard to snippets.parsers patch: _absLink may be undefined, so check (_absLink && _absLink.includes("://")) consistently with the title.parsers patch - Add comment noting that root-relative links require a local server and do not work under file:// - Fix 404.scroll: change bare 'replace BASE_URL' to 'replace BASE_URL .' to be explicit and consistent with other root-level pages Co-Authored-By: Claude Sonnet 4.6 --- 404.scroll | 2 +- build.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/404.scroll b/404.scroll index 87328de56126..89cdbc3f5cb1 100644 --- a/404.scroll +++ b/404.scroll @@ -1,6 +1,6 @@ buildHtml editBaseUrl /edit.html?folderName=pldb.info&fileName= -replace BASE_URL +replace BASE_URL . title Page not found settings.scroll diff --git a/build.js b/build.js index 7774117c8479..407251fb043b 100644 --- a/build.js +++ b/build.js @@ -321,11 +321,14 @@ function patchScrollCliSnippetLinks() { path.join(ROOT, 'node_modules', 'scroll-cli'), path.join(ROOT, 'node_modules', 'scroll-cli', 'node_modules', 'scroll-cli') ]) { - // Patch "Continue reading" link in makeSnippet + // Patch "Continue reading" link in makeSnippet. + // Uses root-relative paths (e.g. /blog/foo.html) so links resolve correctly + // when a directory page is served without a trailing slash. Note: root-relative + // links do not work under file:// — a local server (e.g. npx serve) is required. patchFile( path.join(base, 'parsers', 'snippets.parsers'), ` const linkRelativeToCompileTarget = buildSettings.relativePath + scrollProgram.permalink`, - ` const _absLink = scrollProgram.absoluteLink\n const linkRelativeToCompileTarget = _absLink.includes("://") ? new URL(_absLink).pathname : buildSettings.relativePath + scrollProgram.permalink`, + ` const _absLink = scrollProgram.absoluteLink\n const linkRelativeToCompileTarget = (_absLink && _absLink.includes("://")) ? new URL(_absLink).pathname : buildSettings.relativePath + scrollProgram.permalink`, 'snippet continue-reading link' ) From 0d68c66f8a5f95abe812dbbe06d2fc0b2f9ef16c Mon Sep 17 00:00:00 2001 From: kaby76 Date: Mon, 1 Jun 2026 08:27:01 -0400 Subject: [PATCH 4/4] Updates. --- latestNews.scroll | 2 +- topTiobeLangs.scroll | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/latestNews.scroll b/latestNews.scroll index a741f61951bb..5b55a4fe499e 100644 --- a/latestNews.scroll +++ b/latestNews.scroll @@ -1,3 +1,3 @@ importOnly - + diff --git a/topTiobeLangs.scroll b/topTiobeLangs.scroll index f348b21d3f12..b3640cd75f43 100644 --- a/topTiobeLangs.scroll +++ b/topTiobeLangs.scroll @@ -1,5 +1,5 @@ importOnly - + Python · C · Java · C++ · C# · JavaScript · Visual Basic · R · SQL · Delphi/Object Pascal