diff options
Diffstat (limited to 'src/routes/train-ico')
-rw-r--r-- | src/routes/train-ico/[type]/[[line]]/+page.svelte | 13 | ||||
-rw-r--r-- | src/routes/train-ico/[type]/[[line]]/+page.ts | 1 | ||||
-rw-r--r-- | src/routes/train-ico/[type]/[[line]]/.svg/+server.ts | 23 |
3 files changed, 37 insertions, 0 deletions
diff --git a/src/routes/train-ico/[type]/[[line]]/+page.svelte b/src/routes/train-ico/[type]/[[line]]/+page.svelte new file mode 100644 index 0000000..915f57b --- /dev/null +++ b/src/routes/train-ico/[type]/[[line]]/+page.svelte @@ -0,0 +1,13 @@ +<script lang="ts"> + import type { PageProps } from './$types'; + import LineGlyph from '$lib/assets/LineGlyph.svelte'; + + let { data }: PageProps = $props(); + let { params } = $derived(data); +</script> + +<LineGlyph + kind="{params.type}{params.line}" + type={params.type} + line={params.line} +/> diff --git a/src/routes/train-ico/[type]/[[line]]/+page.ts b/src/routes/train-ico/[type]/[[line]]/+page.ts new file mode 100644 index 0000000..3eeed27 --- /dev/null +++ b/src/routes/train-ico/[type]/[[line]]/+page.ts @@ -0,0 +1 @@ +export const load = ({ params }) => ({ params }); diff --git a/src/routes/train-ico/[type]/[[line]]/.svg/+server.ts b/src/routes/train-ico/[type]/[[line]]/.svg/+server.ts new file mode 100644 index 0000000..0120348 --- /dev/null +++ b/src/routes/train-ico/[type]/[[line]]/.svg/+server.ts @@ -0,0 +1,23 @@ +import LineGlyph from '$lib/assets/LineGlyph.svelte'; +import { render } from 'svelte/server'; +import { optimize } from 'svgo'; +export const GET = ({ params }) => { + return new Response( + optimize(`<?xml version="1.0" encoding="UTF-8" standalone="no"?> +${render(LineGlyph, { + props: { + kind: `${params.type}${params.line}`, + type: `${params.type}`, + line: params.line, + }, +}).body.replace( + '<svg', + '<svg xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"' +)}`).data, + { + headers: { + 'Content-Type': 'image/svg+xml', + }, + } + ); +}; |