--- import Markdown from '../layouts/Markdown.astro'; import rehypeAutolinkHeadings from 'rehype-autolink-headings'; import rehypeSlug from 'rehype-slug'; import markdown from 'markdown-wasm'; // import { markdown } from '@astropub/md' let content = await (await fetch('https://raw.githubusercontent.com/lbryio/spec/master/index.md')).text(); // const md = await markdown(content.replace(`--- // layout: spec // ---`, ''), { // rehypePlugins: [ // [rehypeSlug as any], // [rehypeAutolinkHeadings as any, { behavior: 'wrap' }] // ] // }); content = content.replace(`--- layout: spec ---`, '') // Extract the headings from the markdown const headings = content.match(/(?#{1,6})\s+(?.+)/g).map(heading=>{ const text = heading.replaceAll('#', '').replace(' ', ''); return { depth: heading.replace(/[^#]/g, "").length, // Get number of '#' a heading has slug: text.replaceAll(' ', '-').toLowerCase(), // URL friendly path text } }); --- {}