Last active
August 14, 2025 01:01
-
-
Save lee2sman/3afa82cb75b962877de2f7c7aa96efe4 to your computer and use it in GitHub Desktop.
A fish function to automatically detect which static site server i'm in and run the correct build/serve command.
This file contains hidden or 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
#!/usr/bin/env fish | |
function blog-serve | |
set current_dir (basename (pwd)) | |
# Directory-specific detection | |
switch $current_dir | |
case nosebook | |
echo "πΈ Detected Jekyll blog (nosebook)" | |
bundle exec jekyll serve --baseurl '' | |
case L5-website | |
echo "π Detected MkDocs site (L5-website)" | |
mkdocs serve | |
case compost.party | |
echo "π Detected Eleventy site (compost.party)" | |
npm run dev | |
case '*' | |
# Fall back to file-based detection | |
if test -f build.sh | |
echo "π Detected Panblog site (has build.sh)" | |
./build.sh | |
cd docs | |
live-server | |
else if test -f _config.yml | |
echo "πΈ Detected Jekyll blog (_config.yml found)" | |
bundle exec jekyll serve --baseurl '' | |
else if test -f mkdocs.yml | |
echo "π Detected MkDocs site (mkdocs.yml found)" | |
mkdocs serve | |
else if test -f .eleventy.js; or test -f eleventy.config.js; or test -f package.json -a (grep -q '"@11ty/' package.json 2>/dev/null) | |
echo "β‘ Detected Eleventy site" | |
npm run dev | |
else if test -f index.html | |
echo "π Detected static site (index.html found)" | |
live-server | |
else | |
echo "β Could not detect blog type in current directory: $current_dir" | |
echo "Supported types:" | |
echo " - Jekyll (nosebook directory or _config.yml)" | |
echo " - MkDocs (L5-website directory or mkdocs.yml)" | |
echo " - Panblog (build.sh file)" | |
echo " - Eleventy (compost.party directory or .eleventy.js/eleventy.config.js)" | |
echo " - Static site (index.html file)" | |
return 1 | |
end | |
end | |
end | |
# Run the function | |
blog-serve |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment