Skip to content

Commit c15bf73

Browse files
committed
book: redirect missing xrefs to the English book
Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 14bc87a commit c15bf73

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

script/book.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,12 @@ def save
164164
FileUtils.mkdir_p(self.absolute_path("ch00"))
165165
@xrefs.each do |id_xref, section|
166166
path = self.absolute_path("ch00/#{id_xref}.html")
167-
relurl = "#{section.relative_url(nil)}##{id_xref}"
168-
front_matter = { "redirect_to" => relurl }
167+
if section == 'redirect-to-en'
168+
url = "book/en/v2/ch00/#{id_xref}"
169+
else
170+
url = "#{section.relative_url(nil)}##{id_xref}"
171+
end
172+
front_matter = { "redirect_to" => url }
169173
File.open(path, 'w') do |file|
170174
file.write(self.wrap_front_matter(front_matter))
171175
end

script/update-book2.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def genbook(language_code, &get_content)
134134
xlink = html.scan(/href="1-.*?\.html\#(.*?)"/)
135135
xlink&.each do |link|
136136
xref = link.first
137+
book.xrefs[xref] = 'redirect-to-en' if !book.xrefs[xref]
137138
begin
138139
html.gsub!(/href="1-.*?\.html\##{xref}"/, "href=\"{{< relurl \"#{book_prefix}ch00/#{xref}\" >}}\"")
139140
rescue StandardError
@@ -144,6 +145,7 @@ def genbook(language_code, &get_content)
144145
xlink = html.scan(/href="\#(.*?)"/)
145146
xlink&.each do |link|
146147
xref = link.first
148+
book.xrefs[xref] = 'redirect-to-en' if !book.xrefs[xref]
147149
begin
148150
html.gsub!(/href="\##{xref}"/, "href=\"{{< relurl \"#{book_prefix}ch00/#{xref}\" >}}\"")
149151
rescue StandardError

0 commit comments

Comments
 (0)