Giter Club home page Giter Club logo

Comments (5)

Fryuni avatar Fryuni commented on June 2, 2024

Can someone add the lowest of all low priorities labels for this pls. I almost didn't open the issue because it is working for every page and every language transition except the 404 page switching to English. As minor a bug as it can get.

But its funny, so...

from docs.

sarah11918 avatar sarah11918 commented on June 2, 2024

I've updated the title here because when we migrated to Vercel, we had to do some customization to even get our 404 page to work. So, I'm quite sure this is less of a "language selector" issue and more a 404 page issue. It might not be possible to improve the behaviour, but @delucis would know!

from docs.

Fryuni avatar Fryuni commented on June 2, 2024

It works on Starlight's own that is also deployed to Vercel and uses the same URL patterns for the locales. So it doesn't seem like a platform limitation.

Maybe something that differs on the overrides here?

from docs.

delucis avatar delucis commented on June 2, 2024

Yeah, the docs version does something a bit different for multilingual 404s to work around Vercel’s lack of support for multiple 404 pages. Starlight does this with some “fun” config in vercel.json to support actually serving each language’s 404.html but that approach was not viable in docs with so many redirects needed, so we just always serve the English page and switch out the main content.

The issue is that the language picker listens for a change event, but in this case nothing is changing. Could perhaps be addressed upstream by just running the redirect logic any time an option is chosen even if it is currently selected? I honestly don’t even know if that’s reliably possible (i.e. the distinction between a) user opens the picker then clicks away and b) user opens the picker then clicks the current item).

Or alternatively, the docs 404 could maybe just do this:

document.querySelector('starlight-lang-select select').value = `/${lang}/404/`;

That could be the simplest fix given this is a pretty rare use case.

from docs.

mingjunlu avatar mingjunlu commented on June 2, 2024

Hey friends,

Inspired by @delucis' code snippet, I came up with a possible solution to this issue:

  1. Add a <script> to docs 404 page
  2. Check if current language in URL matches any option in the language selector
  3. If there's a match, apply the option's value to the language selector

Expected results:

  • Allow the user to switch to English 404 page
  • Resolve inconsistent displayed languages (main content of 404 vs language selector on the top right)

I've created a pull request. Would love to hear your feedback 🙂

from docs.

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.