diff --git a/website/src/hooks.server.js b/website/src/hooks.server.js index 7ae57ddf..3b41f793 100644 --- a/website/src/hooks.server.js +++ b/website/src/hooks.server.js @@ -3,16 +3,24 @@ import { languages } from '$lib/languages'; import { getURLForLanguage } from '$lib/utils'; export async function handle({ event, resolve }) { - let language = event.params.language ?? 'en'; + const language = event.params.language ?? 'en'; const strings = await import(`./locales/${language}.json`); - let path = event.url.pathname; - let page = event.route.id?.replace('/[[language]]', '').split('/')[1] ?? 'home'; + const path = event.url.pathname; + const page = event.route.id?.replace('/[[language]]', '').split('/')[1] ?? 'home'; let title = strings.metadata[`${page}_title`]; - let description = strings.metadata[`description`]; + const description = strings.metadata[`description`]; - let htmlTag = ``; + if (page === 'help' && event.params.guide) { + const [guide, subguide] = event.params.guide.split('/'); + const guideModule = subguide + ? await import(`./lib/docs/${language}/${guide}/${subguide}.mdx`) + : await import(`./lib/docs/${language}/${guide}.mdx`); + title = `${title} | ${guideModule.metadata.title}`; + } + + const htmlTag = ``; let headTag = ` gpx.studio — ${title} @@ -37,7 +45,7 @@ export async function handle({ event, resolve }) { `; } - let stringsHTML = page === 'app' ? stringsToHTML(strings) : ''; + const stringsHTML = page === 'app' ? stringsToHTML(strings) : ''; const response = await resolve(event, { transformPageChunk: ({ html }) => html.replace('', htmlTag).replace('', headTag).replace('', ``) diff --git a/website/src/routes/+layout.svelte b/website/src/routes/+layout.svelte index 13b0e51f..99df6715 100644 --- a/website/src/routes/+layout.svelte +++ b/website/src/routes/+layout.svelte @@ -1,63 +1,73 @@
- {#if !$isLoading} - {#if showNavAndFooter} -
diff --git a/website/src/routes/[[language]]/help/+layout.ts b/website/src/routes/[[language]]/help/+layout.ts index da265721..f1bf5e82 100644 --- a/website/src/routes/[[language]]/help/+layout.ts +++ b/website/src/routes/[[language]]/help/+layout.ts @@ -2,9 +2,9 @@ import { guides } from '$lib/components/docs/docs.js'; function getModule(language: string | undefined, guide: string) { language = language ?? 'en'; - let subguide = guide.includes('/') ? guide.split('/').pop() : undefined; - if (subguide) { - guide = guide.replace(`/${subguide}`, ''); + let subguide = undefined; + if (guide.includes('/')) { + [guide, subguide] = guide.split('/'); } return subguide ? import(`./../../../lib/docs/${language}/${guide}/${subguide}.mdx`) diff --git a/website/src/routes/[[language]]/help/[...guide]/+page.ts b/website/src/routes/[[language]]/help/[...guide]/+page.ts index bd81a031..1d32699a 100644 --- a/website/src/routes/[[language]]/help/[...guide]/+page.ts +++ b/website/src/routes/[[language]]/help/[...guide]/+page.ts @@ -2,9 +2,9 @@ import { getNextGuide, getPreviousGuide } from "$lib/components/docs/docs"; function getModule(language: string | undefined, guide: string) { language = language ?? 'en'; - let subguide = guide.includes('/') ? guide.split('/').pop() : undefined; - if (subguide) { - guide = guide.replace(`/${subguide}`, ''); + let subguide = undefined; + if (guide.includes('/')) { + [guide, subguide] = guide.split('/'); } return subguide ? import(`./../../../../lib/docs/${language}/${guide}/${subguide}.mdx`)