|
| 1 | +<h1 align="center" width="100%"> |
| 2 | + <img src="https://raw.githubusercontent.com/surishortlink/suri/HEAD/logo.png" width="200" alt="Suri" /> |
| 3 | +</h1> |
| 4 | + |
| 5 | +<h3 align="center" width="100%"> |
| 6 | + <i>Your own short links as an easily deployed static site on GitHub Pages</i> |
| 7 | +</h3> |
| 8 | + |
| 9 | +You're viewing a template repository tailored for deploying Suri to |
| 10 | +[GitHub Pages](https://pages.github.com/) with |
| 11 | +[GitHub Actions](https://docs.github.com/en/actions). Head over to |
| 12 | +[the main repository](https://github.com/surishortlink/suri) to learn more about |
| 13 | +Suri, including additional deployment options. |
| 14 | + |
| 15 | +## Setup: Step By Step |
| 16 | + |
| 17 | +1. Hit the "Use this template" button above and then "Create a new repository". |
| 18 | + Fill in the required details to create a new repository based on this one. |
| 19 | +2. Go to the "Settings" of your new repository and head to the "Pages" section. |
| 20 | + Under "Build and deployment", change the "Source" to "GitHub Actions". |
| 21 | +3. Go to the "Actions" of your new repository. There should be a workflow run |
| 22 | + that likely failed because the previous step wasn't yet completed. Go ahead |
| 23 | + and view the workflow run and hit the "Re-run jobs" button. |
| 24 | + |
| 25 | +### Auto-Deploy |
| 26 | + |
| 27 | +Any commits to the `main` branch of your new repository will trigger a new build |
| 28 | +and deploy. You can change this by editing |
| 29 | +[`.github/workflows/deploy.yml`](.github/workflows/deploy.yml), which is the |
| 30 | +GitHub Actions workflow for building the site and deploying to GitHub Pages. |
| 31 | + |
| 32 | +### Custom Domain |
| 33 | + |
| 34 | +To use a custom domain, follow GitHub's guide: |
| 35 | +[Managing a custom domain for your GitHub Pages site](https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site). |
| 36 | + |
| 37 | +## How It Works |
| 38 | + |
| 39 | +### Manage Links |
| 40 | + |
| 41 | +At the heart of Suri is the [`links.json`](src/links.json) file, located in the |
| 42 | +`src` directory, where you manage your links. All of the template repositories |
| 43 | +include this file seeded with a few examples: |
| 44 | + |
| 45 | +```json |
| 46 | +{ |
| 47 | + "/": "https://www.youtube.com/watch?v=CsHiG-43Fzg", |
| 48 | + "1": "https://fee.org/articles/the-use-of-knowledge-in-society/", |
| 49 | + "gh": "https://github.com/surishortlink/suri" |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | +It couldn't be simpler: the key is the "short link" path that gets redirected, |
| 54 | +and the value is the target URL. Keys can be as short or as long as you want, |
| 55 | +using whatever mixture of characters you want. `/` is a special entry for |
| 56 | +redirecting the root path. |
| 57 | + |
| 58 | +### Build Static Site |
| 59 | + |
| 60 | +Suri ships with a `suri` executable file that generates the static site from the |
| 61 | +`links.json` file. The static site is output to a directory named `build`. |
| 62 | + |
| 63 | +All of the template repositories are configured with a `build` script that |
| 64 | +invokes this executable, making the command you run simple: |
| 65 | + |
| 66 | +```bash |
| 67 | +npm run build |
| 68 | +``` |
| 69 | + |
| 70 | +When you make a change to the `links.json` file, simply re-run this command to |
| 71 | +re-generate the static site, which can then be re-deployed. This template |
| 72 | +repository is configured to do this automatically. |
| 73 | + |
| 74 | +### Config |
| 75 | + |
| 76 | +Configuration is handled through the [`suri.config.json`](suri.config.json) file |
| 77 | +in the root directory. There is only one option at this point: |
| 78 | + |
| 79 | +| Option | Description | Type | Default | |
| 80 | +| ------ | ------------------------------------------------------------------ | ------- | ------- | |
| 81 | +| `js` | Whether to redirect with JavaScript instead of a `<meta>` refresh. | Boolean | `false` | |
| 82 | + |
| 83 | +### Public Directory |
| 84 | + |
| 85 | +Finally, any files in the `public` directory will be copied over to the `build` |
| 86 | +directory without modification when the static site is built. This can be useful |
| 87 | +for files like `favicon.ico` or `robots.txt` (that said, Suri provides sensible |
| 88 | +defaults for both). |
0 commit comments