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

Update date logic of opengraph and schema internal templates #8256

Merged
merged 4 commits into from
Feb 18, 2021
Merged

Update date logic of opengraph and schema internal templates #8256

merged 4 commits into from
Feb 18, 2021

Conversation

torrayne
Copy link

This is in response to my previous PR #8186.

  • Removed date checking of PublishDate and Lastmod
  • Merged duplicate IsPage blocks in opengraph.html
  • Formatted template tags so they're easier to follow. There are a lot of nested blocks and keeping track of what's open and what's closed was extremely tedious. I hope the changes I made makes this easier.

Feel free to cherry pick the date changes and exclude the formatting change.

{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
<meta property="article:section" content="{{ .Section }}" />
<meta property="article:published_time" content="{{ .PublishDate.Format $iso8601 }}" />
<meta property="article:modified_time" content="{{ .Lastmod.Format $iso8601 }}" />
Copy link
Member

Choose a reason for hiding this comment

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

Your template code looks clean and good. There is one thing I think we need to fix, though. I don't remember my exact comment in that other thread, but my main take on this is that

  • We don't need to fallback on some other date if PublishDate is not set
  • But PublishDate may still be zero (e.g. in cases where there are no date set on a given document)

So, given the construct above, I suggest just wrap it in a with, e.g.

{{ with .Lastmod }}<meta property="article:modified_time" content="{{ .Format $iso8601 }}" />{{ end }}

Copy link
Author

Choose a reason for hiding this comment

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

Just so I'm on the same page. You mean I should individually wrap both the PublishDate and Lastmod?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, assume all dates can be zero.

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants