Skip to content

Commit

Permalink
Merge pull request #338 from remote-jp/enable-to-change-ids-with-frie…
Browse files Browse the repository at this point in the history
…ndly-redirect

Enable to change IDs with friendly redirects
  • Loading branch information
yasulab authored Jan 17, 2025
2 parents 80d4805 + 074f780 commit 3e91d85
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 3 additions & 0 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -176,6 +178,7 @@ DEPENDENCIES
jekyll
jekyll-include-cache
jekyll-paginate
jekyll-redirect-from
jekyll-seo-tag
jekyll-sitemap
logger
Expand Down
1 change: 1 addition & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 17 additions & 1 deletion docs/upsert_data_by_readme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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('(', '(')
Expand All @@ -69,6 +83,8 @@
link: #{link}
commit_url: #{latest_commit_url}
commit_at: #{latest_commit_at}
redirect_from:
- /#{lang}/#{id_v1}
---
#{CGI.unescapeHTML description}
Expand Down

0 comments on commit 3e91d85

Please sign in to comment.