this repo has no description

✨ Heading anchors (bien crado)

gwen.works 72f429ce 41a91373

verified
Changed files
+12 -2
src
pages
works
_components
+11 -1
src/pages/works/_components/BlockParagraph.astro
··· 1 1 --- 2 + import slug from "slug"; 2 3 import type { InferEntrySchema } from "astro:content"; 3 4 4 5 type Block = 5 6 InferEntrySchema<"works">["content"][keyof InferEntrySchema<"works">["content"]]["blocks"][number]; 6 7 7 8 interface Props extends Block {} 9 + 10 + // FIXME do this in ortfodb 11 + const headingText = 12 + // Get inside of <hn> tag if content is just that 13 + Astro.props.content.match(/^<h[1-6]>(.*?)<\/h[1-6]>$/)?.[1]; 14 + const anchor = slug(headingText || "", { lower: true }); 8 15 --- 9 16 10 - <div class="block-paragraph-content" set:html={Astro.props.content} /> 17 + <div 18 + class="block-paragraph-content" 19 + set:html={Astro.props.content.replace(/^<h([1-6])>/, `<h$1 id="${anchor}">`)} 20 + /> 11 21 12 22 <style> 13 23 .block-paragraph-content {
+1 -1
tags.yaml
··· 1 1 # todo: deprecate 2 2 - singular: school 3 3 plural: school 4 - description: School projects and school-related projects 4 + description: School-related projects 5 5 6 6 - singular: science 7 7 plural: science