Skip to content

Commit 1d5887d

Browse files
committed
Use Guillaume's suggested versioning scheme, migration-guides/3.16
1 parent 6eeae61 commit 1d5887d

File tree

5 files changed

+54
-16
lines changed

5 files changed

+54
-16
lines changed

_config.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ collections:
8080
permalink: /version/:path
8181
migrations:
8282
output: true
83-
permalink: /migration/:path
83+
permalink: /migration-guides/:version
8484

8585
# Exclude from processing.
8686
# The following items will not be processed, by default. Create a custom list
@@ -131,6 +131,8 @@ defaults:
131131
values:
132132
layout: migration-guide
133133
toc: true
134+
version_regex: "Migration-Guide-"
135+
# permalink needs be defined above, with the collection definition
134136
-
135137
scope:
136138
type: redirects

_layouts/migration-guide.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<section class="full-width-version-bg flexfilterbar guides">
2222
<div class="guideflexcontainer">
2323
<div class="docslink">
24-
<a class="returnlink" href="{{site.baseurl}}/migrations/"> Back to Migration Guides</a>
24+
<a class="returnlink" href="{{site.baseurl}}/migration-guides/"> Back to Migration Guides</a>
2525
</div>
2626
</div>
2727
</section>

_plugins/version_permalink.rb

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module VersionPermalink
2+
class VersionPermalink < Jekyll::Generator
3+
safe true
4+
priority :low
5+
6+
def generate(site)
7+
# fill in version information from the filename
8+
collection = site.collections["migrations"]
9+
collection.docs.each { |doc|
10+
data = doc.data
11+
reg_str = data["version_regex"]
12+
repl_str = ""
13+
re = Regexp.new reg_str
14+
15+
# This will be returned
16+
version = data["slug"].gsub re, repl_str
17+
doc.data.merge!('version' => version)
18+
19+
}
20+
end
21+
22+
Jekyll::Hooks.register :migrations, :pre_render do |doc|
23+
begin
24+
# check if jekyll can resolve the url template
25+
doc.url
26+
rescue NoMethodError => error
27+
begin
28+
def doc.url_template
29+
custom_permalink_placeholders = ["version"]
30+
@custom_url_template ||= custom_permalink_placeholders.inject(collection.url_template) { |o, m| o.sub ":" + m, data["version"].to_s }
31+
32+
end
33+
end
34+
end
35+
end
36+
end
37+
end

migration-guides.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
layout: base
3+
---
4+
5+
<h1>Migration Guides</h1>
6+
7+
{% assign doclist = site.migrations %}
8+
<ul>
9+
{% for doc in doclist %}
10+
<li><a href="{{ site.baseurl }}{{ doc.url }}">{{ doc.version }}</a></li>
11+
{% endfor %}
12+
</ul>
13+

migrations.html

-14
This file was deleted.

0 commit comments

Comments
 (0)