diff --git a/_config.yml b/_config.yml index 9acc7ca3d05..194e6599d6b 100755 --- a/_config.yml +++ b/_config.yml @@ -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 @@ -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 diff --git a/_layouts/migration-guide.html b/_layouts/migration-guide.html index 74384495838..4138bf4506e 100644 --- a/_layouts/migration-guide.html +++ b/_layouts/migration-guide.html @@ -21,7 +21,7 @@
diff --git a/_plugins/version_permalink.rb b/_plugins/version_permalink.rb new file mode 100644 index 00000000000..b79a6e1b52f --- /dev/null +++ b/_plugins/version_permalink.rb @@ -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 \ No newline at end of file diff --git a/migration-guides.html b/migration-guides.html new file mode 100644 index 00000000000..4c1cee6fce8 --- /dev/null +++ b/migration-guides.html @@ -0,0 +1,13 @@ +--- +layout: base +--- + +

Migration Guides

+ +{% assign doclist = site.migrations %} + + diff --git a/migrations.html b/migrations.html deleted file mode 100644 index c54cfb05bca..00000000000 --- a/migrations.html +++ /dev/null @@ -1,14 +0,0 @@ ---- -layout: base ---- - -

Migration Guides

- -{% assign doclist = site.migrations %} - -