Skip to content

Commit 962acee

Browse files
committed
Generate sitemap _after_ all pages have been indexed
1 parent b808f43 commit 962acee

File tree

5 files changed

+95
-33
lines changed

5 files changed

+95
-33
lines changed

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Welcome to the LearnTeachCode Code & Coffee Compendium Github Repository! Mainta
1515

1616
This site was generated using https://asciidoctor.org/[Asciidoctor] - a static-site generator for the https://asciidoctor.org/docs/asciidoc-syntax-quick-reference[AsciiDoc] markup language.
1717

18-
Want extra coding help? Join our https://learnteachcode.org/slack[Slack group].
18+
ant extra coding help? Join our https://learnteachcode.org/slack[Slack group].
1919

2020
== Contributing
2121
Contributors are welcome to fork this repository and make changes. Please submit a Pull Request with your changes to be reviewed by a repository owner.

convert.rb

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
21
# Safe script for converting Asciidoc file to HTML
32
# Converts all .adoc files in the parent director to .html files
3+
# Usage requires a sitemap.adoc file in the project's root directory
44

55
require 'asciidoctor'
66
require 'asciidoctor/cli/options'
@@ -9,42 +9,45 @@
99
require 'asciidoctor-diagram'
1010

1111
sitemappuml = File.open("sitemap.puml", "w")
12-
1312
sitemappuml.write "@startuml\nhide empty description\n"
1413

1514
Dir["./*.adoc"].each { |x|
16-
f = File.open(x, "r")
17-
18-
filename = x.gsub(/.\//, "")
19-
filename = filename.gsub(/.adoc/, "")
20-
filename = filename.gsub(/-/, "")
21-
22-
f.each_line do |line|
23-
if line.start_with? "="
24-
if not line.include? "image"
25-
level = line.count("=")
26-
if level <= 2
27-
line = line.gsub(/\s+/, "")
28-
line = line.gsub(/=+/, "")
29-
line = line.gsub(/<</, "")
30-
line = line.gsub(/>>/, "")
31-
line = line.gsub(/\)/, "")
32-
line = line.gsub(/\(/, "")
33-
line = line.gsub(/-/, "")
34-
line = line.gsub(/#/, "")
35-
line = line.gsub(/\,/, "")
36-
sitemappuml.write filename + " -down-> " + line + "\n"
15+
if not x.include? "sitemap"
16+
f = File.open(x, "r")
17+
18+
filename = x.gsub(/.\//, "")
19+
filename = filename.gsub(/.adoc/, "")
20+
filename = filename.gsub(/-/, "")
21+
22+
f.each_line do |line|
23+
if line.start_with? "="
24+
if not line.include? "image"
25+
level = line.count("=")
26+
if level <= 2
27+
line = line.gsub(/\s+/, "")
28+
line = line.gsub(/=+/, "")
29+
line = line.gsub(/<</, "")
30+
line = line.gsub(/>>/, "")
31+
line = line.gsub(/\)/, "")
32+
line = line.gsub(/\(/, "")
33+
line = line.gsub(/-/, "")
34+
line = line.gsub(/#/, "")
35+
line = line.gsub(/\,/, "")
36+
sitemappuml.write filename + " -down-> " + line + "\n"
37+
end
3738
end
38-
end
39-
end
40-
end
39+
end
40+
end
4141

42-
f.close
42+
f.close
4343

44-
Asciidoctor.convert_file x, to_file: true, safe: :safe
44+
Asciidoctor.convert_file x, to_file: true, safe: :safe
45+
end
4546
}
4647

4748
sitemappuml.write "@enduml"
48-
4949
sitemappuml.close
50-
puts "Sitemap generated successfully."
50+
51+
Asciidoctor.convert_file "./sitemap.adoc", to_file: true, safe: :safe
52+
53+
puts "Sitemap generated successfully."

ruby

Whitespace-only changes.

sitemap.puml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ references -down-> CareersinTech
2323
references -down-> Python
2424
references -down-> PairProgramming
2525
references -down-> SystemDesign
26-
sitemap -down-> Sitemap
2726
tutorials -down-> TutorialsandChallenges
2827
tutorials -down-> InteractiveLessons&Challenges
2928
tutorials -down-> WebDevelopmentTutorials

0 commit comments

Comments
 (0)