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

Yaml frontmatter #990

Merged
merged 5 commits into from
Dec 8, 2020
Merged

Yaml frontmatter #990

merged 5 commits into from
Dec 8, 2020

Conversation

er-vin
Copy link
Contributor

@er-vin er-vin commented Apr 11, 2020

This is an attempt at adding YAML front matter support to Zola. I'm carrying over 16 years worth of content which moved from Jekyll to Hugo and now to Zola. Obviously this makes it easier to have YAML support in the front matter.

This feature has been discussed in #317 already and I agree that YAML should be limited only to actual content and nothing more. This is mainly useful for legacy reason and for external tooling (mainly text editors) which tend to support properly only YAML in the front matter.

@Keats
Copy link
Collaborator

Keats commented Apr 27, 2020

Is that using strict yaml?

@er-vin
Copy link
Contributor Author

er-vin commented Apr 27, 2020

Unfortunately not, to my knowledge serde_yaml currently only uses yaml-rust and not strict-yaml-rust. As soon as serde_yaml allows to use strict-yaml-rust as dependency or if a serde_strict_yaml emerges I'd expect this to be easy to migrate though.

@Keats
Copy link
Collaborator

Keats commented May 18, 2020

I would really prefer to have strict yaml only though but https://github.com/fralalonde/strict-yaml-rust doesn't seem maintained. Is there another crate?

@er-vin
Copy link
Contributor Author

er-vin commented May 18, 2020

Nope, didn't find any crate apart from the unmaintained one you mentioned. So went for the "next best thing" which is at least maintained.

@Keats Keats closed this May 25, 2020
@Keats
Copy link
Collaborator

Keats commented May 25, 2020

I didn't mean to close all the PRs by deleting the branch :(

@Keats Keats reopened this May 25, 2020
@er-vin er-vin force-pushed the yaml_frontmatter branch 2 times, most recently from 8a2860f to f1de444 Compare June 3, 2020 10:54
@Abdillah
Copy link

Do we wait for a maintained strict Yaml crate to appear?
Hope this merged soon..

@hmble
Copy link
Contributor

hmble commented Aug 1, 2020

yaml-rust crate is fully-comaptible with YAML 1.2 specification. Can we use this library ? @er-vin

@Keats Keats closed this Sep 4, 2020
@Keats Keats reopened this Sep 4, 2020
@er-vin
Copy link
Contributor Author

er-vin commented Sep 7, 2020

yaml-rust crate is fully-comaptible with YAML 1.2 specification. Can we use this library ? @er-vin

Already the case in fact, this is what serde_yaml uses under the hood.

@er-vin
Copy link
Contributor Author

er-vin commented Sep 7, 2020

Need to rebase this once more I see, will try to do it next week.

@rcarmo
Copy link

rcarmo commented Nov 7, 2020

this is great, I too have 18 years of content I'd like to move across :)

@hmble
Copy link
Contributor

hmble commented Nov 7, 2020

I hope this gets merged soon. Thanks @er-vin

@rcarmo
Copy link

rcarmo commented Nov 26, 2020

Bumping this to check if it will be merged soon.

Copy link
Collaborator

@Keats Keats left a comment

Choose a reason for hiding this comment

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

thanks for the ping, I forgot about that.
The code looks ok, just a few tweaks needed

docs/content/documentation/content/page.md Outdated Show resolved Hide resolved
docs/content/documentation/content/section.md Outdated Show resolved Hide resolved
components/front_matter/Cargo.toml Outdated Show resolved Hide resolved
@rcarmo
Copy link

rcarmo commented Nov 28, 2020

I'm curious: why not document something that may bring more people to use this software?

@Keats
Copy link
Collaborator

Keats commented Nov 28, 2020

I don't like YAML and personally think this is not a good feature but many people want it so I'm ok adding it (like themes). But adding it to the documentation means more people will use and will want to have YAML everywhere instead of TOML (config.yaml, theme.yaml etc) and it would make sense in terms of consistency. But I really don't want to ;(

@rcarmo
Copy link

rcarmo commented Nov 28, 2020 via email

@Keats
Copy link
Collaborator

Keats commented Nov 28, 2020

Well, here’s an idea: document it as a migration feature and explicitly state the limitations and that it is meant only for onboarding older content.

That's a good angle!

Still, if we find a string we involve the TOML parser to make sure the
content of said string would be a correct TOML date. In a pure TOML
world this isn't exactly relevant, but this will come in handy when
using a YAML deserializer.

Signed-off-by: Kevin Ottens <ervin@ipsquad.net>
This will be necessary for the YAML frontmatter handling and
corresponding unit tests.

Signed-off-by: Kevin Ottens <ervin@ipsquad.net>
Signed-off-by: Kevin Ottens <ervin@ipsquad.net>
Copy link
Collaborator

@Keats Keats left a comment

Choose a reason for hiding this comment

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

Just one small comment but lgtm otherwise

components/front_matter/src/lib.rs Show resolved Hide resolved
Signed-off-by: Kevin Ottens <ervin@ipsquad.net>
This is just a light update on purpose. There would be no point in
pushing YAML too much, this is mainly here to help people with a backlog
of posts to transition.

Signed-off-by: Kevin Ottens <ervin@ipsquad.net>
@er-vin er-vin requested a review from Keats December 8, 2020 16:43
@Keats Keats merged commit 2499a50 into getzola:next Dec 8, 2020
@Keats
Copy link
Collaborator

Keats commented Dec 8, 2020

Thanks!

@er-vin er-vin deleted the yaml_frontmatter branch December 9, 2020 07:17
Keats pushed a commit that referenced this pull request Dec 14, 2020
* Accept dates presented as strings

Still, if we find a string we involve the TOML parser to make sure the
content of said string would be a correct TOML date. In a pure TOML
world this isn't exactly relevant, but this will come in handy when
using a YAML deserializer.

Signed-off-by: Kevin Ottens <ervin@ipsquad.net>

* Add serde_yaml and test-case dependencies

This will be necessary for the YAML frontmatter handling and
corresponding unit tests.

Signed-off-by: Kevin Ottens <ervin@ipsquad.net>

* Add YAML front matter handling

Signed-off-by: Kevin Ottens <ervin@ipsquad.net>

* Switch RawFrontMatter enum to wrap &str instead of String

Signed-off-by: Kevin Ottens <ervin@ipsquad.net>

* Update the documentation to mention YAML frontmatter

This is just a light update on purpose. There would be no point in
pushing YAML too much, this is mainly here to help people with a backlog
of posts to transition.

Signed-off-by: Kevin Ottens <ervin@ipsquad.net>
@ttys3
Copy link

ttys3 commented Jan 6, 2021

with this PR, I think I can switch from my Hugo + YAML front matter blog to zola !

thanks for the works, guy!

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.

None yet

6 participants