This repository was archived by the owner on Nov 19, 2024. It is now read-only.
File tree 3 files changed +8
-4
lines changed
3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ def generate(site)
49
49
)
50
50
mrg_topic . content = metadata [ 'content' ]
51
51
mrg_topic . data [ 'title' ] = metadata [ 'title' ]
52
+ mrg_topic . data [ 'last_modified_at' ] = metadata [ 'last_modified_at' ]
52
53
mrg_topic . process ( "#{ mod } .md" )
53
54
54
55
# Add the newly constructed page object to the rest of pages
Original file line number Diff line number Diff line change 7
7
# The parameter contains a file path relative to its repository.
8
8
#
9
9
Jekyll ::Hooks . register :pages , :post_init do |page |
10
+
11
+ # Skip virtual pages like MRG topics
12
+ next if page . kind_of? Jekyll ::PageWithoutAFile
10
13
# Process only files with 'md' and 'html' extensions
11
14
next unless File . extname ( page . path ) . match? ( /md|html/ )
12
- # Do nothing for redirects
15
+ # Skip redirects
13
16
next if page . name == 'redirect.html'
14
17
15
18
dir = File . dirname page . path
Original file line number Diff line number Diff line change 3
3
#
4
4
# This custom plugin dynamically sets the 'last_modified_at' parameter
5
5
# for each page except 'redirect.html' pages.
6
- # A value of the pararmeter is available as {{ page.last_modified_at }}.
6
+ # A value of the parameter is available as {{ page.last_modified_at }}.
7
7
# The parameter contains date and time of the last commit that changed
8
8
# the original file.
9
9
# For available date formats, refer to https://git-scm.com/docs/git-log#git-log---dateltformatgt
10
10
#
11
- Jekyll ::Hooks . register :pages , :post_init do |page |
11
+ Jekyll ::Hooks . register :pages , :pre_render do |page |
12
12
# Do nothing in serving mode
13
13
next if page . site . config [ 'serving' ]
14
14
# Do nothing if the date is already set
23
23
dir = File . dirname real_filepath
24
24
filename = File . basename real_filepath
25
25
26
- # Read date of the last committ and assign it to last_modified_at parameter
26
+ # Read date of the last commit and assign it to last_modified_at parameter
27
27
# of the page.
28
28
page . data [ 'last_modified_at' ] =
29
29
`cd #{ dir } && git log -1 --format=%cd --date=iso -- #{ filename } ` . strip
You can’t perform that action at this time.
0 commit comments