forked from magento/devdocs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage-baseurl-generator.rb
More file actions
39 lines (31 loc) · 903 Bytes
/
page-baseurl-generator.rb
File metadata and controls
39 lines (31 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Author: [email protected]
#
# This custom plugin dynamically sets and injects the page.baseurl variable
# based on the page's destination.
#
#
module PageBaseUrlGenerator
class Generator < Jekyll::Generator
def generate(site)
pages = site.pages
siteBaseUrl = site.baseurl
for page in pages
version = "2.2"
destination = page.path
matcher = /guides\/v([\d\.]+)\/.*/.match(destination)
if(matcher != nil)
version = matcher[1]
end
page.data['baseurl'] = "#{siteBaseUrl}/guides/v#{version}"
page.data['guide_version'] = version
end
#videos metadata
videos = site.collections["videos"]
videos.docs.each do |video|
version = "2.1"
video.data['baseurl'] = "#{siteBaseUrl}/guides/v#{version}"
video.data['guide_version'] = version
end
end
end
end