Skip to content

Commit

Permalink
FIX: Display post updated date in non-JS view for crawler
Browse files Browse the repository at this point in the history
  • Loading branch information
vinothkannans committed Feb 11, 2019
1 parent c50db76 commit 2c12336
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/views/topics/show.html.erb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -54,8 +54,18 @@
%> %>
<%= t("js.action_codes.#{post.action_code}", when: "", who: who_username).html_safe %> <%= t("js.action_codes.#{post.action_code}", when: "", who: who_username).html_safe %>
<% end %> <% end %>
<time datetime='<%= post.created_at.to_formatted_s(:iso8601) %>' itemprop='datePublished'> <%

This comment has been minimized.

Copy link
@ZogStriP

ZogStriP Feb 11, 2019

Member

This looks very entangled. I think a little repetition is better for reading comprehension.

What about something like this?

<% if post.updated_at > post.created_at %>
  <meta itemprop='datePublished' content='<%= post.created_at.to_formatted_s(:iso8601) %>'>
  <time itemprop='dateModified' datetime='<%= post.updated_at.to_formatted_s(:iso8601) %>'>
    <%= post.updated_at %>
  </time>
<% else %>
  <time itemprop='datePublished' datetime='<%= post.created_at.to_formatted_s(:iso8601) %>'>
    <%= post.created_at %>
  </time>
<% end %>

This comment has been minimized.

Copy link
@vinothkannans

vinothkannans Feb 11, 2019

Author Contributor

It's updated as per the commit below

e0c16d3

<%= post.created_at %> if post.updated_at > post.created_at
display_time, display_time_prop = post.updated_at, "dateModified"
%>
<meta itemprop='datePublished' content='<%= post.created_at.to_formatted_s(:iso8601) %>'>
<%
else
display_time, display_time_prop = post.created_at, "datePublished"
end
%>
<time datetime='<%= display_time.to_formatted_s(:iso8601) %>' itemprop='<%= display_time_prop %>'>
<%= display_time %>
</time> </time>
</span> </span>
<span itemprop='position'>#<%= post.post_number %></span> <span itemprop='position'>#<%= post.post_number %></span>
Expand Down

1 comment on commit 2c12336

@discoursebot
Copy link

Choose a reason for hiding this comment

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

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/different-schema-type-for-topics-and-posts/71471/11

Please sign in to comment.