diff --git a/docs/Gemfile b/docs/Gemfile index 61398d41..c8502ea6 100644 --- a/docs/Gemfile +++ b/docs/Gemfile @@ -19,6 +19,7 @@ end group :jekyll_plugins do gem 'jekyll' gem 'jekyll-paginate' + gem 'jekyll-redirect-from' gem 'support-for' gem 'jekyll-seo-tag' gem 'jekyll-sitemap' diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index 2c514ec2..c4e9c215 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -89,6 +89,8 @@ GEM jekyll-include-cache (0.2.1) jekyll (>= 3.7, < 5.0) jekyll-paginate (1.1.0) + jekyll-redirect-from (0.16.0) + jekyll (>= 3.3, < 5.0) jekyll-sass-converter (3.0.0) sass-embedded (~> 1.54) jekyll-seo-tag (2.8.0) @@ -176,6 +178,7 @@ DEPENDENCIES jekyll jekyll-include-cache jekyll-paginate + jekyll-redirect-from jekyll-seo-tag jekyll-sitemap logger diff --git a/docs/_config.yml b/docs/_config.yml index 1c389207..d3d4e7ee 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -10,6 +10,7 @@ markdown: kramdown plugins: - jekyll-paginate + - jekyll-redirect-from - jekyll-sitemap # This must be LAST to include contents generated by gems above # It seems this pagination does nothing in this website diff --git a/docs/upsert_data_by_readme.rb b/docs/upsert_data_by_readme.rb index 914c05f3..1717582f 100755 --- a/docs/upsert_data_by_readme.rb +++ b/docs/upsert_data_by_readme.rb @@ -46,7 +46,21 @@ name_and_link = Kramdown::Document.new(cells[1]).root.children[0].children[0] name = name_and_link.children[0].value.strip link = name_and_link.attr['href'] - id = name.gsub(' ', '_') + id = name.downcase # ID (v2) + .gsub('株式会社', '') + .gsub('inc.', '') + .gsub('&', 'and') + .gsub('&', 'and') + .gsub('(', ' ') + .gsub(')', ' ') + .gsub('/', '_') + .strip.gsub(' ', '_').gsub('__', '_') + .delete(".,").downcase + + # ID (v1): Need to archive each version for redirects with this plugin + # https://github.com/jekyll/jekyll-redirect-from + # NOTE: This plugin can handle redirect loop if `id == id_v1` + id_v1 = name.gsub(' ', '_') .gsub('&', 'and') .gsub('&', 'and') .gsub('(', '(') @@ -69,6 +83,8 @@ link: #{link} commit_url: #{latest_commit_url} commit_at: #{latest_commit_at} + redirect_from: + - /#{lang}/#{id_v1} --- #{CGI.unescapeHTML description}