From ee038d844502091cc6b0748754b5975240b83964 Mon Sep 17 00:00:00 2001 From: Pierre Nicolas Durette Date: Sat, 13 Jan 2024 23:58:45 -0500 Subject: [PATCH 1/4] Add support for URL direct to root of domain (/) --- action.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index cbd7835..8c0a4b2 100644 --- a/action.yml +++ b/action.yml @@ -77,7 +77,10 @@ runs: # Sets permalink key to 404.html as per GitHub docs - shell: bash - if: startsWith(inputs.default_redirect, 'http') + id: url_redirect + if: | + startsWith(inputs.default_redirect, 'http') || + startsWith(inputs.default_redirect, '/') env: REDIRECT_URL: ${{ inputs.default_redirect }} run: | @@ -99,7 +102,7 @@ runs: # * Generate a plain 404.html with the message - shell: bash - if: "!startsWith(inputs.default_redirect, 'http')" + if: steps.url_redirect.conclusion == 'skipped' env: MESSAGE: ${{ inputs.default_redirect }} run: | From 387e9792328186bb8b4dc3c107e7ca89581de89b Mon Sep 17 00:00:00 2001 From: Pierre Nicolas Durette Date: Sun, 14 Jan 2024 00:04:45 -0500 Subject: [PATCH 2/4] Add temporary tests to check / redirect behaviour --- .github/workflows/test-reusable.yml | 2 ++ .github/workflows/test.yml | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/test-reusable.yml b/.github/workflows/test-reusable.yml index 8dad614..b20c8ff 100644 --- a/.github/workflows/test-reusable.yml +++ b/.github/workflows/test-reusable.yml @@ -46,6 +46,8 @@ jobs: run: tree -a _redirects - name: Show tree (_site) run: tree -a _site + - name: Show index.html + run: cat _site/index.html - name: Post-Run run: | ${{ inputs.post-run }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 15f0a58..fa08383 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,6 +49,14 @@ jobs: default_redirect: "http://www.d.com" post-run: bats ./tests/test_default_url.bats + test-default-redirect-url-root: + name: Default (Redirect URL, root) + uses: ./.github/workflows/test-reusable.yml + with: + urls_config: not_needed.yml + default_redirect: /some_root_path + post-run: echo + test-default-message: name: Default (Message) uses: ./.github/workflows/test-reusable.yml From 24eaacde96dbb0d842f1a3d657840b0ad0f097fc Mon Sep 17 00:00:00 2001 From: Pierre Nicolas Durette Date: Sun, 14 Jan 2024 00:29:22 -0500 Subject: [PATCH 3/4] Update docs for root level relative redirect --- README.md | 2 +- action.yml | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 85f8266..32cd7c1 100644 --- a/README.md +++ b/README.md @@ -171,7 +171,7 @@ The plugin will generate an HTML file per Collection document, with every possib ``` -Allowing it to be reached at `https:///link1`. It does the same for the `index.html` and `404.hml` (for `/` or non-existing path, respetively), which can also be redirects or plain strings (default is `Nothing here!`). +Allowing it to be reached at `https:///link1`. It does the same for the `index.html` and `404.hml` (for `/` or non-existing path, respetively), which can also be redirects (absolute or relative to the domain) or plain strings (default is `Nothing here!`). ### Action diff --git a/action.yml b/action.yml index 8c0a4b2..7cf6df6 100644 --- a/action.yml +++ b/action.yml @@ -20,8 +20,9 @@ inputs: default_redirect: description: | Default behaviour for `/` or any 404, can be either: - * a URL to redirect to - * a message to display + * a URL (absolute) to redirect to (e.g. `https://www.aol.com/`) + * a URL (relative) to redirect to from the domain (e.g. `/blog`) + * a message to display (e.g. `Nothing here!`) required: false default: "Nothing here!" From d7cd2c0c2fb18da2e5795d4848f66ad217545744 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 14 Jan 2024 05:29:41 +0000 Subject: [PATCH 4/4] GitHub Action Auto-Docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 32cd7c1..e72ccce 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ See [How it works](#how-it-works). |Input|Description|Default|Required| |-----|-----------|-------|:------:| |`urls_config`|

The path to a YAML file associating redirect keys to URLs, e.g.:

---
test1: https://www.bookcity.ca/
test2: https://www.gladdaybookshop.com
|`.github/urls.yml`|no| -|`default_redirect`|

Default behaviour for / or any 404, can be either:
* a URL to redirect to
* a message to display

|`Nothing here!`|no| +|`default_redirect`|

Default behaviour for / or any 404, can be either:
* a URL (absolute) to redirect to (e.g. https://www.aol.com/)
* a URL (relative) to redirect to from the domain (e.g. /blog)
* a message to display (e.g. Nothing here!)

|`Nothing here!`|no|