GithubHelp home page GithubHelp logo

Comments (13)

harshmaur avatar harshmaur commented on July 19, 2024

Can you give the old url and the new url? I will create a 301 redirect middleware.

from styled-components-website.

kitten avatar kitten commented on July 19, 2024

I'd go for a 302 (hope that's the right code?) instead of a 301 to not have a permanent redirection in place.

The URL in question is: https://www.styled-components.com/docs/advanced#babel-plugin
It now lives at: https://www.styled-components.com/docs/tooling#babel-plugin

It'd be great to define these rules here: https://github.com/styled-components/styled-components-website/blob/master/pages/docs.json

Under a new key, like movedPages

from styled-components-website.

harshmaur avatar harshmaur commented on July 19, 2024

Why do you want a 302? Is it a temporary change? The browser would work fine though, Google however would not record the change and will always follow the old url in this case.

from styled-components-website.

kitten avatar kitten commented on July 19, 2024

@harshmaur

Google however would not record the change and will always follow the old url in this case.

Oh that's unfortunate

Why do you want a 302? Is it a temporary change?

I think a simple 301 won't pick up on the hash/anchor part of the URL, right? I might be mistaken. Either way, I'd like to be careful about permanent, cached redirections that make it impossible to undo anything.

from styled-components-website.

harshmaur avatar harshmaur commented on July 19, 2024

Hash/Anchor arent picked up by the server IMO, they are only browser based, I tried to get the hash, I could not get it in the request

Check this https://stackoverflow.com/questions/9967681/nodejs-url-with-hash

So basically this has to be picked up on the frontend and redirection should happen which again is not a good way. Please suggest.

from styled-components-website.

kitten avatar kitten commented on July 19, 2024

So basically this has to be picked up on the frontend and redirection should happen which again is not a good way. Please suggest.

We can add a componentDidMount to our document and detect whether a redirect is necessary here: https://github.com/styled-components/styled-components-website/blob/master/pages/_document.js

from styled-components-website.

harshmaur avatar harshmaur commented on July 19, 2024

Won't work. document.js only executes server side.

from styled-components-website.

kitten avatar kitten commented on July 19, 2024

@harshmaur we can actually use the API to inject an HOC around the app and detect it there. It’s currently non-standard I.e. not released on next yet, but we’ve got it in our censored version to make styling ssr work

from styled-components-website.

harshmaur avatar harshmaur commented on July 19, 2024

I am not aware, Could you explain more? I would then be able to do it. Also redirection on the frontend is not that pretty with nextjs. https://github.com/zeit/next.js/wiki/Redirecting-in-%60getInitialProps%60

from styled-components-website.

kitten avatar kitten commented on July 19, 2024

@harshmaur here we’re wrapping the app in our StyleSheetManager. You can just create another Redirect component that wraps it as well and use and add the redirect logic to componentDidMount

https://github.com/styled-components/styled-components-website/blob/master/pages/_document.js#L150

from styled-components-website.

harshmaur avatar harshmaur commented on July 19, 2024

I see!! Let me try to do it now.

from styled-components-website.

mckernanin avatar mckernanin commented on July 19, 2024

@harshmaur need any help here?

from styled-components-website.

harshmaur avatar harshmaur commented on July 19, 2024

@mckernanin Hey! You can take this up!

from styled-components-website.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.