Add support for native Org dates in frontmatter #7433
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using Org mode with Hugo, it would be nice to have support for Org timestamps for the
DATE
header.At the moment (hugo v0.72.0),
DATE
only supports Hugo's native syntax in Org files, therefore this is parsed correctly:While this is not:
Expected result
Using the following template to format a page's
Date
attribute should produce the correct date:Actual result
Output for
#+DATE: 2020-06-10
:Output for
#+DATE: <2020-06-10 Wed>
:Since Org mode defaults to the latter syntax, it would be great to have support for that in Hugo. Discussing this issue with @niklasfasching, he explained that this would fit better into Hugo than into go-org because of how Org frontmatter is handled by Hugo.
This pull request adds a simple parseORGDate function that does not touch the date value if it does not match an Org timestamp regexp, so that users who are currently using Hugo's native syntax do not experience any breakage.