Skip to content

Instantly share code, notes, and snippets.

@VimalMollyn
Last active November 10, 2022 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VimalMollyn/73c61521f34dce0ffbd2952cad084f60 to your computer and use it in GitHub Desktop.
Save VimalMollyn/73c61521f34dce0ffbd2952cad084f60 to your computer and use it in GitHub Desktop.
Ghost static site generator
function make_website --description "Recreated my website"
set hostServer $argv[1]
set hostURL (string split "http://" $hostServer)[2]
set websiteDir $argv[2]
set domainName $argv[3]
set currDir (pwd)
cd $websiteDir
# delete all files except the .git
find . ! -name '*.git*' -type d -exec rm -f {} +
# populate the websiteDir
wget -r -nH -P . -E -np -k --base=$hostServer $hostServer
wget -r -nH -P . -E -np $hostServer/sitemap.xsl
wget -r -nH -P . -E -np $hostServer/sitemap.xml
wget -r -nH -P . -E -np $hostServer/sitemap-pages.xml
wget -r -nH -P . -E -np $hostServer/sitemap-posts.xml
wget -r -nH -P . -E -np $hostServer/sitemap-authors.xml
wget -r -nH -P . -E -np $hostServer/sitemap-tags.xml
echo "Sed is doing it's magic :D"
LC_ALL=C find . -type f -not -wholename '*.git*' -exec sed -i '' -e "s,/index.html,/,g" {} +
LC_ALL=C find . -type f -not -wholename '*.git*' -exec sed -i '' -e "s,index.html,/,g" {} +
LC_ALL=C find . -type f -not -wholename '*.git*' -exec sed -i '' -e "s,$hostServer,$domainName,g" {} +
LC_ALL=C find . -type f -not -wholename '*.git*' -exec sed -i '' -e "s,$hostURL,$domainName,g" {} +
# add a CNAME file
echo $domainName > CNAME
cd $currDir
end
@VimalMollyn
Copy link
Author

VimalMollyn commented Nov 10, 2022

Usage:

$ make_website http://localhost:2368 vimalmollyn.github.io vimal-mollyn.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment