Transfer wiki links (based on the title) in Markdown files to permalink.
npm install hexo-filter-titlebased-link[[Title]] [[Title#Anchor]] or [[Title|Alias]]) in Hexo.
markdown
npm install hexo-filter-titlebased-link --save
`
Quick Start
To configure this plugin, add these contents in the _config.yml:
`yaml
hexo-filter-titlebased-link
https://github.com/uuanqin/hexo-filter-titlebased-link
titlebased_link:
enable: true # enable this plugin
`
Hexo sets every post a Permalinks, which can be configured in the _config.yml.
Here is an example:
`yaml
in _config.yml
permalink: p/:year/:month/:day/:hour/:minute/:second/
`
Assume you have a post named my_post_1 whose permalink is p/2024/04/12/14/18/50/.
In another post named my_post_2, you wrote a wiki link to my_post_1:
`markdown
This is my_post_2,
you can click this link: [[my_post_1]],
or [[my_post_1|Any title]].
`
After rendering by Hexo, the resultant HTML file of my_post_2.md will be:
`html
This is my_post_2,
you can click this link: my_post_1,
or Any title.
`
Customize Your Links
Similar to the hexo-filter-custom-link,
this plugin reserves several slots for custom HTML.
`js
`
For example, if your option is:
`yaml
titlebased_link:
enable: true # enable this plugin
custom_html:
link_attributes: 'class="my-link" title="example"'
before_tag: ' Before the link '
after_tag: ' After the link
'
before_text: ''
after_text: ''
`
Then the resultant HTML will be (the code below was formatted for ease of review):
`html
Before the link
this link
After the link
``