https://github.com/liolok/hexo-asset-link
A Hexo plugin to convert Markdown style asset links to HTML style ones
https://github.com/liolok/hexo-asset-link
hexo hexo-plugin relative-path
Last synced: 12 months ago
JSON representation
A Hexo plugin to convert Markdown style asset links to HTML style ones
- Host: GitHub
- URL: https://github.com/liolok/hexo-asset-link
- Owner: liolok
- License: mit
- Created: 2019-02-13T23:14:27.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-11-29T07:17:03.000Z (over 2 years ago)
- Last Synced: 2025-04-05T11:34:28.431Z (about 1 year ago)
- Topics: hexo, hexo-plugin, relative-path
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/hexo-asset-link
- Size: 46.9 KB
- Stars: 27
- Watchers: 1
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hexo-asset-link [](https://www.npmjs.com/package/hexo-asset-link)
Convert Markdown style asset links to HTML style ones.
## Install
In Hexo blog instance directory:
```shell
$ npm i -s hexo-asset-link
```
**or** if you prefer yarn:
```shell
$ yarn add hexo-asset-link
```
## Config
**Find** (not *add*) and enable [`Post Asset Folders`](https://hexo.io/docs/asset-folders#Post-Asset-Folder) feature in `_config.yml`:
```yml
# Writing
...
post_asset_folder: true
...
```
## Usage
For example, if you have these files in `source/_post/`:
```
+-- _posts/
| +-- 2019-02-14-Test-Post.md
| +-- 2019-02-14-Test-Post/
| +-- Test-Image.png
| +-- Test-Other-File.pdf
```
Then in `2019-02-14-Test-Post.md`:
### Images
```markdown


```
### Other Files
```markdown
[Text](./2019-02-14-Test-Post/Test-Other-File.pdf)
[Text](2019-02-14-Test-Post/Test-Other-File.pdf)
```
After this we'll get the right asset path result in:
- Blog home page of `hexo server` preview;
- Blog post page of `hexo server` preview;
- Blog home page of online website;
- Blog post page of online website;
- Markdown preview of editors like VS Code.
Now shall we just have fun writing!
## Reference
- [Filter | Hexo](https://hexo.io/api/filter "Filter | Hexo")
- [Posts | Hexo](https://hexo.io/api/posts "Posts | Hexo")
- [`new URL`](https://nodejs.org/docs/latest-v18.x/api/url.html#new-urlinput-base)
- [`url.pathname`](https://nodejs.org/docs/latest-v18.x/api/url.html#urlpathname)
- [RegExp - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp "RegExp - JavaScript | MDN")