This is a way to redirect a domain name the IPFS version of the site
Last active
July 14, 2022 18:45
-
-
Save DrI-T/2ef8290e4b6ad674070aa33f6bbf460b to your computer and use it in GitHub Desktop.
simply hostless site
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
<!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> |
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
# | |
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