From 27733e21193ebcbb8c61200ede59d6294cf34524 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 28 Mar 2020 11:32:19 +0900 Subject: [PATCH] Fix doc page --- package.json | 1 + src/client/pages/doc.vue | 5 +++++ yarn.lock | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/package.json b/package.json index fb61e000f0..c6bd9ecdd9 100644 --- a/package.json +++ b/package.json @@ -169,6 +169,7 @@ "lolex": "5.1.2", "lookup-dns-cache": "2.1.0", "markdown-it": "10.0.0", + "markdown-it-anchor": "5.2.5", "mocha": "7.0.1", "moji": "0.5.1", "ms": "2.1.2", diff --git a/src/client/pages/doc.vue b/src/client/pages/doc.vue index 8d1ba4bd73..c9eec4a6d8 100644 --- a/src/client/pages/doc.vue +++ b/src/client/pages/doc.vue @@ -18,6 +18,7 @@ import Vue from 'vue'; import { faFileAlt } from '@fortawesome/free-solid-svg-icons' import MarkdownIt from 'markdown-it'; +import MarkdownItAnchor from 'markdown-it-anchor'; import i18n from '../i18n'; import { url, lang } from '../config'; import MkLink from '../components/link.vue'; @@ -26,6 +27,10 @@ const markdown = MarkdownIt({ html: true }); +markdown.use(MarkdownItAnchor, { + slugify: (s) => encodeURIComponent(String(s).trim().replace(/\s+/g, '-')) +}); + export default Vue.extend({ i18n, diff --git a/yarn.lock b/yarn.lock index 0f49186132..840a2ed163 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6111,6 +6111,11 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" +markdown-it-anchor@5.2.5: + version "5.2.5" + resolved "https://registry.yarnpkg.com/markdown-it-anchor/-/markdown-it-anchor-5.2.5.tgz#dbf13cfcdbffd16a510984f1263e1d479a47d27a" + integrity sha512-xLIjLQmtym3QpoY9llBgApknl7pxAcN3WDRc2d3rwpl+/YvDZHPmKscGs+L6E05xf2KrCXPBvosWt7MZukwSpQ== + markdown-it@10.0.0: version "10.0.0" resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-10.0.0.tgz#abfc64f141b1722d663402044e43927f1f50a8dc"