Skip to content

Instantly share code, notes, and snippets.

@DrI-T
Last active July 14, 2022 18:45
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 DrI-T/2ef8290e4b6ad674070aa33f6bbf460b to your computer and use it in GitHub Desktop.
Save DrI-T/2ef8290e4b6ad674070aa33f6bbf460b to your computer and use it in GitHub Desktop.
simply hostless site

This is a way to redirect a domain name the IPFS version of the site

<!DOCTYPE html><meta charset=utf8>
You are about to be redirected to a hostless website on the IPFS network.
site: <a href=""><a>
<script>
const gateway='https://ipfs.safewatch.care'
const webkey='QmYwyK9VMxBKm1STUQ9jbYVz3ymAa4ULVLwpx8oHvSKAG2' // website IPNS key
let url;
let hostname=location.hostname.replace('www\.','');
// ipfs ls /ipns/QmYwyK9VMxBKm1STUQ9jbYVz3ymAa4ULVLwpx8oHvSKAG2
if (m = hostname.match(/^(\d+)/)) {
url=`${gateway}/ipns/${webkey}/${m[1]}`
} else if (hostname != 'localhost' && hostname != '127.0.0.1' && ! hostname.match(/(?:netlify|bl.ocks)/)) {
url=`${gateway}/ipns/${hostname}/`
} else {
url=`${gateway}/ipns/wbly.ml/`
}
let el = document.getElementsByTagName('a')[0];
el.href=url; el.innerText = url;
console.log('url:',url);
//location.href=url;
</script>
#
site=${PWD##*/}
if ! which netlify >/dev/null; then
npm install -g npm@8.14.0
npm install netlify-cli -g
fi
if [ ! -e $HOME/.config/netlify/config.json ]; then
netlify login
less $HOME/.config/netlify/config.json
fi
# read also: https://docs.netlify.com/cli/get-started/
#netlify init
if [ ! -e .netlify/state.json ]; then
netlify link
less .netlify/state.json
fi
netlify deploy --prod --dir . --message "date +%y-%m-%d $site"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment