diff --git a/astro.config.ts b/astro.config.ts index 882e651..68eb275 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -1,4 +1,5 @@ import { defineConfig } from 'astro/config'; + // https://astro.build/config export default defineConfig({}); diff --git a/public/favicon-16x16.png b/public/favicon-16x16.png new file mode 100644 index 0000000..b682f79 Binary files /dev/null and b/public/favicon-16x16.png differ diff --git a/public/favicon-32x32.png b/public/favicon-32x32.png new file mode 100644 index 0000000..bb3cda0 Binary files /dev/null and b/public/favicon-32x32.png differ diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..bc3da1b Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/favicon.svg b/public/favicon.svg deleted file mode 100644 index f157bd1..0000000 --- a/public/favicon.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/src/components/Toc.astro b/src/components/Toc.astro new file mode 100644 index 0000000..4597699 --- /dev/null +++ b/src/components/Toc.astro @@ -0,0 +1,52 @@ +--- +interface Props { + headings: Array<{ + depth: number; + slug: string; + text: string; + }> +} + +type Heading = Props['headings'][number]; +type Nested = Heading & { children?: Heading[] }; + +const { headings } = Astro.props; + +function fold(headings: Heading[]) { + const toc = [] as Nested[]; + const map = new Map(); + for (const h of headings) { + const heading = { ...h }; + map.set(heading.depth, heading); + if (heading.depth === 2) + toc.push(heading) + else { + const backref = map.get(heading.depth - 1)!; + backref.children + ? backref.children.push(heading) + : backref.children = [heading]; + } + } + return toc; +} +--- + +
+

Content

+ +
diff --git a/src/layouts/Article.astro b/src/layouts/Article.astro index 210e54f..271c3bb 100644 --- a/src/layouts/Article.astro +++ b/src/layouts/Article.astro @@ -2,21 +2,34 @@ import dayjs from "dayjs"; import Base from "./Base.astro"; import Header from "../components/headers/Article.astro"; +import Toc from "../components/Toc.astro"; -const {frontmatter} = Astro.props; +interface Props { + headings: any[], + frontmatter: { + title: string; + date: string; + tags: string[]; + } +} + +const { + headings, + frontmatter: { + title, + date, + tags, +}} = Astro.props; ---
-
+
diff --git a/src/layouts/Home.astro b/src/layouts/Home.astro index 67297b7..ad214a2 100644 --- a/src/layouts/Home.astro +++ b/src/layouts/Home.astro @@ -1,11 +1,10 @@ --- import Base from "./Base.astro"; - const notice = { - header: "Hello!", + header: "Website ported to Astro 2!", content: [ - "Test" + "Third time's a charm, so hopefully this time it will last longer. So far Astro looks really cool." ] }; ---