Skip to content

Commit

Permalink
use github-slugger for anchor
Browse files Browse the repository at this point in the history
* Use the version that doesn't add count to distinguish identical slugs,
  because I don't know where to initialize a slugger instance.
* Update next to 12, because github-slugger is a pure ESM, which is not
  supported by next < 11. See
  https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#im-having-problems-with-esm-and-nextjs
* Update react stuff, which is peer dependency of next.
* Remove next-routes, which doesn't seem to be used.
  • Loading branch information
tomtomjhj committed May 6, 2023
1 parent 74deeac commit abb17ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions app/pages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import footnote from 'markdown-it-footnote'
import markdownItAnchor from 'markdown-it-anchor'
import markdownItToc from 'markdown-it-toc-done-right'
import markdownDeflist from 'markdown-it-deflist'
import GithubSlugger, {slug} from 'github-slugger'

import mk from './katex'
import chart from './chart'
Expand Down Expand Up @@ -205,11 +206,13 @@ export default class PreviewPage extends React.Component {
permalink: true,
permalinkBefore: true,
permalinkSymbol: anchorSymbol,
permalinkClass: 'anchor'
permalinkClass: 'anchor',
slugify: slug,
})
.use(markdownItToc, {
...DEFAULT_OPTIONS.toc,
...toc
...toc,
slugify: x => slug(String(x).trim()),
})
}

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@chemzqm/neovim": "^5.7.9",
"@types/markdown-it": "^12.2.3",
"chart.js": "^2.7.3",
"github-slugger": "^2.0.0",
"highlight.js": "^10.4.1",
"log4js": "^6.4.0",
"markdown-it": "^13.0.1",
Expand All @@ -28,11 +29,10 @@
"markdown-it-toc-done-right": "^4.2.0",
"md-it-meta": "^0.0.2",
"msgpack-lite": "^0.1.26",
"next": "^7.0.2",
"next-routes": "^1.4.2",
"next": "^12.3.4",
"plantuml-encoder": "^1.4.0",
"react": "^16.5.2",
"react-dom": "^16.5.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"socket.io": "^2.1.1",
"socket.io-client": "^2.1.1"
},
Expand Down

0 comments on commit abb17ff

Please sign in to comment.