Skip to content

Commit 966f67c

Browse files
committed
Mark the highest version as 'main'
1 parent 9323742 commit 966f67c

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

_plugins/version_permalink.rb

+15-7
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,28 @@ def generate(site)
1919

2020
number_pattern = /^[0-9.]+$/
2121

22+
j = 0
23+
# Add a marker for things that don't have a version, because liquid filters are not as flexible as we'd like
24+
# This has to happen before we do any conversion of 'main'
25+
collection.docs.filter { |doc| ! doc.data["version"].match?(number_pattern) }.each { |doc|
26+
data = doc.data
27+
j +=1
28+
data.merge!('unversion_counter' => j)
29+
}
30+
2231
# Also add a version scalar that we can use for sorting
2332
i = 0
2433
collection.docs.filter { |doc| doc.data["version"].match?(number_pattern) }.sort_by { |doc| Gem::Version.new(doc.data["version"]) }.reverse.each { |doc|
2534
data = doc.data
2635
i +=1
2736
data.merge!('version_counter' => i)
28-
}
2937

30-
j = 0
31-
# Add a marker for things that don't have a version, because liquid filters are not as flexible as we'd like
32-
collection.docs.filter { |doc| ! doc.data["version"].match?(number_pattern) }.each { |doc|
33-
data = doc.data
34-
j +=1
35-
data.merge!('unversion_counter' => j)
38+
39+
# Mark the latest release as main
40+
if i == 1
41+
data.merge!('proposed_version' => data["version"])
42+
data.merge!('version' => "main")
43+
end
3644
}
3745

3846
end

migration-guides.html

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@
44

55
<h1>Migration Guides</h1>
66

7-
8-
97
{% assign doclist = site.migrations | sort: 'version_counter' | where: 'unversion_counter', nil %}
108
<ul>
119
{% for doc in doclist %}
12-
<li><a href="{{ site.baseurl }}{{ doc.url }}">{{ doc.version }}</a></li>
10+
{% if doc.proposed_version %}
11+
{% assign comment = ', will be ' | append: doc.proposed_version %}
12+
{% else %}
13+
{% assign comment = '' %}
14+
{% endif %}
15+
<li><a href="{{ site.baseurl }}{{ doc.url }}">{{ doc.version }}</a>{{ comment }}</li>
1316
{% endfor %}
1417
</ul>
1518

16-
{% assign doclist = site.migrations | sort: 'version_counter' | where: 'version_counter', nil %}
19+
{% assign doclist = site.migrations | sort: 'version_counter' | where: 'version_counter', nil | where_exp: 'doc', "doc.version != 'Migration-Guides'" %}
1720
<h2>Special Guides</h2>
1821
<ul>
1922
{% for doc in doclist %}

0 commit comments

Comments
 (0)