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

fix(#1490): if post_asset_folder is set, restrict renderable files to default file extension #4781

Merged
merged 3 commits into from Jan 1, 2022

Conversation

kristofzerbe
Copy link
Contributor

What does it do?

It alleviates the problem on the rendering asset files as posts, if post_asset_folder is set to true, by restricting the rendered file types to the default new post type (new_post_name).

Caveat: Doesn't work with MD files as assets, when your default file type is MD.

It is not a final solution, as it would be better to identify to subfolder as asset folder in this stage of code execution.

How to test

git clone -b BRANCH https://github.com/USER/hexo.git
cd hexo
npm install
npm test
  1. Set post_asset_folder to true in _config.yml
  2. Create new post
  3. Create subfolder (without leading underscore!) in newly created asset folder for the post
  4. Copy a HTML, JS or CSS file into the subfolder
  5. run hexo generate

None of the subfolders files should be rendered as post, as it will be in the current version. They will be treated as real assets.

Copy link
Member

@SukkaW SukkaW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Would you mind adding unit test cases for the changes as well?

@SukkaW SukkaW mentioned this pull request Sep 22, 2021
@tomap
Copy link
Contributor

tomap commented Nov 4, 2021

@SukkaW maybe we could add the unit tests ourselves (@hexojs/core ) and fix the linting issue to move forward faster?

@SukkaW
Copy link
Member

SukkaW commented Nov 4, 2021

@SukkaW maybe we could add the unit tests ourselves (@hexojs/core ) and fix the linting issue to move forward faster?

Yeah, that would be fine.

@yoshinorin yoshinorin changed the title Resolve #1490 fix(#1490): if post_asset_folder is set, restrict renderable files to default file extension Jan 1, 2022
@yoshinorin
Copy link
Member

@kristofzerbe
Thank you :)

@hexojs/core
I wrote the test code & fix lint.
Would you please review again?

Thank you :)

@kristofzerbe
Copy link
Contributor Author

Thank you for the test and lint... Happy New Year

@yoshinorin yoshinorin merged commit 8465a61 into hexojs:master Jan 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

asset files were rendered when post_asset_folder set to true
4 participants