From 675ef1003d278210eb6d8c05682b4b248972e7a9 Mon Sep 17 00:00:00 2001 From: Joseph Montanaro Date: Sat, 4 Apr 2026 14:58:59 -0400 Subject: [PATCH] add custom headings with deep link --- src/components/Icon.astro | 6 ++- src/components/Post.astro | 71 ++++++++++++++------------- src/components/headings/H1.astro | 7 +++ src/components/headings/H2.astro | 7 +++ src/components/headings/H3.astro | 7 +++ src/components/headings/H4.astro | 7 +++ src/components/headings/H5.astro | 7 +++ src/components/headings/H6.astro | 7 +++ src/components/headings/Heading.astro | 45 +++++++++++++++++ src/components/headings/index.ts | 15 ++++++ src/components/icons/link.svg | 3 ++ 11 files changed, 145 insertions(+), 37 deletions(-) create mode 100644 src/components/headings/H1.astro create mode 100644 src/components/headings/H2.astro create mode 100644 src/components/headings/H3.astro create mode 100644 src/components/headings/H4.astro create mode 100644 src/components/headings/H5.astro create mode 100644 src/components/headings/H6.astro create mode 100644 src/components/headings/Heading.astro create mode 100644 src/components/headings/index.ts create mode 100644 src/components/icons/link.svg diff --git a/src/components/Icon.astro b/src/components/Icon.astro index b46c9ed..fd4cbb7 100644 --- a/src/components/Icon.astro +++ b/src/components/Icon.astro @@ -3,9 +3,10 @@ export interface Props { name: string, width?: string, height?: string, + display?: string, }; -const { name, width, height } = Astro.props; +const { name, width, height, display } = Astro.props; const icons = import.meta.glob<{string: string}>('@components/icons/*.svg', { query: '?raw', import: 'default' }); const path = `/src/components/icons/${name}.svg`; @@ -17,8 +18,9 @@ const icon = await icons[path](); - - -
-
-

- - { entry.data.title } -

-

{ formatDate(entry.data.date) }

-
- -
- -
- -
- -
- -
- -
- {prevSlug && ( - - )} - {nextSlug && ( - - )} -
-
diff --git a/src/components/headings/H1.astro b/src/components/headings/H1.astro new file mode 100644 index 0000000..179a2b8 --- /dev/null +++ b/src/components/headings/H1.astro @@ -0,0 +1,7 @@ +--- +import Heading from './Heading.astro'; +--- + + + + diff --git a/src/components/headings/H2.astro b/src/components/headings/H2.astro new file mode 100644 index 0000000..f72656f --- /dev/null +++ b/src/components/headings/H2.astro @@ -0,0 +1,7 @@ +--- +import Heading from './Heading.astro'; +--- + + + + diff --git a/src/components/headings/H3.astro b/src/components/headings/H3.astro new file mode 100644 index 0000000..91224e5 --- /dev/null +++ b/src/components/headings/H3.astro @@ -0,0 +1,7 @@ +--- +import Heading from './Heading.astro'; +--- + + + + diff --git a/src/components/headings/H4.astro b/src/components/headings/H4.astro new file mode 100644 index 0000000..1538f30 --- /dev/null +++ b/src/components/headings/H4.astro @@ -0,0 +1,7 @@ +--- +import Heading from './Heading.astro'; +--- + + + + diff --git a/src/components/headings/H5.astro b/src/components/headings/H5.astro new file mode 100644 index 0000000..9e30fb3 --- /dev/null +++ b/src/components/headings/H5.astro @@ -0,0 +1,7 @@ +--- +import Heading from './Heading.astro'; +--- + + + + diff --git a/src/components/headings/H6.astro b/src/components/headings/H6.astro new file mode 100644 index 0000000..1c63602 --- /dev/null +++ b/src/components/headings/H6.astro @@ -0,0 +1,7 @@ +--- +import Heading from './Heading.astro'; +--- + + + + diff --git a/src/components/headings/Heading.astro b/src/components/headings/Heading.astro new file mode 100644 index 0000000..306f13f --- /dev/null +++ b/src/components/headings/Heading.astro @@ -0,0 +1,45 @@ +--- +import Icon from '@components/Icon.astro'; + +export interface Props extends astroHTML.JSX.HTMLAttributes { + tag: string, +} + +const { tag: Tag, ...rest } = Astro.props; +--- + + + + + + + + + + diff --git a/src/components/headings/index.ts b/src/components/headings/index.ts new file mode 100644 index 0000000..5fba862 --- /dev/null +++ b/src/components/headings/index.ts @@ -0,0 +1,15 @@ +import H1 from './H1.astro'; +import H2 from './H2.astro'; +import H3 from './H3.astro'; +import H4 from './H4.astro'; +import H5 from './H5.astro'; +import H6 from './H6.astro'; + +export const headingElements = { + h1: H1, + h2: H2, + h3: H3, + h4: H4, + h5: H5, + h6: H6, +}; diff --git a/src/components/icons/link.svg b/src/components/icons/link.svg new file mode 100644 index 0000000..3fefc6a --- /dev/null +++ b/src/components/icons/link.svg @@ -0,0 +1,3 @@ + + +