├── .gitignore ├── LICENSE ├── README.md ├── components └── nav.js ├── next.config.js ├── package.json ├── pages ├── _document.js ├── about.js ├── deep │ └── p.js └── index.js ├── public ├── example.png └── favicon.ico └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | .env* 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Dmitry 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Deploying Next.js site to IPFS 2 | 3 | 1. Inject `` into `` at runtime: 4 | 5 | ```jsx 6 | // ./pages/_document.js 7 | import Document, { Html, Head, Main, NextScript } from 'next/document' 8 | 9 | const scriptTxt = ` 10 | (function () { 11 | const { pathname } = window.location 12 | const ipfsMatch = /.*\\/Qm\\w{44}\\//.exec(pathname) 13 | const base = document.createElement('base') 14 | 15 | base.href = ipfsMatch ? ipfsMatch[0] : '/' 16 | document.head.append(base) 17 | })(); 18 | ` 19 | 20 | class MyDocument extends Document { 21 | 22 | render() { 23 | return ( 24 | 25 | 26 |