-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
521 additions
and
581 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ updates: | |
groups: | ||
build: | ||
patterns: | ||
- mdsvex | ||
- sass | ||
- "svelte" | ||
- "svelte-*" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { base } from "$app/paths"; | ||
|
||
export type MarkdownNav = Array<MarkdownNavItem>; | ||
export type MarkdownNavItem = Record<string, string | MarkdownNav>; | ||
export type ParsedNav = Array<ParsedNavItem>; | ||
export type ParsedNavItem = { link: Link; children?: ParsedNav }; | ||
export type Link = { name: string; href: string }; | ||
|
||
export function parseNav(list?: MarkdownNav): ParsedNav | undefined { | ||
if (!list || !list.length) return; | ||
const result: ParsedNav = []; | ||
for (const item of list) { | ||
let link, children; | ||
for (let [key, value] of Object.entries(item)) { | ||
if (typeof value === "string") { | ||
const href = value.charAt(0) === "#" ? value : `${base}${value}`; | ||
link = { name: key, href }; | ||
} else if (Array.isArray(value)) { | ||
children = parseNav(value); | ||
} | ||
} | ||
if (link) { | ||
result.push({ link, children }); | ||
} else { | ||
console.error(`Invalid nav list: ${JSON.stringify(item)}`); | ||
} | ||
} | ||
if (result.length) return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script lang="ts"> | ||
import { base } from "$app/paths"; | ||
import type { HTMLAnchorAttributes } from "svelte/elements"; | ||
let { href, children, ...rest }: HTMLAnchorAttributes = $props(); | ||
let rebasedHref = $derived(href && href.startsWith("/") ? `${base}${href}` : href); | ||
</script> | ||
|
||
<a href={rebasedHref} {...rest}> | ||
{@render children?.()} | ||
</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<script module lang="ts"> | ||
export { default as Code } from "$lib/Code.svelte"; | ||
export { default as a } from "../components/A.svelte"; | ||
</script> | ||
|
||
<script lang="ts"> | ||
import type { Snippet } from "svelte"; | ||
import { parseNav, type MarkdownNav, type ParsedNav } from "$lib/markdown-nav"; | ||
import SideMenu from "$lib/SideMenu.svelte"; | ||
interface Props { | ||
title?: string; | ||
nav?: MarkdownNav; | ||
children?: Snippet; | ||
} | ||
let { title, nav, children }: Props = $props(); | ||
let parsedNav = $derived(parseNav(nav)); | ||
</script> | ||
|
||
<svelte:head> | ||
<title>{title || "Manon"}</title> | ||
</svelte:head> | ||
|
||
{#snippet navlist(items: ParsedNav)} | ||
<ul> | ||
{#each items as { link, children }} | ||
<li><a href={link.href}>{link.name}</a></li> | ||
{#if children}{@render navlist(children)}{/if} | ||
{/each} | ||
</ul> | ||
{/snippet} | ||
|
||
<main class:sidemenu={!!parsedNav} id="main-content" tabindex="-1"> | ||
{#if parsedNav} | ||
<SideMenu>{@render navlist(parsedNav)}</SideMenu> | ||
{/if} | ||
<section class="visually-grouped"> | ||
{@render children?.()} | ||
</section> | ||
</main> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
declare module '*.md' { | ||
import type { SvelteComponent } from 'svelte' | ||
|
||
export default class Comp extends SvelteComponent{} | ||
|
||
export const metadata: Record<string, unknown> | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.