Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable to change IDs with friendly redirects #338

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading