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

Throw an error if post_link is provided an invalid slug #2916

Closed
schreifels opened this issue Dec 17, 2017 · 1 comment
Closed

Throw an error if post_link is provided an invalid slug #2916

schreifels opened this issue Dec 17, 2017 · 1 comment

Comments

@schreifels
Copy link

Having post_link and post_path return nothing if the provided slug does not exist makes it easy to accidentally create dead links on your site.

It was previously suggested that this should throw an error in #1594, which was closed as a dupe of #1771, but it doesn't look like this was ever implemented as part of the latter ticket, nor can I find any further discussion about it.

Reproduction case

hexo init test-site
cd test-site
echo "{% post_link 'hello-world' %}{% post_link 'hello-world-nonexistent' %}" >> source/_posts/hello-world.md
hexo server --open

The server output only contains:

~/Desktop/tmp/test-site $ hexo server --open
INFO  Start processing
INFO  Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.

and the page renders with only the first link (which has a valid slug). I think it would be much safer if an error or warning was printed in the server log.

Environment Info

~/Desktop/tmp/test-site $ node -v
v8.9.3
~/Desktop/tmp/test-site $ npm ls --depth 0
hexo-site@0.0.0 ~/Desktop/tmp/test-site
├── hexo@3.4.3
├── hexo-generator-archive@0.1.5
├── hexo-generator-category@0.1.3
├── hexo-generator-index@0.2.1
├── hexo-generator-tag@0.2.0
├── hexo-renderer-ejs@0.3.1
├── hexo-renderer-marked@0.3.0
├── hexo-renderer-stylus@0.3.3
└── hexo-server@0.2.2
@leesei
Copy link
Member

leesei commented Aug 6, 2018

#1771 is only on formatting, it does not intend to modify logic of when to generate an error.
I think I misread the proposed solution as code snippet in Hexo code base. It should NOT have been marked as duplicate in the first place.
Closing this one and reopen #1594.

@leesei leesei closed this as completed Aug 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants