added too much stuff

This commit is contained in:
Youwen Wu 2024-04-06 22:39:21 -07:00
parent f59d667226
commit f6a6af79f5
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3
20 changed files with 324 additions and 15 deletions

View file

@ -1,5 +1,7 @@
# coredump # coredump
[![pnpm](https://img.shields.io/badge/maintained%20with-pnpm-cc00ff.svg?style=for-the-badge&logo=pnpm)](https://pnpm.io/)
My personal website and its associated blog. Written in [SvelteKit](https://kit.svelte.dev) using [TailwindCSS](https://tailwindcss.com/) and components from [shadcn-svelte](https://www.shadcn-svelte.com/). My personal website and its associated blog. Written in [SvelteKit](https://kit.svelte.dev) using [TailwindCSS](https://tailwindcss.com/) and components from [shadcn-svelte](https://www.shadcn-svelte.com/).
## Running locally ## Running locally

View file

@ -12,7 +12,7 @@
<ChevronRight class="h-4 w-4" /> <ChevronRight class="h-4 w-4" />
<div class="font-medium text-foreground">{doc.title}</div> <div class="font-medium text-foreground">{doc.title}</div>
</div> </div>
<div class="space-y-2"> <header class="space-y-2">
<h1 class="scroll-m-20 text-5xl font-bold font-serif tracking-tight"> <h1 class="scroll-m-20 text-5xl font-bold font-serif tracking-tight">
{doc.title} {doc.title}
</h1> </h1>
@ -28,10 +28,10 @@
length={doc.content.length} length={doc.content.length}
reverseDateAndRest reverseDateAndRest
/> />
</div> <slot name="toc" />
</header>
<div class="markdown-body mt-8 font-serif"> <div class="markdown-body mt-8 font-serif">
{@html doc.content} {@html doc.content}
<div role="note" id="end-marker" aria-label="End of article" class="invisible h-0 w-0">End</div>
</div> </div>
</article> </article>

View file

@ -10,6 +10,10 @@
- `time` - A unix epoch integer representing the time the post was published. - `time` - A unix epoch integer representing the time the post was published.
- `length` - An integer representing amount of words in the post. - `length` - An integer representing amount of words in the post.
- `reverseDateAndRest` - A boolean that determines whether the date should be displayed at the bottom of the metadata. - `reverseDateAndRest` - A boolean that determines whether the date should be displayed at the bottom of the metadata.
@slots
- toc - Place a table of contents here
--> -->
<script lang="ts"> <script lang="ts">

View file

@ -5,9 +5,9 @@
export let tocStore: TocStore; export let tocStore: TocStore;
const calcTextClasses = (el: HTMLElement) => { const calcTextClasses = (el: HTMLElement) => {
if (el.tagName === 'H1') return 'text-md xl:text-lg'; if (el.tagName === 'H1') return 'text-lg xl:text-xl font-medium';
if (el.tagName === 'H2') return 'text-md xl:text-lg'; if (el.tagName === 'H2') return 'text-md xl:text-lg';
if (el.id === 'end-marker') return 'text-md xl:text-lg'; if (el.id === 'end-marker') return 'text-lg xl:text-xl';
return 'text-sm text-muted-foreground'; return 'text-sm text-muted-foreground';
}; };
</script> </script>
@ -24,6 +24,7 @@
<!-- svelte-ignore a11y-missing-attribute a11y-missing-content --> <!-- svelte-ignore a11y-missing-attribute a11y-missing-content -->
<a <a
use:toclink={{ store: tocStore, tocItem, observe: true }} use:toclink={{ store: tocStore, tocItem, observe: true }}
class:highlighted={$tocStore.activeItem === tocItem}
class={`hover:bg-muted px-2 py-1 rounded-r-sm transition-all border-l-secondary border-l-4 ${calcTextClasses(tocItem.element)}`} class={`hover:bg-muted px-2 py-1 rounded-r-sm transition-all border-l-secondary border-l-4 ${calcTextClasses(tocItem.element)}`}
/> />
</li> </li>
@ -32,3 +33,9 @@
{/if} {/if}
</Card.Content> </Card.Content>
</Card.Root> </Card.Root>
<style lang="postcss">
.highlighted {
@apply bg-blue-200 dark:bg-blue-900 border-l-blue-500;
}
</style>

View file

@ -0,0 +1,26 @@
<script lang="ts">
import { Accordion as AccordionPrimitive } from "bits-ui";
import { slide } from "svelte/transition";
import { cn } from "$lib/utils.js";
type $$Props = AccordionPrimitive.ContentProps;
let className: $$Props["class"] = undefined;
export let transition: $$Props["transition"] = slide;
export let transitionConfig: $$Props["transitionConfig"] = {
duration: 200,
};
export { className as class };
</script>
<AccordionPrimitive.Content
class={cn("overflow-hidden text-sm", className)}
{transition}
{transitionConfig}
{...$$restProps}
>
<div class="pb-4 pt-0">
<slot />
</div>
</AccordionPrimitive.Content>

View file

@ -0,0 +1,14 @@
<script lang="ts">
import { Accordion as AccordionPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = AccordionPrimitive.ItemProps;
let className: $$Props["class"] = undefined;
export { className as class };
export let value: $$Props["value"];
</script>
<AccordionPrimitive.Item {value} class={cn("border-b", className)} {...$$restProps}>
<slot />
</AccordionPrimitive.Item>

View file

@ -0,0 +1,28 @@
<script lang="ts">
import { Accordion as AccordionPrimitive } from "bits-ui";
import ChevronDown from "svelte-radix/ChevronDown.svelte";
import { cn } from "$lib/utils.js";
type $$Props = AccordionPrimitive.TriggerProps;
type $$Events = AccordionPrimitive.TriggerEvents;
let className: $$Props["class"] = undefined;
export let level: AccordionPrimitive.HeaderProps["level"] = 3;
export { className as class };
</script>
<AccordionPrimitive.Header {level} class="flex">
<AccordionPrimitive.Trigger
class={cn(
"flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
className
)}
{...$$restProps}
on:click
>
<slot />
<ChevronDown
class="h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"
/>
</AccordionPrimitive.Trigger>
</AccordionPrimitive.Header>

View file

@ -0,0 +1,17 @@
import { Accordion as AccordionPrimitive } from "bits-ui";
import Content from "./accordion-content.svelte";
import Item from "./accordion-item.svelte";
import Trigger from "./accordion-trigger.svelte";
const Root = AccordionPrimitive.Root;
export {
Root,
Content,
Item,
Trigger,
//
Root as Accordion,
Content as AccordionContent,
Item as AccordionItem,
Trigger as AccordionTrigger,
};

View file

@ -0,0 +1,24 @@
<script lang="ts">
import { Drawer as DrawerPrimitive } from "vaul-svelte";
import DrawerOverlay from "./drawer-overlay.svelte";
import { cn } from "$lib/utils.js";
type $$Props = DrawerPrimitive.ContentProps;
let className: $$Props["class"] = undefined;
export { className as class };
</script>
<DrawerPrimitive.Portal>
<DrawerOverlay />
<DrawerPrimitive.Content
class={cn(
"fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",
className
)}
{...$$restProps}
>
<div class="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
<slot />
</DrawerPrimitive.Content>
</DrawerPrimitive.Portal>

View file

@ -0,0 +1,18 @@
<script lang="ts">
import { Drawer as DrawerPrimitive } from "vaul-svelte";
import { cn } from "$lib/utils.js";
type $$Props = DrawerPrimitive.DescriptionProps;
export let el: $$Props["el"] = undefined;
let className: $$Props["class"] = undefined;
export { className as class };
</script>
<DrawerPrimitive.Description
bind:el
class={cn("text-sm text-muted-foreground", className)}
{...$$restProps}
>
<slot />
</DrawerPrimitive.Description>

View file

@ -0,0 +1,16 @@
<script lang="ts">
import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js";
type $$Props = HTMLAttributes<HTMLDivElement> & {
el?: HTMLDivElement;
};
export let el: $$Props["el"] = undefined;
let className: $$Props["class"] = undefined;
export { className as class };
</script>
<div bind:this={el} class={cn("mt-auto flex flex-col gap-2 p-4", className)} {...$$restProps}>
<slot />
</div>

View file

@ -0,0 +1,19 @@
<script lang="ts">
import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js";
type $$Props = HTMLAttributes<HTMLDivElement> & {
el?: HTMLDivElement;
};
export let el: $$Props["el"] = undefined;
let className: $$Props["class"] = undefined;
export { className as class };
</script>
<div
bind:this={el}
class={cn("grid gap-1.5 p-4 text-center sm:text-left", className)}
{...$$restProps}
>
<slot />
</div>

View file

@ -0,0 +1,12 @@
<script lang="ts">
import { Drawer as DrawerPrimitive } from "vaul-svelte";
type $$Props = DrawerPrimitive.Props;
export let shouldScaleBackground: $$Props["shouldScaleBackground"] = true;
export let open: $$Props["open"] = false;
export let activeSnapPoint: $$Props["activeSnapPoint"] = undefined;
</script>
<DrawerPrimitive.NestedRoot {shouldScaleBackground} bind:open bind:activeSnapPoint {...$$restProps}>
<slot />
</DrawerPrimitive.NestedRoot>

View file

@ -0,0 +1,18 @@
<script lang="ts">
import { Drawer as DrawerPrimitive } from "vaul-svelte";
import { cn } from "$lib/utils.js";
type $$Props = DrawerPrimitive.OverlayProps;
export let el: $$Props["el"] = undefined;
let className: $$Props["class"] = undefined;
export { className as class };
</script>
<DrawerPrimitive.Overlay
bind:el
class={cn("fixed inset-0 z-50 bg-black/80", className)}
{...$$restProps}
>
<slot />
</DrawerPrimitive.Overlay>

View file

@ -0,0 +1,18 @@
<script lang="ts">
import { Drawer as DrawerPrimitive } from "vaul-svelte";
import { cn } from "$lib/utils.js";
type $$Props = DrawerPrimitive.TitleProps;
export let el: $$Props["el"] = undefined;
let className: $$Props["class"] = undefined;
export { className as class };
</script>
<DrawerPrimitive.Title
bind:el
class={cn("text-lg font-semibold leading-none tracking-tight", className)}
{...$$restProps}
>
<slot />
</DrawerPrimitive.Title>

View file

@ -0,0 +1,12 @@
<script lang="ts">
import { Drawer as DrawerPrimitive } from "vaul-svelte";
type $$Props = DrawerPrimitive.Props;
export let shouldScaleBackground: $$Props["shouldScaleBackground"] = true;
export let open: $$Props["open"] = false;
export let activeSnapPoint: $$Props["activeSnapPoint"] = undefined;
</script>
<DrawerPrimitive.Root {shouldScaleBackground} bind:open bind:activeSnapPoint {...$$restProps}>
<slot />
</DrawerPrimitive.Root>

View file

@ -0,0 +1,40 @@
import { Drawer as DrawerPrimitive } from "vaul-svelte";
import Root from "./drawer.svelte";
import Content from "./drawer-content.svelte";
import Description from "./drawer-description.svelte";
import Overlay from "./drawer-overlay.svelte";
import Footer from "./drawer-footer.svelte";
import Header from "./drawer-header.svelte";
import Title from "./drawer-title.svelte";
import NestedRoot from "./drawer-nested.svelte";
const Trigger = DrawerPrimitive.Trigger;
const Portal = DrawerPrimitive.Portal;
const Close = DrawerPrimitive.Close;
export {
Root,
NestedRoot,
Content,
Description,
Overlay,
Footer,
Header,
Title,
Trigger,
Portal,
Close,
//
Root as Drawer,
NestedRoot as DrawerNestedRoot,
Content as DrawerContent,
Description as DrawerDescription,
Overlay as DrawerOverlay,
Footer as DrawerFooter,
Header as DrawerHeader,
Title as DrawerTitle,
Trigger as DrawerTrigger,
Portal as DrawerPortal,
Close as DrawerClose,
};

View file

@ -48,7 +48,10 @@
> >
my blog on computer science, math, games, art, and more. my blog on computer science, math, games, art, and more.
</p> </p>
<span class="flex flex-wrap items-center mt-8 md:hidden"> <span
class="flex flex-wrap items-center mt-8 md:hidden"
in:fly={{ duration: 300, x: -50, delay: 300 }}
>
<a href="#archive" class="flex items-center font-mono gap-2 hover:underline" <a href="#archive" class="flex items-center font-mono gap-2 hover:underline"
><ChevronRight />Archived Posts</a ><ChevronRight />Archived Posts</a
> >

View file

@ -3,12 +3,12 @@
import Code from 'svelte-radix/Code.svelte'; import Code from 'svelte-radix/Code.svelte';
import type { PageData } from './$types'; import type { PageData } from './$types';
// import { config } from '$lib/stores/index.js'; // import { config } from '$lib/stores/index.js';
import { cn } from '$lib/utils.js';
import Article from '$lib/components/Blog/Article.svelte'; import Article from '$lib/components/Blog/Article.svelte';
import { toc, createTocStore } from '@svelte-put/toc'; import { toc, createTocStore, toclink } from '@svelte-put/toc';
import StickyToc from '$lib/components/Toc/StickyToc.svelte'; import StickyToc from '$lib/components/Toc/StickyToc.svelte';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import MobileTocFooter from '$lib/components/MobileTocFooter.svelte'; import * as Accordion from '$lib/components/ui/accordion';
import * as Card from '$lib/components/ui/card';
const tocStore = createTocStore(); const tocStore = createTocStore();
@ -24,6 +24,13 @@
description: description:
'An insightful and longer description of the post. This should be a bit more detailed than the blurb. It should give the reader a good idea of what the post is about.' 'An insightful and longer description of the post. This should be a bit more detailed than the blurb. It should give the reader a good idea of what the post is about.'
}; };
const calcTextClasses = (el: HTMLElement) => {
if (el.tagName === 'H1') return 'text-xl font-medium';
if (el.tagName === 'H2') return 'text-lg';
return 'text-sm text-muted-foreground';
};
// $: doc = data.metadata; // $: doc = data.metadata;
// $: componentSource = data.metadata.source?.replace('default', $config.style ?? 'default'); // $: componentSource = data.metadata.source?.replace('default', $config.style ?? 'default');
</script> </script>
@ -47,7 +54,34 @@
scrollMarginTop: 120 scrollMarginTop: 120
}} }}
> >
<Article {doc} /> <Article {doc}>
<Card.Root slot="toc" class="lg:hidden">
<Card.Content>
<Accordion.Root>
<Accordion.Item value="toc">
<Accordion.Trigger>
<p>On this page</p>
</Accordion.Trigger>
<Accordion.Content>
{#if $tocStore.items.size}
<ol class="border-l-2 border-l-blue-500 px-4">
{#each $tocStore.items.values() as tocItem}
<li class="py-0.5">
<!-- svelte-ignore a11y-missing-attribute a11y-missing-content -->
<a
use:toclink={{ store: tocStore, tocItem, observe: true }}
class={`${calcTextClasses(tocItem.element)}`}
/>
</li>
{/each}
</ol>
{/if}
</Accordion.Content>
</Accordion.Item>
</Accordion.Root>
</Card.Content>
</Card.Root>
</Article>
</main> </main>
<aside class="basis-1/4 relative hidden lg:block"> <aside class="basis-1/4 relative hidden lg:block">
@ -55,8 +89,4 @@
<StickyToc {tocStore} /> <StickyToc {tocStore} />
</div> </div>
</aside> </aside>
<aside class="lg:hidden">
<MobileTocFooter {tocStore} />
</aside>
</div> </div>

View file

@ -8,6 +8,7 @@ export const prerender = true;
const options = { const options = {
throwOnError: false throwOnError: false
}; };
marked.use(markedKatex(options)); marked.use(markedKatex(options));
marked.use(markedAlert()); marked.use(markedAlert());