Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asset files were rendered when post_asset_folder set to true #1490

Closed
cissoid opened this issue Sep 8, 2015 · 10 comments · Fixed by #4781
Closed

asset files were rendered when post_asset_folder set to true #1490

cissoid opened this issue Sep 8, 2015 · 10 comments · Fixed by #4781
Labels
bug Something isn't working duplicate This issue or pull request already exists post-asset

Comments

@cissoid
Copy link

cissoid commented Sep 8, 2015

This is the source structure:

$ tree source/_posts/

source/_posts/
|-- hello-world.md
|-- test-post
|   |-- test_css.css
|   `-- test_js.js
`-- test-post.md

but when I executed hexo generate, the post in public folder looks like this:

$ tree public/2015/09/08/test-post/

public/2015/09/08/test-post/
|-- index.html
|-- test_css
|   `-- index.html
|-- test_css.css
|-- test_js
|   `-- index.html
`-- test_js.js

It seems the css files and javascript files also were rendered.

@cissoid cissoid changed the title asset files be rendered when post_asset_folder set to true asset files were rendered when post_asset_folder set to true Sep 9, 2015
@sueyic
Copy link

sueyic commented Oct 4, 2015

Confirmed this is happening. I'm using hexo version 3.1.1 .
This creation of additional index.html files and rendering them as if they were posts is occurring with css and js files in the asset folder, but not with jpg files.

@denjones
Copy link

I am suffering from this too with v3.1.1 also with v3.2.0-beta.2.

@leesei leesei added the duplicate This issue or pull request already exists label Feb 24, 2016
@leesei
Copy link
Member

leesei commented Mar 1, 2016

試試這配置:

skip_render:
- _posts/test-post/*

skip_render 的path 是相對source/

#1591, #1146 (comment)

@denjones
Copy link

denjones commented Mar 1, 2016

我就是这么输的

skip_render:
- _posts/test-post/*

貌似只要是_posts中的 js、css文件就不能skip掉

我看了下代码

process: function postProcessor(file) {

这里即使第一个判断 renderable 为 false, 只要设了 post_asset_folder 就会处理这个文件

@leesei leesei added bug Something isn't working need-verify labels Mar 1, 2016
@xovel
Copy link

xovel commented Jul 6, 2016

try this:

skip_render:
- _posts/test-post/*
- _posts/test-post/*.js
- _posts/test-post/*.css

@MACDfree
Copy link

MACDfree commented Sep 17, 2016

配置成这样是可以的

skip_render:
  - _posts/**/*.js
  - _posts/**/*.css

@huyingjie
Copy link

I have the same issue. It becomes the most annoying issue for me now. I have html files in the asset folder. Hexo renders them. I try js files. Hexo renders them. skipping render doesn't work.

The tag for the issue is weird. "duplicate" and "need-verify" are not suitable for this situation.

@bkmeneguello
Copy link

bkmeneguello commented Jun 4, 2018

Any progress? I think post_asset_folder flag should make renderer ignore the "asset_folder" completely, allowing only "asset" reference. Isn't this a core functionality?
This issue is still present in 3.7.1

@plusls
Copy link

plusls commented Mar 24, 2020

Any progress?

@kristofzerbe
Copy link
Contributor

kristofzerbe commented Sep 21, 2021

There is a solution, or at least an alleviation of the problem. See #4781.

In order to fix the problem on your own in the meanwhile, just edit ./node_modules/hexo/lib/plugins/processor/post.js and insert following code right after result.renderable = ...:

  ...
  result.renderable = ctx.render.isRenderable(path) && !isMatch(path, ctx.config.skip_render);

  //if post_asset_folder is set, restrict renderable files to default file extension 
  if (result.renderable && ctx.config.post_asset_folder) {
    result.renderable = (extname(ctx.config.new_post_name) === extname(path));
  }

It helps for all files in post asset folders, but the default post file type configured in new_post_name.

https://kiko.io/post/Uups-empty-posts/

yoshinorin added a commit that referenced this issue Jan 1, 2022
fix(#1490): if `post_asset_folder` is set, restrict renderable files to default file extension
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists post-asset
Projects
None yet