mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-08-30 23:30:04 +00:00
preload all guide titles
This commit is contained in:
@@ -48,7 +48,7 @@ export async function handle({ event, resolve }) {
|
||||
const stringsHTML = page === 'app' ? stringsToHTML(strings) : '';
|
||||
|
||||
const response = await resolve(event, {
|
||||
transformPageChunk: ({ html }) => html.replace('<html>', htmlTag).replace('<head>', headTag).replace('<body data-sveltekit-preload-data="hover">', `<body data-sveltekit-preload-data="hover"><div class="hidden">${stringsHTML}</div>`)
|
||||
transformPageChunk: ({ html }) => html.replace('<html>', htmlTag).replace('<head>', headTag).replace('</body>', `<div class="fixed -z-10 text-transparent">${stringsHTML}</div></body>`)
|
||||
});
|
||||
|
||||
return response;
|
||||
|
@@ -14,15 +14,15 @@ function getModule(language: string | undefined, guide: string) {
|
||||
export async function load({ params }) {
|
||||
const { language } = params;
|
||||
|
||||
const guideModules: Record<string, any> = {};
|
||||
const guideTitles: Record<string, string> = {};
|
||||
for (let guide of Object.keys(guides)) {
|
||||
guideModules[guide] = getModule(language, guide);
|
||||
guideTitles[guide] = (await getModule(language, guide)).metadata.title;
|
||||
for (let subguide of guides[guide]) {
|
||||
guideModules[`${guide}/${subguide}`] = getModule(language, `${guide}/${subguide}`);
|
||||
guideTitles[`${guide}/${subguide}`] = (await getModule(language, `${guide}/${subguide}`)).metadata.title;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
guideModules
|
||||
guideTitles
|
||||
};
|
||||
}
|
@@ -6,7 +6,7 @@
|
||||
import { guides } from '$lib/components/docs/docs';
|
||||
|
||||
export let data: {
|
||||
guideModules: Record<string, any>;
|
||||
guideTitles: Record<string, string>;
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
? 'font-semibold text-foreground'
|
||||
: ''}"
|
||||
>
|
||||
{#await data.guideModules[guide] then guideModule}
|
||||
{guideModule.metadata.title}
|
||||
{/await}
|
||||
{data.guideTitles[guide]}
|
||||
</Button>
|
||||
{#each guides[guide] as subGuide}
|
||||
<Button
|
||||
@@ -35,9 +33,7 @@
|
||||
? 'font-semibold text-foreground'
|
||||
: ''}"
|
||||
>
|
||||
{#await data.guideModules[`${guide}/${subGuide}`] then guideModule}
|
||||
{guideModule.metadata.title}
|
||||
{/await}
|
||||
{data.guideTitles[`${guide}/${subGuide}`]}
|
||||
</Button>
|
||||
{/each}
|
||||
{/each}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
import { guides, guideIcons } from '$lib/components/docs/docs';
|
||||
|
||||
export let data: {
|
||||
guideModules: Record<string, any>;
|
||||
guideTitles: Record<string, string>;
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
{guideIcons[guide]}
|
||||
</div>
|
||||
<div class="min-h-8 text-2xl text-center my-3 w-full whitespace-normal px-6">
|
||||
{#await data.guideModules[guide] then guideModule}
|
||||
{guideModule.metadata.title}
|
||||
{/await}
|
||||
{data.guideTitles[guide]}
|
||||
</div>
|
||||
<div class="flex flex-row justify-center flex-wrap gap-x-6 px-6">
|
||||
{#each guides[guide] as subGuide}
|
||||
@@ -33,9 +31,7 @@
|
||||
class="min-h-8 h-fit min-w-24 px-0 py-1 text-muted-foreground text-base text-center whitespace-normal"
|
||||
>
|
||||
<svelte:component this={guideIcons[subGuide]} size="16" class="mr-1 shrink-0" />
|
||||
{#await data.guideModules[`${guide}/${subGuide}`] then guideModule}
|
||||
{guideModule.metadata.title}
|
||||
{/await}
|
||||
{data.guideTitles[`${guide}/${subGuide}`]}
|
||||
</Button>
|
||||
{/each}
|
||||
</div>
|
||||
|
@@ -0,0 +1,29 @@
|
||||
import { getNextGuide, getPreviousGuide } from "$lib/components/docs/docs";
|
||||
|
||||
function getModule(language: string | undefined, guide: string) {
|
||||
language = language ?? 'en';
|
||||
let subguide = undefined;
|
||||
if (guide.includes('/')) {
|
||||
[guide, subguide] = guide.split('/');
|
||||
}
|
||||
return subguide
|
||||
? import(`./../../../../lib/docs/${language}/${guide}/${subguide}.mdx`)
|
||||
: import(`./../../../../lib/docs/${language}/${guide}.mdx`);
|
||||
}
|
||||
|
||||
export async function load({ params }) {
|
||||
const { guide, language } = params;
|
||||
|
||||
const previousGuide = getPreviousGuide(guide);
|
||||
const nextGuide = getNextGuide(guide);
|
||||
|
||||
const previousGuideTitle = previousGuide ? (await getModule(language, previousGuide)).metadata.title : undefined;
|
||||
const nextGuideTitle = nextGuide ? (await getModule(language, nextGuide)).metadata.title : undefined;
|
||||
|
||||
return {
|
||||
previousGuide,
|
||||
previousGuideTitle,
|
||||
nextGuide,
|
||||
nextGuideTitle
|
||||
};
|
||||
}
|
@@ -9,9 +9,9 @@
|
||||
export let data: {
|
||||
guideModule: any;
|
||||
previousGuide: string | undefined;
|
||||
previousGuideModule: any;
|
||||
previousGuideTitle: string | undefined;
|
||||
nextGuide: string | undefined;
|
||||
nextGuideModule: any;
|
||||
nextGuideTitle: string | undefined;
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -27,9 +27,7 @@
|
||||
href={getURLForLanguage($locale, `/help/${data.previousGuide}`)}
|
||||
>
|
||||
<ChevronLeft size="14" class="mr-1 mt-0.5" />
|
||||
{#await data.previousGuideModule then guideModule}
|
||||
{guideModule.metadata.title}
|
||||
{/await}
|
||||
{data.previousGuideTitle}
|
||||
</Button>
|
||||
{/if}
|
||||
{#if data.nextGuide}
|
||||
@@ -38,9 +36,7 @@
|
||||
class="ml-auto"
|
||||
href={getURLForLanguage($locale, `/help/${data.nextGuide}`)}
|
||||
>
|
||||
{#await data.nextGuideModule then guideModule}
|
||||
{guideModule.metadata.title}
|
||||
{/await}
|
||||
{data.nextGuideTitle}
|
||||
<ChevronRight size="14" class="ml-1 mt-0.5" />
|
||||
</Button>
|
||||
{/if}
|
||||
|
@@ -1,5 +1,3 @@
|
||||
import { getNextGuide, getPreviousGuide } from "$lib/components/docs/docs";
|
||||
|
||||
function getModule(language: string | undefined, guide: string) {
|
||||
language = language ?? 'en';
|
||||
let subguide = undefined;
|
||||
@@ -11,17 +9,13 @@ function getModule(language: string | undefined, guide: string) {
|
||||
: import(`./../../../../lib/docs/${language}/${guide}.mdx`);
|
||||
}
|
||||
|
||||
export async function load({ params }) {
|
||||
export async function load({ data, params }) {
|
||||
const { guide, language } = params;
|
||||
|
||||
const previousGuide = getPreviousGuide(guide);
|
||||
const nextGuide = getNextGuide(guide);
|
||||
const guideModule = await getModule(language, guide);
|
||||
|
||||
return {
|
||||
guideModule: await getModule(language, guide),
|
||||
previousGuide,
|
||||
previousGuideModule: previousGuide ? getModule(language, previousGuide) : undefined,
|
||||
nextGuide,
|
||||
nextGuideModule: nextGuide ? getModule(language, nextGuide) : undefined,
|
||||
guideModule,
|
||||
...data,
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user