Skip to content

Commit

Permalink
Update URI generation algorithm more unique way with friendly redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
yasulab committed Jan 29, 2025
1 parent 3300b09 commit acbe6b8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions docs/upsert_data_by_readme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@
name = name_and_link.children[0].value.strip
link = name_and_link.attr['href']
domain = PublicSuffix.domain(link.split('/')[2])
id = name.downcase # ID (v2)
id = domain.gsub('.', '_')

# The following`id` has been replaced with the `domain` above.
# So 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_v2 = name.downcase # ID (v2)
.gsub('株式会社', '')
.gsub('inc.', '')
.gsub('&', 'and')
Expand All @@ -58,10 +65,6 @@
.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')
Expand All @@ -88,6 +91,7 @@
categories: #{is_full_remote}
redirect_from:
- /#{lang}/#{id_v1}
- /#{lang}/#{id_v2}
---
#{CGI.unescapeHTML description}
Expand Down

0 comments on commit acbe6b8

Please sign in to comment.