-
Notifications
You must be signed in to change notification settings - Fork 5
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
Normalize directories and generate redirections #315
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a2e1128
Rename folders and write redirections
Aschen d237e73
Fix missing redirections
Aschen fffa673
Fix dead links
Aschen 4c82add
Fix dead links
Aschen 76cd27f
Update src/core/1/guides/essentials/installing-console/index.md
Aschen 72b8139
Update src/core/1/guides/essentials/installing-console/index.md
Aschen e139d84
Apply @scottinet comments
Aschen 092b2bb
Merge branch 'clean-directories' of github.com:kuzzleio/documentation…
Aschen 1745a92
Fix link in menu
Aschen 8faa599
Fix dead links
Aschen cdee819
fix(check_link): remove comments
Aschen 1cff3d7
Merge ok
Aschen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require 'yaml' | ||
require 'json' | ||
|
||
def each_dir(start, &block) | ||
directories = Dir["#{start}/*"] | ||
|
||
directories.each do |path| | ||
if File.file?(path) | ||
block.call(path) | ||
else | ||
each_dir(path, &block) | ||
end | ||
end | ||
end | ||
|
||
redirections = YAML.load_file('./redirections.yml') | ||
|
||
v2_redir = [] | ||
v2_pages = [] | ||
|
||
redirections['redirections'].each do |redirection| | ||
each_dir("../documentation-v2/src/#{redirection['from']}") do |file| | ||
v2_redir << file.gsub('../documentation-v2/', '') | ||
end | ||
end | ||
|
||
each_dir("../documentation-v2/src/") do |file| | ||
next unless file.end_with?('.md') | ||
v2_pages << file.gsub('../documentation-v2/', '').gsub(/\/\//, '/') | ||
end | ||
|
||
v2_redir.uniq! | ||
v2_pages.uniq! | ||
missing_redirections = v2_pages - v2_redir | ||
|
||
puts "#{v2_redir.count} redirection from v2 to v3" | ||
puts "#{v2_pages.count} pages for v2" | ||
puts "#{missing_redirections.count} missing redirections" | ||
|
||
if missing_redirections.any? | ||
File.write('./missing-redirections.json', JSON.pretty_generate(missing_redirections)) | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this line, and all other commented out lines of this file.