Skip to content

Commit fafa067

Browse files
committed
add sitemap generation
1 parent 7331c13 commit fafa067

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
BayesBase = "b4ee3484-f114-42fe-b91c-797d54a0c67e"
33
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
44
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
5+
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
56
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
67
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
78
DocumenterMermaid = "a078cd44-4d9c-4618-b545-3ab9d77f9177"

docs/make.jl

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using RxInfer
22
using Documenter
33
using DocumenterMermaid
4+
using Dates
45

56
## https://discourse.julialang.org/t/generation-of-documentation-fails-qt-qpa-xcb-could-not-connect-to-display/60988
67
## https://gr-framework.org/workstations.html#no-output
@@ -64,4 +65,85 @@ makedocs(;
6465
]
6566
)
6667

68+
# Function to inject keywords meta tag into HTML files
69+
function inject_keywords_meta()
70+
# Define keywords for the documentation
71+
keywords = "Julia, Bayesian inference, factor graph, message passing, probabilistic programming, reactive programming, RxInfer"
72+
base_url = "https://reactivebayes.github.io/RxInfer.jl/stable"
73+
74+
# Meta tags to inject
75+
meta_tags = """
76+
<meta name="keywords" content="$(keywords)">
77+
<link rel="sitemap" type="application/xml" title="Sitemap" href="$(base_url)/sitemap.xml">"""
78+
79+
# List of files to exclude
80+
exclude_files = ["googlef2b9004e34bc8cf4.html"]
81+
82+
# Process all HTML files in the build directory
83+
for (root, _, files) in walkdir("docs/build")
84+
for file in files
85+
if endswith(file, ".html") && !(file in exclude_files)
86+
filepath = joinpath(root, file)
87+
content = read(filepath, String)
88+
89+
# Insert meta tags before </head>
90+
new_content = replace(content, r"</head>" => meta_tags * "</head>")
91+
92+
# Write the modified content back
93+
write(filepath, new_content)
94+
end
95+
end
96+
end
97+
end
98+
99+
# Function to generate sitemap.xml
100+
function generate_sitemap()
101+
base_url = "https://reactivebayes.github.io/RxInfer.jl"
102+
sitemap_content = """<?xml version="1.0" encoding="UTF-8"?>
103+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">"""
104+
105+
# List of files to exclude
106+
exclude_files = ["googlef2b9004e34bc8cf4.html", "404.html", "search_index.js"]
107+
108+
# Current date in W3C format
109+
current_date = Dates.format(Dates.now(), "yyyy-mm-dd")
110+
111+
# Process all HTML files in the build directory
112+
for (root, _, files) in walkdir("docs/build")
113+
for file in files
114+
if endswith(file, ".html") && !(file in exclude_files)
115+
# Get relative path from build directory
116+
rel_path = relpath(joinpath(root, file), "docs/build")
117+
# Convert Windows path separators if present
118+
url_path = replace(rel_path, '\\' => '/')
119+
# Remove index.html from the end if present
120+
url_path = replace(url_path, r"/index.html$" => "/")
121+
# Remove .html from the end of all other files
122+
url_path = replace(url_path, r"\.html$" => "")
123+
124+
# Construct full URL
125+
full_url = string(base_url, "/", url_path)
126+
127+
# Add URL entry to sitemap
128+
sitemap_content *= """
129+
<url>
130+
<loc>$(full_url)</loc>
131+
<lastmod>$(current_date)</lastmod>
132+
<changefreq>weekly</changefreq>
133+
<priority>0.8</priority>
134+
</url>"""
135+
end
136+
end
137+
end
138+
139+
sitemap_content *= "\n</urlset>"
140+
141+
# Write sitemap to the build directory
142+
write("docs/build/sitemap.xml", sitemap_content)
143+
end
144+
145+
# Call the functions after makedocs
146+
inject_keywords_meta()
147+
generate_sitemap()
148+
67149
deploydocs(; repo = "github.com/ReactiveBayes/RxInfer.jl", devbranch = "main", forcepush = true)

0 commit comments

Comments
 (0)