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

Feature Request: Customizable date/timestamps #493

Closed
KatieTheDev opened this issue Oct 26, 2024 · 8 comments
Closed

Feature Request: Customizable date/timestamps #493

KatieTheDev opened this issue Oct 26, 2024 · 8 comments

Comments

@KatieTheDev
Copy link

Hi all,

While trying to customize my page to my liking, I discovered that Hugo has built-in support for different date and time formats. I would like to suggest a new feature where we can set if a timestamp should be shown or only date. I have a proof of concept available in my website's repository. I believe that using some if-statements and adding some options to the main config file, that we should be able to add this as a feature.

If the community finds interest in this, I would be more than happy to start work on a PR.

@KatieTheDev
Copy link
Author

image
This is an example of it working in action with how I currently have it set up.

@KatieTheDev
Copy link
Author

In issue #477 another user has suggested replacing the {{- .Date.Format "2006-01-02" -}} string with a time.Format :date_medium string. I would be interested in incorporating this into a potential PR, though I am unsure if it would be better with it separate.

@KatieTheDev
Copy link
Author

I should add that under my implementation, extra CSS is required to make it look how I did. In order to make the AM/PM designation uppercase, I created the following CSS rule:

.post-time {
  text-transform: uppercase;
  padding: 0px;
  margin: 0px;
  border: 0px;
}

In order to fix the issue of the extra span created for .post-time, I added the following css as well:

.post-time {
  text-transform: uppercase;
  padding: 0px;
  margin: 0px;
  border: 0px;
}

All of this can be found in my /assets/css/style.css file in my website's repository.

@KatieTheDev
Copy link
Author

As such, a PR should add these settings to one of the main CSS files. I think terminal.css would likely work well, unless any maintainers have suggestions?

Also, my apologies for the many comments. This is how I think and it is immensely helpful for me to be able to break up my thoughts this way.

@panr
Copy link
Owner

panr commented Oct 26, 2024

If the community finds interest in this, I would be more than happy to start work on a PR.

Hi @KatieTheDev, you are more than welcome to start the PR ;-) This seems to be a very interesting feature as long as we keep it true to the official Hugo docs (we don't want to add unnecessary abstractions).

The layout string probably should be configurable in config.toml, but I suggest to keep the current date format as default (as fallback when the new option is empty/null etc.) to not introducing breaking changes to anyone (at least for now).

Is it possible to mix (concatenate) two layouts like this: {{ .Date | .time.Format ":date_medium :time_short" }}? I haven't played with it yet?

@KatieTheDev
Copy link
Author

If the community finds interest in this, I would be more than happy to start work on a PR.

Hi @KatieTheDev, you are more than welcome to start the PR ;-) This seems to be a very interesting feature as long as we keep it true to the official Hugo docs (we don't want to add unnecessary abstractions).

The layout string probably should be configurable in config.toml, but I suggest to keep the current date format as default (as fallback when the new option is empty/null etc.) to not introducing breaking changes to anyone (at least for now).

Is it possible to mix (concatenate) two layouts like this: {{ .Date | .time.Format ":date_medium :time_short" }}? I haven't played with it yet?

I am not sure if that is possible, so possibly my PR could be refactored somewhat if it is. I will test this and find out. That said, I have it setup so that if my new configuration options are not set to true, it will default back to the existing datestamp. Please check out PR #494 as it has my work so far.

@KatieTheDev
Copy link
Author

Actually with how I have it set up to where you can enable/disable seconds, it may be best to keep them as separate lines so that we aren't duplicating code?

@KatieTheDev
Copy link
Author

Closed as discussion fits better in PR #494.

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

No branches or pull requests

2 participants