Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Possibility to add a e.g. banner when user has been redirected #198

Closed
BrunnerLivio opened this issue Oct 19, 2021 · 1 comment
Closed

Comments

@BrunnerLivio
Copy link

BrunnerLivio commented Oct 19, 2021

I'd like to notify the user when a redirect has happened. A good way for me would be to e.g. specify a query parameter to the new URL.

So as an example:

---
redirect_from:
  - url: /old-page/
    queryParams:
       - message: "This page has been updated"
---

So if the user requests example.com/old-page it should direct to example.com/new-page?message=This page has been updated

In addition it would be awesome to specify this query parameter setting globally in the plugin config:

Option a) Straight-forward:

{
  "plugins": [
     {
        resolve: 'gatsby-redirect-from',
        options: {
           defaultQueryParams: {
             message: "This page has been updated"
           }
        }
      },
  ]
}

Option b) More dynamic:

{
  "plugins": [
     {
        resolve: 'gatsby-redirect-from',
        options: {
           onRedirect: (from, to) => `${to}?message=${encodeURIComponent('Update your bookmark from ' + from)}`
        }
      },
  ]
}
@BrunnerLivio
Copy link
Author

Let me know if you'd be open for contributions. In my eyes seems to be an easy feature to implement judging your source code :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants