Skip to content

Fixed the PR_review issue #755

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

Merged
merged 6 commits into from
Jun 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions site/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,13 @@ execute:
quarto render --profile "$$PROFILE" "$$FILE_PATH"; \
rm $$env_file '

# Generate sitemap for the site
# Generate sitemap for the site
generate-sitemap:
$(eval BRANCH := $(shell git rev-parse --abbrev-ref HEAD))
$(eval BRANCH := $(if $(filter HEAD,$(BRANCH)),$(or $(GITHUB_HEAD_REF),$(GITHUB_REF_NAME)),$(BRANCH)))
$(eval BASE_URL := $(if $(filter main staging prod,$(BRANCH)),https://docs.validmind.ai,https://docs-demo.vm.validmind.ai))
$(eval PATH_PREFIX := $(if $(filter main staging prod,$(BRANCH)),,pr_previews/$(BRANCH)/))
@echo "Generating sitemaps ..."
@find _site -name "*.html" -not -path "*/internal/*" -not -path "*/site_libs/*" -not -path "*/sitemap.html/*" -not -path "*/training.html/*" | while read -r file; do \
url_path=$$(echo "$$file" | sed 's|^_site/||'); \
Expand All @@ -175,31 +180,29 @@ generate-sitemap:
else \
lastmod=$$(stat -c "%y" "$$file" | sed 's/ /T/;s/$$/Z/'); \
fi; \
printf " <url>\n <loc>https://docs-demo.vm.validmind.ai/pr_previews/$(GIT_BRANCH)/%s</loc>\n <lastmod>%s</lastmod>\n <changefreq>weekly</changefreq>\n <priority>0.8</priority>\n </url>\n" "$$url_path" "$$lastmod" >> sitemap.xml.tmp; \
printf " <url>\n <loc>$(BASE_URL)/$(PATH_PREFIX)%s</loc>\n <lastmod>%s</lastmod>\n <changefreq>weekly</changefreq>\n <priority>0.8</priority>\n </url>\n" "$$url_path" "$$lastmod" >> sitemap.xml.tmp; \
printf "%s\n" "$$url_path" >> sitemap.urls.tmp; \
done
@printf '<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n' > _site/sitemap.xml
@cat sitemap.xml.tmp >> _site/sitemap.xml
@printf '</urlset>\n' >> _site/sitemap.xml
@rm sitemap.xml.tmp
@printf '<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <title>ValidMind Documentation & Training Sitemap</title>\n <style>\n body { font-family: Arial, sans-serif; max-width: 1200px; margin: 0 auto; padding: 20px; }\n h1 { color: #333; }\n h2 { color: #444; margin-top: 30px; }\n ul { list-style: none; padding: 0; }\n li { margin: 10px 0; }\n a { color: #0066cc; text-decoration: none; }\n a:hover { text-decoration: underline; }\n .root-pages { margin-bottom: 30px; }\n </style>\n</head>\n<body>\n <div class="root-pages">\n <h2>Root Pages</h2>\n <ul>\n' > _site/sitemap.html
@# Deduplicate URLs before processing
@sort -u sitemap.urls.tmp > sitemap.urls.unique.tmp
@mv sitemap.urls.unique.tmp sitemap.urls.tmp
@grep -E '^(index|404)\.html$$' sitemap.urls.tmp | while read -r url; do \

@printf '<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <title>ValidMind Documentation & Training Sitemap</title>\n <style>\n body { font-family: Arial, sans-serif; max-width: 1200px; margin: 0 auto; padding: 20px; }\n h1 { color: #333; }\n h2 { color: #444; margin-top: 30px; }\n ul { list-style: none; padding: 0; }\n li { margin: 10px 0; }\n a { color: #0066cc; text-decoration: none; }\n a:hover { text-decoration: underline; }\n .root-pages { margin-bottom: 30px; }\n </style>\n</head>\n<body>\n <div class="root-pages">\n <h2>Root Pages</h2>\n <ul>\n' > _site/sitemap.html; \
sort -u sitemap.urls.tmp > sitemap.urls.unique.tmp && mv sitemap.urls.unique.tmp sitemap.urls.tmp; \
grep -E '^(index|404)\.html$$' sitemap.urls.tmp | while read -r url; do \
file="_site/$$url"; \
if [ -f "$$file" ] && grep -q '<title>' "$$file"; then \
title=$$(grep -m1 '<title>' "$$file" | sed 's/.*<title>\(.*\)<\/title>.*/\1/'); \
else \
title="$$url"; \
fi; \
if [ "$$title" != "Redirect" ]; then \
printf " <li><a href=\"https://docs-demo.vm.validmind.ai/pr_previews/$(GIT_BRANCH)/%s\">%s</a></li>\n" "$$url" "$$title" >> _site/sitemap.html; \
printf " <li><a href=\"$(BASE_URL)/$(PATH_PREFIX)%s\">%s</a></li>\n" "$$url" "$$title" >> _site/sitemap.html; \
fi; \
done
@printf ' </ul>\n </div>\n' >> _site/sitemap.html
@# Group remaining pages by top-level directory
@for dir in $$(grep -v -E '^(index|404)\.html$$' sitemap.urls.tmp | cut -d/ -f1 | grep -vE '\.(html|xml)$$' | sort -u); do \
done; \
printf ' </ul>\n </div>\n' >> _site/sitemap.html; \
for dir in $$(grep -v -E '^(index|404)\.html$$' sitemap.urls.tmp | cut -d/ -f1 | grep -vE '\.(html|xml)$$' | sort -u); do \
printf ' <h2>%s/</h2>\n <ul>\n' "$$dir" >> _site/sitemap.html; \
grep -E "^$$dir/[^/]+\.html$$" sitemap.urls.tmp | while read -r url; do \
file="_site/$$url"; \
Expand All @@ -209,7 +212,7 @@ generate-sitemap:
title="$$url"; \
fi; \
if [ "$$title" != "Redirect" ]; then \
printf " <li><a href=\"https://docs-demo.vm.validmind.ai/pr_previews/$(GIT_BRANCH)/%s\">%s</a></li>\n" "$$url" "$$title" >> _site/sitemap.html; \
printf " <li><a href=\"$(BASE_URL)/$(PATH_PREFIX)%s\">%s</a></li>\n" "$$url" "$$title" >> _site/sitemap.html; \
fi; \
done; \
for sub in $$(grep -E "^$$dir/" sitemap.urls.tmp | grep -o -E "^$$dir/[^/]+/" | sed "s|^$$dir/||;s|/||" | sort -u); do \
Expand All @@ -222,17 +225,19 @@ generate-sitemap:
title="$$url"; \
fi; \
if [ "$$title" != "Redirect" ]; then \
printf " <li><a href=\"https://docs-demo.vm.validmind.ai/pr_previews/$(GIT_BRANCH)/%s\">%s</a></li>\n" "$$url" "$$title" >> _site/sitemap.html; \
printf " <li><a href=\"$(BASE_URL)/$(PATH_PREFIX)%s\">%s</a></li>\n" "$$url" "$$title" >> _site/sitemap.html; \
fi; \
done; \
printf ' </ul>\n </li>\n' >> _site/sitemap.html; \
done; \
printf ' </ul>\n' >> _site/sitemap.html; \
done
@printf '</body>\n</html>\n' >> _site/sitemap.html
done; \
printf '</body>\n</html>\n' >> _site/sitemap.html
@rm sitemap.urls.tmp
@echo "Sitemaps generated at _site/sitemap.xml and _site/sitemap.html"



# Get all source files
get-source: clean clone copy-installation notebooks python-docs test-descriptions

Expand Down
Loading