feat: inline code highlight

This commit is contained in:
iCrawl
2022-10-11 04:06:14 +02:00
parent e17323c15c
commit 8b7ce2b61d
9 changed files with 432 additions and 43 deletions

View File

@@ -7,7 +7,7 @@ import { remarkCodeHike } from '@code-hike/mdx';
import { defineConfig } from 'astro/config';
import compress from 'astro-compress';
import critters from 'astro-critters';
import { toString } from 'hast-util-to-string';
import { type Node, toString } from 'hast-util-to-string';
import { h } from 'hastscript';
import { escape } from 'html-escaper';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
@@ -71,12 +71,12 @@ export default defineConfig({
'relative inline-flex w-6 h-6 place-items-center place-content-center outline-0 text-black dark:text-white ml-2',
},
behavior: 'after',
group: ({ tagName }) =>
group: ({ tagName }: { tagName: string }) =>
h('div', {
class: `[&>*]:inline-block [&>h1]:m-0 [&>h2]:m-0 [&>h3]:m-0 [&>h4]:m-0 level-${tagName}`,
tabIndex: -1,
}),
content: (heading) => [
content: (heading: Node) => [
h(
`span.anchor-icon`,
{