web/routes: refactor error & /about/[page] to svelte 5

This commit is contained in:
wukko
2025-06-03 11:18:42 +06:00
parent 58209970ac
commit b304549a8d
2 changed files with 13 additions and 16 deletions

View File

@@ -1,14 +1,13 @@
import type { ComponentType, SvelteComponent } from 'svelte';
import { get } from 'svelte/store';
import { error } from '@sveltejs/kit';
import locale from "$lib/i18n/locale";
import { get } from "svelte/store";
import { error } from "@sveltejs/kit";
import { defaultLocale } from "$lib/i18n/translations";
import type { PageLoad } from './$types';
import type { Component } from "svelte";
import type { PageLoad } from "./$types";
import type { DefaultImport } from "$lib/types/generic";
import locale from '$lib/i18n/locale';
import type { DefaultImport } from '$lib/types/generic';
import { defaultLocale } from '$lib/i18n/translations';
const pages = import.meta.glob('$i18n/*/about/*.md');
const pages = import.meta.glob("$i18n/*/about/*.md");
export const load: PageLoad = async ({ params }) => {
const getPage = (locale: string) => Object.keys(pages).find(
@@ -17,13 +16,11 @@ export const load: PageLoad = async ({ params }) => {
const componentPath = getPage(get(locale)) || getPage(defaultLocale);
if (componentPath) {
type Component = ComponentType<SvelteComponent>;
const componentImport = pages[componentPath] as DefaultImport<Component>;
return { component: (await componentImport()).default }
}
error(404, 'Not found');
error(404, 'Not found');
};
export const prerender = true;