From 2976170ee9a0e370a772a5c652aa05b98a54fa10 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Fri, 20 Aug 2021 12:32:01 +0200 Subject: [PATCH] feat: upgrade markdown-it-anchor (#350) BREAKING CHANGE: the `markdown.anchor` option is updated. Refer to valeriangalliat/markdown-it-anchor#permalinks for instructions to upgrade your existing `markdown.anchor.permalink` option. **This doesn't affect you if you weren't changing the header permalinks behavior**. --- docs/guide/markdown.md | 8 ++++++-- package.json | 2 +- src/client/app/components/Debug.vue | 7 +++++-- src/client/theme-default/components/CarbonAds.vue | 2 +- src/node/markdown/markdown.ts | 11 +++-------- yarn.lock | 8 ++++---- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/docs/guide/markdown.md b/docs/guide/markdown.md index 8d00d00148ac..8c5b54e31cac 100644 --- a/docs/guide/markdown.md +++ b/docs/guide/markdown.md @@ -60,7 +60,6 @@ Outbound links automatically get `target="_blank" rel="noopener noreferrer"`: title: Blogging Like a Hacker lang: en-US --- - ``` This data will be available to the rest of the page, along with all custom and theming components. @@ -404,10 +403,15 @@ You can also use a [VS Code region](https://code.visualstudio.com/docs/editor/co VitePress uses [markdown-it](https://github.com/markdown-it/markdown-it) as the Markdown renderer. A lot of the extensions above are implemented via custom plugins. You can further customize the `markdown-it` instance using the `markdown` option in `.vitepress/config.js`: ```js +const anchor = require('markdown-it-anchor') + module.exports = { markdown: { // options for markdown-it-anchor - anchor: { permalink: false }, + // https://github.com/valeriangalliat/markdown-it-anchor#permalinks + anchor: { + permalink: anchor.permalink.headerLink() + }, // options for markdown-it-toc toc: { includeLevel: [1, 2] }, diff --git a/package.json b/package.json index c4786d97b4e3..0ef2508c955b 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "gray-matter": "^4.0.3", "lru-cache": "^6.0.0", "markdown-it": "^12.0.6", - "markdown-it-anchor": "^7.1.0", + "markdown-it-anchor": "^8.1.2", "markdown-it-container": "^3.0.0", "markdown-it-emoji": "^2.0.0", "markdown-it-table-of-contents": "^0.5.2", diff --git a/src/client/app/components/Debug.vue b/src/client/app/components/Debug.vue index 617895dbf659..41e926a087f0 100644 --- a/src/client/app/components/Debug.vue +++ b/src/client/app/components/Debug.vue @@ -1,11 +1,14 @@