1- /* eslint-disable @typescript-eslint/no-unsafe-call */
2-
31import eleventyNavigationPlugin from '@11ty/eleventy-navigation'
42import eleventyRemark from '@fec/eleventy-plugin-remark'
5- import dedent from 'dedent'
63import { rehype } from 'rehype'
74import rehypeAutolinkHeadings from 'rehype-autolink-headings'
85import rehypeSlug from 'rehype-slug'
@@ -12,7 +9,7 @@ import { remarkDirectives } from './remark/directives.js'
129import { remarkHeadings } from './remark/headings.js'
1310import { remarkSample } from './remark/sample.js'
1411
15- /** @param {import('@11ty/eleventy').UserConfig } eleventyConfig */
12+ /** @param {import('@11ty/eleventy/UserConfig ').default } eleventyConfig */
1613export default async function config ( eleventyConfig ) {
1714 eleventyConfig . addPassthroughCopy ( {
1815 'src/assets/fonts' : './assets/fonts' ,
@@ -22,32 +19,6 @@ export default async function config(eleventyConfig) {
2219 } )
2320 eleventyConfig . addPassthroughCopy ( { 'src/public' : '.' } )
2421
25- eleventyConfig . addPairedShortcode (
26- 'navitem' ,
27- ( content , url , isSelected , isInactive ) => {
28- let tag = ''
29-
30- if ( isInactive ) {
31- tag = `<span class="px-3 py-2 relative block text-grey-400">${ content } </span>`
32- } else {
33- let linkClass = [
34- 'px-3 py-2 transition-colors duration-200 relative block' ,
35- isSelected && 'text-sky-700' ,
36- ! isSelected && 'hover:text-grey-900 text-grey-500' ,
37- ] . join ( ' ' )
38-
39- tag = dedent `<a class="${ linkClass } " href="${ url } ">
40- <span class="rounded-md absolute inset-0 bg-sky-50 ${
41- ! isSelected && 'opacity-0'
42- } "></span>
43- <span class="relative">${ content } </span>
44- </a>`
45- }
46-
47- return `<li>${ tag } </li>`
48- } ,
49- )
50-
5122 eleventyConfig . addPlugin ( eleventyNavigationPlugin )
5223 eleventyConfig . addPlugin ( eleventyRemark , {
5324 plugins : [
@@ -61,14 +32,24 @@ export default async function config(eleventyConfig) {
6132
6233 eleventyConfig . addTransform (
6334 'rehype' ,
64- /** @param {string } content */ async ( content , outputPath ) => {
35+ /**
36+ * @param {string } content
37+ * @param {string } outputPath
38+ */
39+ async ( content , outputPath ) => {
6540 let newContent = content
6641
6742 if ( outputPath ?. endsWith ( '.html' ) ) {
6843 let result = await rehype ( )
6944 . use ( rehypeSlug )
7045 . use ( rehypeAutolinkHeadings , {
71- test : ( element , index , parent ) => parent . tagName !== 'nav' ,
46+ test ( element , index , parent ) {
47+ return (
48+ parent ?. type === 'element' &&
49+ parent ?. tagName !== 'nav' &&
50+ element . tagName !== 'h1'
51+ )
52+ } ,
7253 properties : {
7354 class :
7455 'absolute ml-[-0.75em] md:ml-[-1em] pr-[0.5em] !no-underline !text-grey-400 opacity-0 group-hover:opacity-100' ,
0 commit comments