Created
June 8, 2020 10:44
-
-
Save flaki/6b66132c3ae4edb7eb3eed5c03b840f5 to your computer and use it in GitHub Desktop.
Host the docs of better-sqlite3 (npm) on a local nginx server for offline access
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
127.0.0.1 better-sqlite3.docs.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
# Address | |
server_name better-sqlite3.docs.local; | |
# looks like for autoindex to work root needs to be outside of the location | |
# https://forum.nginx.org/read.php?11,3810,83721#msg-83721 | |
root /usr/share/nginx/better-sqlite3-docs; | |
location / { | |
index index.html; | |
# enable directory indexes | |
# http://nginx.org/en/docs/http/ngx_http_autoindex_module.html | |
autoindex on; | |
# adds extensions for nice urls & directory indexes | |
# http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files | |
# need $uri/ for autoindexing | |
# https://serverfault.com/questions/491671/using-nginx-try-files-and-autoindex-together | |
try_files $uri $uri.html $uri/ =404; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This is a sparse checkout (http://scriptedonachip.com/git-sparse-checkout) | |
# of just the docs/ folder of https://github.com/JoshuaWise/better-sqlite3 | |
# get latest version of the docs | |
git pull --depth 2 origin master | |
# generate markdown | |
for file in ./docs/*.md; do | |
# https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion | |
outfile=${file/.md/.html} | |
outfile=${outfile/docs\//} | |
echo "Compiling $file -> $outfile..." | |
# create the html file from the markdown applying a specific stylesheet to all docs | |
npx -q --package markdown-to-html github-markdown --stylesheet "./.assets/stylesheet.css" "$file" > "$outfile" | |
# fix anchors | |
sed -i "s/<a id=\"user-content-/<a id=\"/g" "$outfile" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment