Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 2 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 (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-11-29T07:17:03.000Z (about 1 year ago)
- Last Synced: 2024-06-19T01:55:33.239Z (7 months ago)
- Topics: hexo, hexo-plugin, relative-path
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/hexo-asset-link
- Size: 46.9 KB
- Stars: 22
- Watchers: 2
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hexo-asset-link [![NPM version](https://badge.fury.io/js/hexo-asset-link.svg)](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
![Alt Text](./2019-02-14-Test-Post/Test-Image.png "Title Text")
![Alt Text](2019-02-14-Test-Post/Test-Image.png "Title Text")
```### 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")