From 592acc152dc68e0f24300c090c9eabb9f21cef6b Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 10 Jan 2023 19:32:22 -0400 Subject: remove output-specific getPagePaths util --- src/util/urls.js | 33 ---------------------- src/write/build-modes/static-build.js | 53 +++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 57 deletions(-) (limited to 'src') diff --git a/src/util/urls.js b/src/util/urls.js index 4672c6a2..a74e0dfb 100644 --- a/src/util/urls.js +++ b/src/util/urls.js @@ -238,36 +238,3 @@ export function getPagePathname({ export function getPageSubdirectoryPrefix({urlArgs}) { return '../'.repeat(urlArgs.join('/').split('/').length - 1); } - -export function getPagePaths({ - baseDirectory, - fullKey, - outputPath, - urlArgs, - urls, -}) { - const [groupKey, subKey] = fullKey.split('.'); - - const pathname = getPagePathname({ - baseDirectory, - device: true, - fullKey, - urlArgs, - urls, - }); - - const outputDirectory = path.join(outputPath, pathname); - - const output = { - directory: outputDirectory, - documentHTML: path.join(outputDirectory, 'index.html'), - oEmbedJSON: path.join(outputDirectory, 'oembed.json'), - }; - - return { - urlPath: [fullKey, ...urlArgs], - - output, - pathname, - }; -} diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js index 90fc38ae..bbf97085 100644 --- a/src/write/build-modes/static-build.js +++ b/src/write/build-modes/static-build.js @@ -27,7 +27,6 @@ import { import { getPagePathname, - getPagePaths, getPageSubdirectoryPrefix, getURLsFrom, getURLsFromRoot, @@ -267,6 +266,7 @@ export async function go({ ...pageWrites.map(page => () => { const pageSubKey = page.path[0]; const urlArgs = page.path.slice(1); + const fullKey = 'localized.' + pageSubKey; const localizedPathnames = withEntries(languages, entries => entries .filter(([key, language]) => key !== 'default' && !language.hidden) @@ -277,19 +277,17 @@ export async function go({ (language === defaultLanguage ? '' : language.code), - fullKey: 'localized.' + pageSubKey, + fullKey, urlArgs, urls, }), ])); - const paths = getPagePaths({ - outputPath, - urls, - + const pathname = getPagePathname({ baseDirectory, - fullKey: 'localized.' + pageSubKey, + fullKey, urlArgs, + urls, }); const to = getURLsFrom({ @@ -328,7 +326,7 @@ export async function go({ wikiData.wikiInfo.canonicalBase + urls .from('shared.root') - .to('shared.path', paths.pathname + 'oembed.json'); + .to('shared.path', pathname + 'oembed.json'); const pageHTML = generateDocumentHTML(pageInfo, { cachebust, @@ -340,7 +338,7 @@ export async function go({ localizedPathnames, oEmbedJSONHref, pageSubKey, - pathname: paths.pathname, + pathname, to, transformMultiline: bound.transformMultiline, urlArgs, @@ -350,7 +348,13 @@ export async function go({ return writePage({ html: pageHTML, oEmbedJSON, - paths, + outputDirectory: path.join(outputPath, getPagePathname({ + baseDirectory, + device: true, + fullKey, + urlArgs, + urls, + })), }); }), ...redirectWrites.map(({fromPath, toPath, title: titleFn}) => () => { @@ -358,15 +362,6 @@ export async function go({ language, }); - const from = getPagePaths({ - outputPath, - urls, - - baseDirectory, - fullKey: 'localized.' + fromPath[0], - urlArgs: fromPath.slice(1), - }); - const to = getURLsFrom({ urls, baseDirectory, @@ -378,7 +373,17 @@ export async function go({ const target = to('localized.' + toPath[0], ...toPath.slice(1)); const html = generateRedirectHTML(title, target, {language}); - return writePage({html, paths: from}); + + return writePage({ + html, + outputDirectory: path.join(outputPath, getPagePathname({ + baseDirectory, + device: true, + fullKey: 'localized.' + fromPath[0], + urlArgs: fromPath.slice(1), + urls, + })), + }); }), ], queueSize)); }; @@ -424,15 +429,15 @@ import { async function writePage({ html, oEmbedJSON = '', - paths, + outputDirectory, }) { - await mkdir(paths.output.directory, {recursive: true}); + await mkdir(outputDirectory, {recursive: true}); await Promise.all([ - writeFile(paths.output.documentHTML, html), + writeFile(path.join(outputDirectory, 'index.html'), html), oEmbedJSON && - writeFile(paths.output.oEmbedJSON, oEmbedJSON), + writeFile(path.join(outputDirectory, 'oembed.json'), oEmbedJSON), ].filter(Boolean)); } -- cgit 1.3.0-6-gf8a5 From e06292fe8e7d789d38ac43fd9eee6816e39e18fe Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 10 Jan 2023 19:45:13 -0400 Subject: extract fn for localizedPathnames --- src/util/urls.js | 23 +++++++++++++++++++++++ src/write/build-modes/live-dev-server.js | 23 ++++++++--------------- src/write/build-modes/static-build.js | 24 +++++++++--------------- 3 files changed, 40 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/util/urls.js b/src/util/urls.js index a74e0dfb..ead6c769 100644 --- a/src/util/urls.js +++ b/src/util/urls.js @@ -233,6 +233,29 @@ export function getPagePathname({ ...urlArgs)); } +export function getPagePathnameAcrossLanguages({ + defaultLanguage, + languages, + pageSubKey, + urlArgs, + urls, +}) { + return withEntries(languages, entries => entries + .filter(([key, language]) => key !== 'default' && !language.hidden) + .map(([_key, language]) => [ + language.code, + getPagePathname({ + baseDirectory: + (language === defaultLanguage + ? '' + : language.code), + fullKey: 'localized.' + pageSubKey, + urlArgs, + urls, + }), + ])); +} + // Needed for the rare path arguments which themselves contains one or more // slashes, e.g. for listings, with arguments like 'albums/by-name'. export function getPageSubdirectoryPrefix({urlArgs}) { diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index b6bf662b..a5d9da97 100644 --- a/src/write/build-modes/live-dev-server.js +++ b/src/write/build-modes/live-dev-server.js @@ -11,10 +11,10 @@ import {serializeThings} from '../../data/serialize.js'; import * as pageSpecs from '../../page/index.js'; import {logInfo, logWarn, progressCallAll} from '../../util/cli.js'; -import {withEntries} from '../../util/sugar.js'; import { getPagePathname, + getPagePathnameAcrossLanguages, getPageSubdirectoryPrefix, getURLsFrom, getURLsFromRoot, @@ -280,20 +280,13 @@ export async function go({ response.writeHead(200, contentTypeHTML); - const localizedPathnames = withEntries(languages, entries => entries - .filter(([key, language]) => key !== 'default' && !language.hidden) - .map(([_key, language]) => [ - language.code, - getPagePathname({ - baseDirectory: - (language === defaultLanguage - ? '' - : language.code), - fullKey: 'localized.' + pageSubKey, - urlArgs, - urls, - }), - ])); + const localizedPathnames = getPagePathnameAcrossLanguages({ + defaultLanguage, + languages, + pageSubKey, + urlArgs, + urls, + }); const bound = bindUtilities({ absoluteTo, diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js index bbf97085..0e8c4b07 100644 --- a/src/write/build-modes/static-build.js +++ b/src/write/build-modes/static-build.js @@ -15,7 +15,7 @@ import {serializeThings} from '../../data/serialize.js'; import * as pageSpecs from '../../page/index.js'; import link from '../../util/link.js'; -import {empty, queue, withEntries} from '../../util/sugar.js'; +import {empty, queue} from '../../util/sugar.js'; import { logError, @@ -27,6 +27,7 @@ import { import { getPagePathname, + getPagePathnameAcrossLanguages, getPageSubdirectoryPrefix, getURLsFrom, getURLsFromRoot, @@ -268,20 +269,13 @@ export async function go({ const urlArgs = page.path.slice(1); const fullKey = 'localized.' + pageSubKey; - const localizedPathnames = withEntries(languages, entries => entries - .filter(([key, language]) => key !== 'default' && !language.hidden) - .map(([_key, language]) => [ - language.code, - getPagePathname({ - baseDirectory: - (language === defaultLanguage - ? '' - : language.code), - fullKey, - urlArgs, - urls, - }), - ])); + const localizedPathnames = getPagePathnameAcrossLanguages({ + defaultLanguage, + languages, + pageSubKey, + urlArgs, + urls, + }); const pathname = getPagePathname({ baseDirectory, -- cgit 1.3.0-6-gf8a5 From fd59ddd05bdfebf2f9a55a0fa5915485929e7de6 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 10 Jan 2023 19:54:10 -0400 Subject: don't pass around fullKey where unneeded --- src/util/urls.js | 22 ++++++---------------- src/write/build-modes/live-dev-server.js | 7 ++----- src/write/build-modes/static-build.js | 7 +++---- 3 files changed, 11 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/util/urls.js b/src/util/urls.js index ead6c769..0733ce04 100644 --- a/src/util/urls.js +++ b/src/util/urls.js @@ -213,24 +213,14 @@ export function getURLsFromRoot({ export function getPagePathname({ baseDirectory, device = false, - fullKey, + pageSubKey, urlArgs, urls, }) { - const [groupKey, subKey] = fullKey.split('.'); - - const toKey = device ? 'toDevice' : 'to'; - - return (groupKey === 'localized' && baseDirectory - ? urls - .from('shared.root')[toKey]( - 'localizedWithBaseDirectory.' + subKey, - baseDirectory, - ...urlArgs) - : urls - .from('shared.root')[toKey]( - fullKey, - ...urlArgs)); + const to = urls.from('shared.root')[device ? 'toDevice' : 'to']; + return (baseDirectory + ? to('localizedWithBaseDirectory.' + pageSubKey, baseDirectory, ...urlArgs) + : to('localized.' + pageSubKey, ...urlArgs)); } export function getPagePathnameAcrossLanguages({ @@ -249,7 +239,7 @@ export function getPagePathnameAcrossLanguages({ (language === defaultLanguage ? '' : language.code), - fullKey: 'localized.' + pageSubKey, + pageSubKey, urlArgs, urls, }), diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index a5d9da97..bdd4561e 100644 --- a/src/write/build-modes/live-dev-server.js +++ b/src/write/build-modes/live-dev-server.js @@ -83,17 +83,14 @@ export async function go({ else if (page.type === 'redirect') servePath = page.fromPath; - const fullKey = 'localized.' + servePath[0]; - const urlArgs = servePath.slice(1); - return Object.values(languages).map(language => { const baseDirectory = language === defaultLanguage ? '' : language.code; const pathname = getPagePathname({ baseDirectory, - fullKey, - urlArgs, + pageSubKey: servePath[0], + urlArgs: servePath.slice(1), urls, }); diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js index 0e8c4b07..edfb02c2 100644 --- a/src/write/build-modes/static-build.js +++ b/src/write/build-modes/static-build.js @@ -267,7 +267,6 @@ export async function go({ ...pageWrites.map(page => () => { const pageSubKey = page.path[0]; const urlArgs = page.path.slice(1); - const fullKey = 'localized.' + pageSubKey; const localizedPathnames = getPagePathnameAcrossLanguages({ defaultLanguage, @@ -279,7 +278,7 @@ export async function go({ const pathname = getPagePathname({ baseDirectory, - fullKey, + pageSubKey, urlArgs, urls, }); @@ -345,7 +344,7 @@ export async function go({ outputDirectory: path.join(outputPath, getPagePathname({ baseDirectory, device: true, - fullKey, + pageSubKey, urlArgs, urls, })), @@ -373,7 +372,7 @@ export async function go({ outputDirectory: path.join(outputPath, getPagePathname({ baseDirectory, device: true, - fullKey: 'localized.' + fromPath[0], + pageSubKey: fromPath[0], urlArgs: fromPath.slice(1), urls, })), -- cgit 1.3.0-6-gf8a5 From 54ad9946e3fa32ae8388d54ec8b3baad78a29417 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 10 Jan 2023 20:20:18 -0400 Subject: prefer passing around pagePath --- src/misc-templates.js | 13 ++++++----- src/util/urls.js | 37 +++++++++++++++++++------------- src/write/build-modes/live-dev-server.js | 16 +++++--------- src/write/build-modes/static-build.js | 26 +++++++++------------- src/write/page-template.js | 11 ++++------ 5 files changed, 47 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/misc-templates.js b/src/misc-templates.js index 6659d72b..794b6920 100644 --- a/src/misc-templates.js +++ b/src/misc-templates.js @@ -973,10 +973,8 @@ function unbound_getFooterLocalizationLinks(pathname, { defaultLanguage, language, languages, + pagePath, to, - - pageSubKey, - urlArgs, }) { const links = Object.entries(languages) .filter(([code, language]) => code !== 'default' && !language.hidden) @@ -989,11 +987,12 @@ function unbound_getFooterLocalizationLinks(pathname, { href: language === defaultLanguage ? to( - 'localizedDefaultLanguage.' + pageSubKey, - ...urlArgs) + 'localizedDefaultLanguage.' + pagePath[0], + ...pagePath.slice(1)) : to( - 'localizedWithBaseDirectory.' + pageSubKey, - language.code, ...urlArgs), + 'localizedWithBaseDirectory.' + pagePath[0], + language.code, + ...pagePath.slice(1)), }, language.name))); diff --git a/src/util/urls.js b/src/util/urls.js index 0733ce04..1c7d1c58 100644 --- a/src/util/urls.js +++ b/src/util/urls.js @@ -143,9 +143,11 @@ export function getURLsFrom({ urls, baseDirectory, - pageSubKey, + pagePath, subdirectoryPrefix, }) { + const pageSubKey = pagePath[0]; + return (targetFullKey, ...args) => { const [groupKey, subKey] = targetFullKey.split('.'); let path = subdirectoryPrefix; @@ -193,19 +195,19 @@ export function getURLsFromRoot({ baseDirectory, urls, }) { - const from = urls.from('shared.root'); + const {to} = urls.from('shared.root'); return (targetFullKey, ...args) => { const [groupKey, subKey] = targetFullKey.split('.'); return ( '/' + (groupKey === 'localized' && baseDirectory - ? from.to( + ? to( 'localizedWithBaseDirectory.' + subKey, baseDirectory, ...args ) - : from.to(targetFullKey, ...args)) + : to(targetFullKey, ...args)) ); }; } @@ -213,21 +215,20 @@ export function getURLsFromRoot({ export function getPagePathname({ baseDirectory, device = false, - pageSubKey, - urlArgs, + pagePath, urls, }) { - const to = urls.from('shared.root')[device ? 'toDevice' : 'to']; + const {[device ? 'toDevice' : 'to']: to} = urls.from('shared.root'); + return (baseDirectory - ? to('localizedWithBaseDirectory.' + pageSubKey, baseDirectory, ...urlArgs) - : to('localized.' + pageSubKey, ...urlArgs)); + ? to('localizedWithBaseDirectory.' + pagePath[0], baseDirectory, ...pagePath.slice(1)) + : to('localized.' + pagePath[0], ...pagePath.slice(1))); } export function getPagePathnameAcrossLanguages({ defaultLanguage, languages, - pageSubKey, - urlArgs, + pagePath, urls, }) { return withEntries(languages, entries => entries @@ -239,8 +240,7 @@ export function getPagePathnameAcrossLanguages({ (language === defaultLanguage ? '' : language.code), - pageSubKey, - urlArgs, + pagePath, urls, }), ])); @@ -248,6 +248,13 @@ export function getPagePathnameAcrossLanguages({ // Needed for the rare path arguments which themselves contains one or more // slashes, e.g. for listings, with arguments like 'albums/by-name'. -export function getPageSubdirectoryPrefix({urlArgs}) { - return '../'.repeat(urlArgs.join('/').split('/').length - 1); +export function getPageSubdirectoryPrefix({ + pagePath, +}) { + const timesNestedDeeply = (pagePath + .slice(1) // skip URL key, only check arguments + .join('/') + .split('/') + .length - 1); + return '../'.repeat(timesNestedDeeply); } diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index bdd4561e..ec9689bd 100644 --- a/src/write/build-modes/live-dev-server.js +++ b/src/write/build-modes/live-dev-server.js @@ -89,8 +89,7 @@ export async function go({ const pathname = getPagePathname({ baseDirectory, - pageSubKey: servePath[0], - urlArgs: servePath.slice(1), + pagePath: servePath, urls, }); @@ -248,9 +247,9 @@ export async function go({ const to = getURLsFrom({ urls, baseDirectory, - pageSubKey: servePath[0], + pagePath: servePath, subdirectoryPrefix: getPageSubdirectoryPrefix({ - urlArgs: servePath.slice(1), + pagePath: servePath, }), }); @@ -260,9 +259,6 @@ export async function go({ }); try { - const pageSubKey = servePath[0]; - const urlArgs = servePath.slice(1); - if (page.type === 'redirect') { response.writeHead(301, contentTypeHTML); @@ -280,8 +276,7 @@ export async function go({ const localizedPathnames = getPagePathnameAcrossLanguages({ defaultLanguage, languages, - pageSubKey, - urlArgs, + pagePath: servePath, urls, }); @@ -305,9 +300,8 @@ export async function go({ languages, localizedPathnames, oEmbedJSONHref: null, // No oEmbed support for live dev server - pageSubKey, + pagePath: servePath, pathname, - urlArgs, to, transformMultiline: bound.transformMultiline, wikiData, diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js index edfb02c2..5141891c 100644 --- a/src/write/build-modes/static-build.js +++ b/src/write/build-modes/static-build.js @@ -265,30 +265,27 @@ export async function go({ await progressPromiseAll(`Writing ${language.code}`, queue([ ...pageWrites.map(page => () => { - const pageSubKey = page.path[0]; - const urlArgs = page.path.slice(1); + const pagePath = page.path; const localizedPathnames = getPagePathnameAcrossLanguages({ defaultLanguage, languages, - pageSubKey, - urlArgs, + pagePath, urls, }); const pathname = getPagePathname({ baseDirectory, - pageSubKey, - urlArgs, + pagePath, urls, }); const to = getURLsFrom({ urls, baseDirectory, - pageSubKey, + pagePath, subdirectoryPrefix: getPageSubdirectoryPrefix({ - urlArgs: page.path.slice(1), + pagePath, }), }); @@ -330,11 +327,10 @@ export async function go({ languages, localizedPathnames, oEmbedJSONHref, - pageSubKey, + pagePath, pathname, to, transformMultiline: bound.transformMultiline, - urlArgs, wikiData, }); @@ -344,8 +340,7 @@ export async function go({ outputDirectory: path.join(outputPath, getPagePathname({ baseDirectory, device: true, - pageSubKey, - urlArgs, + pagePath, urls, })), }); @@ -358,9 +353,9 @@ export async function go({ const to = getURLsFrom({ urls, baseDirectory, - pageSubKey: fromPath[0], + pagePath: fromPath, subdirectoryPrefix: getPageSubdirectoryPrefix({ - urlArgs: fromPath.slice(1), + pagePath: fromPath, }), }); @@ -372,8 +367,7 @@ export async function go({ outputDirectory: path.join(outputPath, getPagePathname({ baseDirectory, device: true, - pageSubKey: fromPath[0], - urlArgs: fromPath.slice(1), + pagePath: fromPath, urls, })), }); diff --git a/src/write/page-template.js b/src/write/page-template.js index 88d81c23..7c2f0c66 100644 --- a/src/write/page-template.js +++ b/src/write/page-template.js @@ -55,11 +55,10 @@ export function generateDocumentHTML(pageInfo, { languages, localizedPathnames, oEmbedJSONHref, - pageSubKey, + pagePath, pathname, to, transformMultiline, - urlArgs, wikiData, }) { const {wikiInfo} = wikiData; @@ -169,9 +168,8 @@ export function generateDocumentHTML(pageInfo, { html, language, languages, - pageSubKey, + pagePath, to, - urlArgs, }), ]); @@ -450,10 +448,9 @@ export function generateDocumentHTML(pageInfo, { { lang: language.intlCode, 'data-language-code': language.code, - 'data-url-key': 'localized.' + pageSubKey, + 'data-url-key': 'localized.' + pagePath[0], ...Object.fromEntries( - urlArgs.map((v, i) => [['data-url-value' + i], v]) - ), + pagePath.slice(1).map((v, i) => [['data-url-value' + i], v])), 'data-rebase-localized': to('localized.root'), 'data-rebase-shared': to('shared.root'), 'data-rebase-media': to('media.root'), -- cgit 1.3.0-6-gf8a5 From ba8a441f95481e294d414a0c89e2513f82f45a7a Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 10 Jan 2023 20:28:22 -0400 Subject: compute subdirectoryPrefix internally --- src/util/urls.js | 16 ++++++---------- src/write/build-modes/live-dev-server.js | 6 +----- src/write/build-modes/static-build.js | 11 ++--------- 3 files changed, 9 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/util/urls.js b/src/util/urls.js index 1c7d1c58..c2119b8d 100644 --- a/src/util/urls.js +++ b/src/util/urls.js @@ -140,20 +140,16 @@ export const thumb = { // Makes the generally-used and wiki-specialized "to" page utility. // "to" returns a relative path from the current page to the target. export function getURLsFrom({ - urls, - baseDirectory, pagePath, - subdirectoryPrefix, + urls, }) { const pageSubKey = pagePath[0]; + const subdirectoryPrefix = getPageSubdirectoryPrefix({pagePath}); return (targetFullKey, ...args) => { const [groupKey, subKey] = targetFullKey.split('.'); - let path = subdirectoryPrefix; - - let from; - let to; + let from, to; // When linking to *outside* the localized area of the site, we need to // make sure the result is correctly relative to the 8ase directory. @@ -182,9 +178,9 @@ export function getURLsFrom({ to = targetFullKey; } - path += urls.from(from).to(to, ...args); - - return path; + return ( + subdirectoryPrefix + + urls.from(from).to(to, ...args)); }; } diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index ec9689bd..a4c4c871 100644 --- a/src/write/build-modes/live-dev-server.js +++ b/src/write/build-modes/live-dev-server.js @@ -15,7 +15,6 @@ import {logInfo, logWarn, progressCallAll} from '../../util/cli.js'; import { getPagePathname, getPagePathnameAcrossLanguages, - getPageSubdirectoryPrefix, getURLsFrom, getURLsFromRoot, } from '../../util/urls.js'; @@ -245,12 +244,9 @@ export async function go({ } = urlToPageMap[pathnameKey]; const to = getURLsFrom({ - urls, baseDirectory, pagePath: servePath, - subdirectoryPrefix: getPageSubdirectoryPrefix({ - pagePath: servePath, - }), + urls, }); const absoluteTo = getURLsFromRoot({ diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js index 5141891c..23c6470a 100644 --- a/src/write/build-modes/static-build.js +++ b/src/write/build-modes/static-build.js @@ -28,7 +28,6 @@ import { import { getPagePathname, getPagePathnameAcrossLanguages, - getPageSubdirectoryPrefix, getURLsFrom, getURLsFromRoot, } from '../../util/urls.js'; @@ -281,12 +280,9 @@ export async function go({ }); const to = getURLsFrom({ - urls, baseDirectory, pagePath, - subdirectoryPrefix: getPageSubdirectoryPrefix({ - pagePath, - }), + urls, }); const absoluteTo = getURLsFromRoot({ @@ -351,12 +347,9 @@ export async function go({ }); const to = getURLsFrom({ - urls, baseDirectory, pagePath: fromPath, - subdirectoryPrefix: getPageSubdirectoryPrefix({ - pagePath: fromPath, - }), + urls, }); const target = to('localized.' + toPath[0], ...toPath.slice(1)); -- cgit 1.3.0-6-gf8a5 From c09e733544f8f47850532aecee4d14887ffd83db Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 10 Jan 2023 20:39:21 -0400 Subject: remove unused arg from getFooterLocalizationLinks eslint didn't warn about this ???????????? --- src/misc-templates.js | 2 +- src/write/page-template.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/misc-templates.js b/src/misc-templates.js index 794b6920..7cfdc86c 100644 --- a/src/misc-templates.js +++ b/src/misc-templates.js @@ -968,7 +968,7 @@ function unbound_generateStickyHeadingContainer({ // Footer stuff -function unbound_getFooterLocalizationLinks(pathname, { +function unbound_getFooterLocalizationLinks({ html, defaultLanguage, language, diff --git a/src/write/page-template.js b/src/write/page-template.js index 7c2f0c66..0bf0a98e 100644 --- a/src/write/page-template.js +++ b/src/write/page-template.js @@ -163,7 +163,7 @@ export function generateDocumentHTML(pageInfo, { }, footer.content), - getFooterLocalizationLinks(pathname, { + getFooterLocalizationLinks({ defaultLanguage, html, language, -- cgit 1.3.0-6-gf8a5 From d0abc02e2cf6e5648d1e0c2833bb109fd4976e0e Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 10 Jan 2023 20:41:19 -0400 Subject: remove legacy navbar {href} handler this references pathname so it totally makes sense to include with other url/path-related changes --- src/write/page-template.js | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src') diff --git a/src/write/page-template.js b/src/write/page-template.js index 0bf0a98e..6ed9fcf5 100644 --- a/src/write/page-template.js +++ b/src/write/page-template.js @@ -1,7 +1,6 @@ import chroma from 'chroma-js'; import * as html from '../util/html.js'; -import {logWarn} from '../util/cli.js'; import {getColors} from '../util/colors.js'; import { @@ -263,11 +262,6 @@ export function generateDocumentHTML(pageInfo, { ? to('localized.home') : cur.path ? to(...cur.path) - : cur.href - ? (() => { - logWarn`Using legacy href format nav link in ${pathname}`; - return cur.href; - })() : null, }; if (attributes.href === null) { -- cgit 1.3.0-6-gf8a5 From 7bca1c6b41f7df9a20dd73872c7b1e9653776485 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 10 Jan 2023 20:43:57 -0400 Subject: indentation opinion --- src/write/build-modes/static-build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js index 23c6470a..691ce579 100644 --- a/src/write/build-modes/static-build.js +++ b/src/write/build-modes/static-build.js @@ -309,7 +309,7 @@ export async function go({ const oEmbedJSONHref = oEmbedJSON && wikiData.wikiInfo.canonicalBase && - wikiData.wikiInfo.canonicalBase + + wikiData.wikiInfo.canonicalBase + urls .from('shared.root') .to('shared.path', pathname + 'oembed.json'); -- cgit 1.3.0-6-gf8a5 From 7f6d21d480e22765f438d5a80227f89c416b770b Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 10 Jan 2023 20:47:38 -0400 Subject: bind more language vars, pass to generateDocumentHTML --- src/write/bind-utilities.js | 4 ++++ src/write/build-modes/live-dev-server.js | 10 +++------- src/write/build-modes/static-build.js | 10 +++------- 3 files changed, 10 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/write/bind-utilities.js b/src/write/bind-utilities.js index 4b037a91..6212b824 100644 --- a/src/write/bind-utilities.js +++ b/src/write/bind-utilities.js @@ -52,8 +52,10 @@ import { export function bindUtilities({ absoluteTo, + defaultLanguage, getSizeOfAdditionalFile, language, + languages, to, urls, wikiData, @@ -65,9 +67,11 @@ export function bindUtilities({ Object.assign(bound, { absoluteTo, + defaultLanguage, getSizeOfAdditionalFile, html, language, + languages, to, urls, wikiData, diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index a4c4c871..0e2b6160 100644 --- a/src/write/build-modes/live-dev-server.js +++ b/src/write/build-modes/live-dev-server.js @@ -278,8 +278,10 @@ export async function go({ const bound = bindUtilities({ absoluteTo, + defaultLanguage, getSizeOfAdditionalFile, language, + languages, to, urls, wikiData, @@ -288,19 +290,13 @@ export async function go({ const pageInfo = page.page(bound); const pageHTML = generateDocumentHTML(pageInfo, { + ...bound, cachebust, - defaultLanguage, developersComment, - getThemeString: bound.getThemeString, - language, - languages, localizedPathnames, oEmbedJSONHref: null, // No oEmbed support for live dev server pagePath: servePath, pathname, - to, - transformMultiline: bound.transformMultiline, - wikiData, }); console.log(`${requestHead} [200] ${pathname}`); diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js index 691ce579..220e51f4 100644 --- a/src/write/build-modes/static-build.js +++ b/src/write/build-modes/static-build.js @@ -292,8 +292,10 @@ export async function go({ const bound = bindUtilities({ absoluteTo, + defaultLanguage, getSizeOfAdditionalFile, language, + languages, to, urls, wikiData, @@ -315,19 +317,13 @@ export async function go({ .to('shared.path', pathname + 'oembed.json'); const pageHTML = generateDocumentHTML(pageInfo, { + ...bound, cachebust, - defaultLanguage, developersComment, - getThemeString: bound.getThemeString, - language, - languages, localizedPathnames, oEmbedJSONHref, pagePath, pathname, - to, - transformMultiline: bound.transformMultiline, - wikiData, }); return writePage({ -- cgit 1.3.0-6-gf8a5