diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/util/urls.js | 33 | ||||
-rw-r--r-- | src/write/build-modes/static-build.js | 53 |
2 files changed, 29 insertions, 57 deletions
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)); } |