Files
gpx.studio/website/src/lib/components/docs/DocsLoader.svelte

69 lines
1.1 KiB
Svelte
Raw Normal View History

2024-07-02 10:07:54 +02:00
<script lang="ts">
import { _, locale } from 'svelte-i18n';
export let path: string;
2024-07-08 22:43:50 +02:00
export let titleOnly: boolean = false;
2024-07-02 10:07:54 +02:00
let module = undefined;
2024-07-08 22:43:50 +02:00
let metadata: Record<string, any> = {};
2024-07-02 10:07:54 +02:00
const modules = import.meta.glob('/src/lib/docs/**/*.{md,svx}');
2024-07-08 22:43:50 +02:00
function loadModule(path: string) {
modules[path]().then((mod) => {
2024-07-02 10:07:54 +02:00
module = mod.default;
2024-07-08 22:43:50 +02:00
metadata = mod.metadata;
2024-07-02 10:07:54 +02:00
});
}
2024-07-08 22:43:50 +02:00
$: if ($locale) {
loadModule(`/src/lib/docs/${$locale}/${path}`);
}
2024-07-02 10:07:54 +02:00
</script>
{#if module !== undefined}
2024-07-08 22:43:50 +02:00
{#if titleOnly}
{metadata.title}
{:else}
<div class="markdown space-y-3">
<svelte:component this={module} />
</div>
{/if}
2024-07-02 10:07:54 +02:00
{/if}
2024-07-05 01:02:53 +02:00
<style lang="postcss">
:global(.markdown) {
}
:global(.markdown h1) {
@apply text-3xl;
2024-07-05 16:08:16 +02:00
@apply font-semibold;
@apply mb-6;
2024-07-05 01:02:53 +02:00
}
:global(.markdown h2) {
@apply text-2xl;
2024-07-05 16:08:16 +02:00
@apply font-semibold;
2024-07-05 01:02:53 +02:00
@apply mb-3;
}
:global(.markdown p > a) {
@apply text-blue-500;
@apply hover:underline;
}
2024-07-05 16:08:16 +02:00
:global(.markdown p > a) {
@apply text-blue-500;
@apply hover:underline;
}
2024-07-05 01:02:53 +02:00
:global(.markdown ul) {
@apply list-disc;
@apply pl-4;
}
:global(.markdown hr) {
@apply my-5;
}
</style>