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

Made date format configurable using parameter #13

Conversation

ilikeorangutans
Copy link

Closes #12

As discussed in issue #12 this makes the date format configurable via a param. I don't see a way of how a template could provide a default value for a param, from what I can tell the config.toml in a theme is just to provide an example.

Also, sorry about the trimmed whitespaces at the end of the line, my editor does that and I didn't realize until I put this up.

@aos what do you think?

@aos
Copy link
Owner

aos commented Apr 19, 2018

Hey @ilikeorangutans thanks for the PR! I've been very busy this last week so I'll look at it this weekend if I have time

@ilikeorangutans
Copy link
Author

No worries, let me know what you think. Already building my own blog against my fork, so I'm good. Just thought I'd give back! 😄

<time datetime="{{ $page.Date.Format "01-02-2006" }}">
{{ $page.Date.Format "01-02-2006" }}
<time datetime="{{ $page.Date.Format .Site.Params.dateformat }}">
{{ $page.Date.Format .Site.Params.dateformat }}
Copy link
Owner

Choose a reason for hiding this comment

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

So I think the addition of a Params section for dateformat is great, but I think we can still do with a default one like so:

{{ if .Site.Params.dateformat }}
  {{ $page.Date.Format .Site.Params.dateformat }}
{{ else }}
  {{ $page.Date.Format "01-02-2006" }}
{{ end }}

It is unfortunately more verbose, but this is the cleanest way to go about it if we want a drop-in theme template without having to add anything extra on the config from the get-go.

Copy link
Owner

@aos aos Apr 24, 2018

Choose a reason for hiding this comment

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

Also, I think the datetime attribute of <time /> doesn't necessarily need to be formatted and can just be given standard UTC time as its strictly for machine parsing or accessibility.

I forgot to change it when initially creating this template. If you want to work on that as well, that would be great!

@aos
Copy link
Owner

aos commented Nov 13, 2018

Hey @ilikeorangutans -- I've went ahead and implemented these changes. See #15 for details. I'll be closing your PR. Thanks for the input and help!

@aos aos closed this Nov 13, 2018
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.

2 participants