Skip to content

Instantly share code, notes, and snippets.

@lee2sman
Last active August 14, 2025 01:01
Show Gist options
  • Save lee2sman/3afa82cb75b962877de2f7c7aa96efe4 to your computer and use it in GitHub Desktop.
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.
#!/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