diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-01-10 19:45:13 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-01-10 19:45:32 -0400 |
commit | e06292fe8e7d789d38ac43fd9eee6816e39e18fe (patch) | |
tree | b640471c8d401df418d94af6b8bfc3ce3e81c1ec /src/write/build-modes | |
parent | 592acc152dc68e0f24300c090c9eabb9f21cef6b (diff) |
extract fn for localizedPathnames
Diffstat (limited to 'src/write/build-modes')
-rw-r--r-- | src/write/build-modes/live-dev-server.js | 23 | ||||
-rw-r--r-- | src/write/build-modes/static-build.js | 24 |
2 files changed, 17 insertions, 30 deletions
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, |