Skip to content

Commit

Permalink
feat: add autolink heading
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-ub committed Oct 6, 2024
1 parent bfa6691 commit af136e8
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@
"unocss": "^0.63.2"
},
"dependencies": {
"@astrojs/markdown-remark": "^5.2.0",
"@astrojs/mdx": "^3.1.7",
"@astrojs/sitemap": "^3.2.0",
"bcp-47": "^2.1.0",
"dayjs": "^1.11.13",
"fast-glob": "^3.3.2",
"i18next": "^23.15.2",
"nprogress": "^0.2.0"
"nprogress": "^0.2.0",
"rehype-autolink-headings": "^7.1.0"
},
"devDependencies": {
"@antfu/eslint-config": "^3.3.2",
Expand Down
25 changes: 25 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import type { AstroIntegration } from 'astro'
import type { PluginTranslations, VitesseUserConfigWithPlugins } from './utils/plugins'

import { rehypeHeadingIds } from '@astrojs/markdown-remark'
import mdx from '@astrojs/mdx'
import rehypeAutolinkHeadings from 'rehype-autolink-headings'
import { vitesseSitemap } from './integrations/sitemap'
import { vitePluginVitesseUserConfig } from './integrations/virtual-user-config'
import { processI18nConfig } from './utils/i18n'
Expand Down Expand Up @@ -93,6 +95,24 @@ export default function VitesseIntegration({
],
},
markdown: {
rehypePlugins: [
rehypeHeadingIds,
[
rehypeAutolinkHeadings,
{
behavior: 'append',
content: {
type: 'text',
value: '#',
},
properties: {
ariaHidden: true,
tabIndex: -1,
className: 'header-anchor',
},
},
],
],
shikiConfig: {
themes: {
dark: 'vitesse-dark',
Expand Down

0 comments on commit af136e8

Please sign in to comment.