add website with docs
This commit is contained in:
parent
870c20e745
commit
fcf1979a1d
12 changed files with 541 additions and 314 deletions
78
nix/website.nix
Normal file
78
nix/website.nix
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
{ pkgs, root }:
|
||||
pkgs.stdenv.mkDerivation {
|
||||
name = "grimu-r-website";
|
||||
|
||||
src = pkgs.lib.cleanSourceWith {
|
||||
src = root;
|
||||
filter = path: type:
|
||||
let
|
||||
baseName = baseNameOf path;
|
||||
relativePath = pkgs.lib.removePrefix (toString root + "/") (toString path);
|
||||
in
|
||||
baseName == "README.org" ||
|
||||
relativePath == "website" ||
|
||||
pkgs.lib.hasPrefix "website/" relativePath;
|
||||
};
|
||||
buildInputs = [ pkgs.pandoc ];
|
||||
|
||||
buildPhase = ''
|
||||
cp $src/website/pandoc-template.html ./
|
||||
mkdir -p ./html/doc
|
||||
cp $src/website/favicon.ico ./html/
|
||||
cp $src/website/llms.txt ./html/
|
||||
|
||||
if [ -d "$src/website/doc" ]; then
|
||||
echo '<nav class="sidebar"><ul>' > docs-nav.html
|
||||
|
||||
for file in $(find $src/website/doc -name "*.org" -type f | sort); do
|
||||
basename=$(basename "$file" .org)
|
||||
title=$(grep -m1 -i "^#+TITLE:" "$file" | sed 's/^#+TITLE:[[:space:]]*//I' || echo "$basename")
|
||||
echo "<li><a href=\"$basename.html\">$title</a></li>" >> docs-nav.html
|
||||
done
|
||||
|
||||
echo '</ul></nav>' >> docs-nav.html
|
||||
fi
|
||||
|
||||
if [ -d "$src/website/doc" ]; then
|
||||
for file in $src/website/doc/*.org; do
|
||||
basename=$(basename "$file" .org)
|
||||
pandoc \
|
||||
--template=./pandoc-template.html \
|
||||
--include-before-body=./docs-nav.html \
|
||||
--shift-heading-level-by=1 \
|
||||
--section-divs \
|
||||
-M document-css=false \
|
||||
"$file" \
|
||||
-o "./html/doc/$basename.html"
|
||||
done
|
||||
fi
|
||||
|
||||
pandoc \
|
||||
--template=./pandoc-template.html \
|
||||
--shift-heading-level-by=1 \
|
||||
--section-divs \
|
||||
-M document-css=false \
|
||||
$src/README.org \
|
||||
-o html/index.html
|
||||
|
||||
pandoc \
|
||||
--template=./pandoc-template.html \
|
||||
--shift-heading-level-by=1 \
|
||||
--section-divs \
|
||||
-M document-css=false \
|
||||
$src/website/pitch.org \
|
||||
-o html/pitch.html
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/html
|
||||
mkdir -p $out/bin
|
||||
cp -r ./html $out/
|
||||
|
||||
cat > $out/bin/grimu-r-website <<EOF
|
||||
#!/usr/bin/env bash
|
||||
${pkgs.python3}/bin/python3 -m http.server --directory "$out/html"
|
||||
EOF
|
||||
chmod +x $out/bin/grimu-r-website
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue