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

A more universal variable system both front-matter + file name + permalinks. #649

Closed
reggi opened this issue May 30, 2014 · 7 comments
Closed
Milestone

Comments

@reggi
Copy link

reggi commented May 30, 2014

This is a feature request, for a way to standardize the variable system. It revolves around the idea that any variable can be set within the post file-name and within the YML front-matter and that these variables can be both used in the layouts and in the permalink, (any place a variable can be used).

Here's an example of my config file.

permalink: :crazyid/:year/:month/:day/:title/
new_post_name: :crazyid-:year-:month-:day-:title.md # File name of new posts

Given the example file name:

jd91230ue-2014-03-14-hello-world.md

It's rendering out the url to:

http://localhost:4000/2014/05/30/jd91230ue-2014-03-14-hello-world/

I would expect it to be:

http://localhost:4000/jd91230ue/2014/05/30/hello-world/

It would be nice if the YML front-matter variables could be used for the permalink as well (a priority would need to take place between file-name and front-matter).

title: Hello World
crazyid: jd91230ue

---
Welcome to [Hexo](http://hexo.io/)! This is your very first post. Check [documentation](http://hexo.io/docs/) for more info. If you get any problems when using Hexo, you can 

for instance.

Or without setting it in the md post and it just being in the file name, being able to use the crazyid variable within the template / layout would be more universal.

@tommy351 tommy351 added bug and removed bug labels May 30, 2014
@tommy351 tommy351 added this to the 2.7 milestone May 30, 2014
@tommy351
Copy link
Member

OK. I'll try to implement this feature in 2.7.

@sergiolepore
Copy link
Contributor

@tommy351 THIS

Seriously, this could be awesome. I could use a variable named language to define the post language, reflect it on the permalink, write a theme which queries posts by language variable and we'll be so close to resolve this: #474 😃

@reggi
Copy link
Author

reggi commented May 30, 2014

I think it would also be wise to have some kind of "Hook" that allowed plugins to manipulate these variables before they're used, kind of like a "Middleware". This would allow me to have a post named hello-world.md which is mapped to :title and have the title be rendered out as Hello World (rather then hello world) in my blog post without any redundant YML front-matter or functions within the layout, could also be used to manipulate date with moment.js. Thoughts on this?

@tommy351
Copy link
Member

@reggi Hexo has "Filter" currently. But it's still weak. This part will be enhanced in future.

@tommy351 tommy351 modified the milestones: 2.8, 2.7 Jun 14, 2014
@tommy351
Copy link
Member

tommy351 commented Jul 6, 2014

This feature will be released in 2.8.

@sergiolepore
Copy link
Contributor

:D great!
El jul 6, 2014 5:52 a.m., "SkyArrow" notifications@github.com escribió:

This feature will be released in 2.8.


Reply to this email directly or view it on GitHub
#649 (comment).

@reggi
Copy link
Author

reggi commented Aug 11, 2014

Thank you so much for implementing. This works like a charm! 👍

zhipengyan pushed a commit to zhipengyan/hexo that referenced this issue Apr 4, 2016
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