Skip to content

Commit

Permalink
Use Guillaume's suggested versioning scheme, migration-guides/3.16
Browse files Browse the repository at this point in the history
  • Loading branch information
holly-cummins committed Sep 3, 2024
1 parent 6eeae61 commit b902de0
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 16 deletions.
4 changes: 3 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ collections:
permalink: /version/:path
migrations:
output: true
permalink: /migration/:path
permalink: /migration-guides/:version

# Exclude from processing.
# The following items will not be processed, by default. Create a custom list
Expand Down Expand Up @@ -131,6 +131,8 @@ defaults:
values:
layout: migration-guide
toc: true
version_regex: "Migration-Guide-"
# permalink needs be defined above, with the collection definition
-
scope:
type: redirects
Expand Down
2 changes: 1 addition & 1 deletion _layouts/migration-guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<section class="full-width-version-bg flexfilterbar guides">
<div class="guideflexcontainer">
<div class="docslink">
<a class="returnlink" href="{{site.baseurl}}/migrations/"> Back to Migration Guides</a>
<a class="returnlink" href="{{site.baseurl}}/migration-guides/"> Back to Migration Guides</a>
</div>
</div>
</section>
Expand Down
38 changes: 38 additions & 0 deletions _plugins/version_permalink.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module VersionPermalink
class VersionPermalink < Jekyll::Generator
safe true
priority :low

def generate(site)
# fill in version information from the filename
collection = site.collections["migrations"]
collection.docs.each { |doc|
data = doc.data
reg_str = data["version_regex"]
repl_str = ""
re = Regexp.new reg_str

# This will be returned
puts "got regex"
version = data["slug"].gsub re, repl_str
puts doc.data["version_regex"]
doc.data.merge!('version' => version)

}
end

Jekyll::Hooks.register :migrations, :pre_render do |doc|
begin
# check if jekyll can resolve the url template
doc.url
rescue NoMethodError => error
begin
def doc.url_template
custom_permalink_placeholders = ["version"]
@custom_url_template ||= custom_permalink_placeholders.inject(collection.url_template) { |o, m| o.sub ":" + m, version.to_s }
end
end
end
end
end
end
13 changes: 13 additions & 0 deletions migration-guides.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
layout: base
---

<h1>Migration Guides</h1>

{% assign doclist = site.migrations %}
<ul>
{% for doc in doclist %}
<li><a href="{{ site.baseurl }}{{ doc.url }}">{{ doc.version }}</a></li>
{% endfor %}
</ul>

14 changes: 0 additions & 14 deletions migrations.html

This file was deleted.

0 comments on commit b902de0

Please sign in to comment.