You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And, it doesn't look like the built-in Permalink functions (headerLink, linkInsideHeader, linkAfterHeader) return strings either?
So, what string am I supposed to return in my custom function renderPermalink (slug, opts, state, idx) {}?
More Details...
I'm using VuePress, and I want to configure my own custom permalink, using the permalink option for markdown-it-anchor.
The types for markdown-it-anchor show that a PermalinkGenerator should return a string
However, the docs for custom permalinks don't show a return type, so I'm getting an ESLint error because I don't return a string in my custom function...
(property) anchor.AnchorOptions.permalink?: anchor.PermalinkGenerator
Type '(slug: string, opts: PermalinkOptions, state: StateCore, idx: number) => void' is not assignable to type 'PermalinkGenerator'.
Type 'void' is not assignable to type 'string'.ts(2322)
If I return a random string, that satisfies ESLint and the permalink still renders <div>test</div>, so should I just return an empty string?
// .vuepress/config.ts
...
markdown: {anchor: {permalink: (slug,opts,state,idx)=>{state.tokens.splice(idx,0,Object.assign(newstate.Token('html_block','',0),{content: `<div>test</div>`}));return'what should go here?';}}},
...
The text was updated successfully, but these errors were encountered:
Hello!
TL;DR --
The types say that my custom
PermalinkGenerator
should return astring
:https://github.com/valeriangalliat/markdown-it-anchor/blob/master/types/index.d.ts#L39
But, the docs for custom permalinks don't show a return type:
https://github.com/valeriangalliat/markdown-it-anchor#custom-permalink
And, it doesn't look like the built-in Permalink functions (
headerLink
,linkInsideHeader
,linkAfterHeader
) return strings either?So, what
string
am I supposed to return in my customfunction renderPermalink (slug, opts, state, idx) {}
?More Details...
I'm using VuePress, and I want to configure my own custom permalink, using the
permalink
option formarkdown-it-anchor
.The types for
markdown-it-anchor
show that aPermalinkGenerator
should return a stringHowever, the docs for custom permalinks don't show a return type, so I'm getting an ESLint error because I don't
return
astring
in my custom function...If I return a random
string
, that satisfies ESLint and the permalink still renders<div>test</div>
, so should I just return an empty string?The text was updated successfully, but these errors were encountered: