forked from telerik/winforms-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlastMod_generator.rb
More file actions
17 lines (15 loc) · 780 Bytes
/
lastMod_generator.rb
File metadata and controls
17 lines (15 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# This code block is used in the sitemap.xml template - it takes the file name as an argument (provided via other liquit tags) and returns the last commit date from git in YYYY-MM-DD format
# Necesary for SEO optimization of the documentation so Google can get proper last modified dates of our articles and index them
class TimeStampTag < Liquid::Block
def initialize(tag_name, markup, tokens)
@text = markup
super
end
def render(context)
contents = super
content = Liquid::Template.parse(contents).render context
# aim for YYYY-MM-DD format https://www.google.com/sitemaps/protocol.html#lastmoddef
`git log -1 --format=%cd --date=short #{content}`.strip
end
end
Liquid::Template.register_tag('timestamp', TimeStampTag)