Skip to content

Commit

Permalink
Add option to redirect with JS instead of <meta>
Browse files Browse the repository at this point in the history
  • Loading branch information
jstayton committed Nov 24, 2020
1 parent 041589d commit e21ea49
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ _Pro tip_: Bookmark the page to
(or wherever), and use the default commit message that's populated. Now show me
a link shortener that's easier than that!

### Config

Environment variables are used to set config options. There is only one at this
point:

| Variable | Description | Values | Default |
| --------- | ------------------------------------------------------------------ | -------- | ------- |
| `SURI_JS` | Whether to redirect with JavaScript instead of a `<meta>` refresh. | `1`, `0` | `0` |

### Install Manually

To install Suri somewhere else, or just on your own machine:
Expand Down
3 changes: 3 additions & 0 deletions src/env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
js: process.env.SURI_JS === '1',
}
7 changes: 6 additions & 1 deletion src/links.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ pagination:
permalink: "{{ link }}/"
---

<!DOCTYPE html><meta http-equiv=refresh content="0; url={{ links[link] }}">
<!DOCTYPE html>
{% if env.js -%}
<script>window.location.replace('{{ links[link] }}')</script>
{% else -%}
<meta http-equiv=refresh content="0; url={{ links[link] }}">
{% endif -%}

0 comments on commit e21ea49

Please sign in to comment.