@@ -40,56 +40,46 @@ jobs:
4040 for tag in $(git tag --list 'v*' --sort=-version:refname); do
4141 echo "Building docs for $tag"
4242 git checkout "$tag" -- docs/ solr/ 2>/dev/null || continue
43- version_dir="_site/${tag}"
44- mkdir -p "$version_dir"
45- sphinx-build -b html docs "$version_dir" 2>/dev/null || echo " Skipped $tag (build failed)"
43+ mkdir -p "_site/${tag}"
44+ sphinx-build -b html docs "_site/${tag}" 2>/dev/null || echo " Skipped $tag (build failed)"
4645 git checkout master -- docs/ solr/ 2>/dev/null
4746 done
4847
49- - name : Generate version index page
48+ - name : Generate versions.json
5049 run : |
5150 LATEST_TAG=$(git tag --list 'v*' --sort=-version:refname | head -1)
52- cat > _site/index.html << 'HEADER'
53- <!DOCTYPE html>
54- <html>
55- <head>
56- <meta charset="utf-8">
57- <title>solrpy Documentation</title>
58- <style>
59- body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; max-width: 700px; margin: 60px auto; padding: 0 20px; color: #333; }
60- h1 { border-bottom: 2px solid #2980b9; padding-bottom: 10px; }
61- a { color: #2980b9; text-decoration: none; }
62- a:hover { text-decoration: underline; }
63- ul { list-style: none; padding: 0; }
64- li { padding: 8px 0; border-bottom: 1px solid #eee; }
65- .latest { font-weight: bold; }
66- .badge { background: #2980b9; color: #fff; padding: 2px 8px; border-radius: 4px; font-size: 0.8em; margin-left: 8px; }
67- </style>
68- </head>
69- <body>
70- <h1>solrpy Documentation</h1>
71- <p><a href="latest/">Latest (master)</a></p>
72- <h2>Versions</h2>
73- <ul>
74- HEADER
75-
51+ echo '[' > _site/versions.json
52+ echo " {\"version\": \"latest\", \"label\": \"latest (master)\", \"path\": \"latest\"}," >> _site/versions.json
53+ first=true
7654 for tag in $(git tag --list 'v*' --sort=-version:refname); do
7755 if [ -d "_site/${tag}" ]; then
78- badge=" "
56+ label="${tag} "
7957 if [ "$tag" = "$LATEST_TAG" ]; then
80- badge='<span class="badge">latest release</span>'
58+ label="${tag} (stable)"
59+ fi
60+ if [ "$first" = true ]; then
61+ first=false
62+ else
63+ echo "," >> _site/versions.json
8164 fi
82- echo " <li><a href=\"${tag}/\">${ tag}</a>${badge}</li>" >> _site/index.html
65+ printf " {\"version\": \"%s\", \"label\": \"%s\", \"path\": \"%s\"}" "$ tag" "$label" "$tag" >> _site/versions.json
8366 fi
8467 done
68+ echo "" >> _site/versions.json
69+ echo ']' >> _site/versions.json
8570
86- cat >> _site/index.html << 'FOOTER'
87- </ul>
88- <hr>
89- <p><a href="https://github.com/search5/solrpy">GitHub</a> · <a href="https://pypi.org/project/solrpy/">PyPI</a></p>
90- </body>
71+ - name : Generate root redirect
72+ run : |
73+ cat > _site/index.html << 'EOF'
74+ <!DOCTYPE html>
75+ <html>
76+ <head>
77+ <meta http-equiv="refresh" content="0; url=latest/">
78+ <link rel="canonical" href="latest/">
79+ </head>
80+ <body><a href="latest/">Redirecting to latest documentation...</a></body>
9181 </html>
92- FOOTER
82+ EOF
9383
9484 - name : Upload artifact
9585 uses : actions/upload-pages-artifact@v3
0 commit comments