hexo icon indicating copy to clipboard operation
hexo copied to clipboard

Better asset management

Open qzi opened this issue 5 years ago • 5 comments

Check List

Please check followings before submitting a new feature request.

  • [x] I have already read Docs page
  • [x] I have already searched existing issues

Feature Request

If I enabled the post_asset_folder in _config.yml of HEXO, it will always create a new asset folder after hexo new
but sometimes I just want to create a new post without asset, but the default behaviour will still create a asset blank folder to make my sources dirty and not useful
So I wish to add one more feature to control whether I need the asset folder.

More over I hope that Hexo can impove its default rendering of image reference to support a original markdown syntax

  1. Add a asset off parameter for the command hexo new to control AssetOff after enabling asset folder
  2. Improve the asset url management for the natural markdown phrasing

Image reference
Improve the url reference for three scenarios in just one go:

  1. Markdown preview in local
  2. Hexo s in local after rendering
  3. static web page in /public host in the github page
![Rest Client](my-favorite-extensions-for-visual-studio-code/rest-client.jpg)
![Rest Client](./my-favorite-extensions-for-visual-studio-code/rest-client.jpg)

Here is the sample generated by using the asset link
https://leonvision.online/technology/2019/12/16/my-favorite-extensions-for-visual-studio-code/
Asset Link for integration
https://liolok.github.io/zh-CN/How-to-Add-Image-to-Hexo-Blog-Post/

Others

qzi avatar Dec 16 '19 08:12 qzi

Please describe Improve the url reference for three scenarios in just one go?

For example, what did you written and where did you placed your image files before, then what happened, and what do you want to write in your markdown file and achieve what then.

SukkaW avatar Dec 23 '19 13:12 SukkaW

Let me guess.

_source/post/
2019-02-14-Test-Post.md
2019-02-14-Test-Post/
+-- Test-Image-1.png
+-- Test-Image-2.png
+-- Subdirectory/
|   +-- Test-Image-3.png
|   +-- Test-Image-4.png

And the post will be rendered in https://blog.example.com/2019-02-14-Test-Post/

./Test-Image-1.png and ./Test-Image-2.png works at post page because they are under same directory with index.html, but will not work at homepage.

But the problem is your NexT theme (and probably all of the theme) use post.content. Since every post will be only rendered for once, it is impossible to have different output for post.content at index and page.content for the post.

https://github.com/theme-next/hexo-theme-next/blob/master/layout/_macro/post.swig#L205 https://github.com/theme-next/hexo-theme-next/blob/master/layout/_macro/post.swig#L208

SukkaW avatar Dec 23 '19 13:12 SukkaW

I have noticed hexo-renderer-marked has an option prependRoot. root will be prepended after this option is enabled. I am wondered if we could prepend post path as well.

https://github.com/hexojs/hexo-renderer-marked#Options

SukkaW avatar Dec 23 '19 13:12 SukkaW

Please describe Improve the url reference for three scenarios in just one go?

For example, what did you written and where did you placed your image files before, then what happened, and what do you want to write in your markdown file and achieve what then.

Thanks for your reply, SukkaW.

Normally, we will refer the image in markdown syntax like below:

![Rest Client](my-favorite-extensions-for-visual-studio-code/rest-client.jpg)
![Rest Client](./my-favorite-extensions-for-visual-studio-code/rest-client.jpg)

but we can get the correct rendering result in local preview, but it can not render correctly after in local Hexo server and the same as it after we push it to the host online. I think every markdown syntax should be rendered correctly in three scenarios:

  1. local markdown preview without hexo server
  2. local markdown preview with hexo server
  3. online markdown rendering in host

that could make the writing naturally align the markdown syntax and rendering correctly

qzi avatar Dec 25 '19 17:12 qzi

See also https://github.com/hexojs/hexo/issues/3245

stevenjoezhang avatar Apr 17 '20 08:04 stevenjoezhang

It can be solved using this third-party plugin: https://www.npmjs.com/package/hexo-img-locator

stevenjoezhang avatar Jul 09 '23 17:07 stevenjoezhang