docs(site): publish website at repo root with /docs compatibility and clean deploy (#2402)

This commit is contained in:
Copilot
2026-05-05 14:26:30 +00:00
committed by GitHub
parent 399c4554f0
commit 5733e5d28e
5 changed files with 40 additions and 22 deletions
+36 -18
View File
@@ -98,25 +98,43 @@ jobs:
git fetch origin gh-pages
git reset --hard origin/gh-pages
rm -rf docs
mv ../site docs
# Preserve API reference folders generated by the `build` job
# (for example `master/`, `vX.Y.Z/`), while fully replacing
# the mkdocs website content at the root.
api_doc_dirs=()
for dir in */; do
if [ -f "${dir}libp2p.html" ]; then
api_doc_dirs+=("${dir%/}")
fi
done
# Create a root index.html that redirects to /docs/ so that
# https://vacp2p.github.io/nim-libp2p/ does not return 404
cat > index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url=docs/">
<link rel="canonical" href="docs/">
<title>nim-libp2p</title>
</head>
<body>
<p>Redirecting to <a href="docs/">documentation</a>...</p>
</body>
</html>
EOF
shopt -s dotglob nullglob
for path in ./*; do
base=${path#./}
if [ "$base" = ".git" ]; then
continue
fi
keep=false
for dir in "${api_doc_dirs[@]}"; do
if [ "$base" = "$dir" ]; then
keep=true
break
fi
done
if [ "$keep" = false ]; then
rm -rf "$path"
fi
done
shopt -u dotglob nullglob
cp -a ../site/. .
# Maintain backward compatibility for `/docs/...` links.
rm -rf docs
mkdir -p docs
cp -a ../site/. docs/
git add .
+1 -1
View File
@@ -40,7 +40,7 @@ The currently supported Nim versions are v2.2.4 and v2.2.10.
nimble install libp2p
```
You'll find the nim-libp2p documentation [here](https://vacp2p.github.io/nim-libp2p/docs/). See [examples](./examples) for simple usage patterns.
You'll find the nim-libp2p documentation [here](https://vacp2p.github.io/nim-libp2p/). See [examples](./examples) for simple usage patterns.
## Development
+1 -1
View File
@@ -1,5 +1,5 @@
# nim-libp2p examples
In this folder, you'll find the sources of the [nim-libp2p website](https://vacp2p.github.io/nim-libp2p/docs/)
In this folder, you'll find the sources of the [nim-libp2p website](https://vacp2p.github.io/nim-libp2p/)
We recommand to follow the tutorials on the website, but feel free to grok the sources here!
+1 -1
View File
@@ -4,7 +4,7 @@
when defined(nimdoc):
## Welcome to the nim-libp2p reference!
##
## If you're new to nim-libp2p, you can find a tutorial `here<https://vacp2p.github.io/nim-libp2p/docs/tutorial_1_connect/>`_
## If you're new to nim-libp2p, you can find a tutorial `here<https://vacp2p.github.io/nim-libp2p/tutorial_1_connect/>`_
## that can help you get started.
# Import stuff for doc
+1 -1
View File
@@ -2,7 +2,7 @@ site_name: nim-libp2p
repo_url: https://github.com/vacp2p/nim-libp2p
repo_name: vacp2p/nim-libp2p
site_url: https://vacp2p.github.io/nim-libp2p/docs
site_url: https://vacp2p.github.io/nim-libp2p/
# Can't find a way to point the edit to the .nim instead
# of the .md
edit_uri: ''