Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homepage is broken with JavaScript disabled #4

Open
JustAnotherArchivist opened this issue Jul 20, 2023 · 7 comments
Open

Homepage is broken with JavaScript disabled #4

JustAnotherArchivist opened this issue Jul 20, 2023 · 7 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@JustAnotherArchivist
Copy link

JustAnotherArchivist commented Jul 20, 2023

Since the homepage uses JavaScript to jump to the introduction page, it just stays blank when scripting is disabled.

Possible solutions:

  • The proper solution would be using an HTTP 3xx redirect.
  • A <noscript> tag with a meta refresh could be used, but this would reintroduce Fix broken back button on Firefox #3 for script-disabled users, I believe.
@taoeffect
Copy link
Member

If there's a way to address this while still automatically switching to the correct local language, please let us know!

@taoeffect
Copy link
Member

Oh - I guess we could default to English and introduce some sort of a language switching menu thing. 🤔

@JustAnotherArchivist
Copy link
Author

I'm unfortunately not familiar with the framework you're using. This suggests it should be possible though.

@JustAnotherArchivist
Copy link
Author

Oh - I guess we could default to English and introduce some sort of a language switching menu thing.

I suppose you could, but respecting the Accept-Language header would be much better.

@taoeffect taoeffect added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Jul 20, 2023
@taoeffect
Copy link
Member

taoeffect commented Jul 20, 2023

Ah - Maybe we could just introduce a <noscript> section to index.astro that includes a link to the various languages that we support. I think that might work. (PRs accepted for that!)

@JustAnotherArchivist
Copy link
Author

Perhaps index.astro could simply be this?

---
return Astro.redirect('/en/introduction/');

(And perhaps another --- at the end, don't quite understand how that works from a glance at the docs.)

Once other languages are supported, it'd simply be a matter of replacing the hardcoded URL with something derived from Accept-Language or whichever other data source you may want to use for that.

@taoeffect
Copy link
Member

taoeffect commented Jul 20, 2023

No that results in an error:

Astro.redirect is not available in static mode.

This is the closest I've been able to get to something reasonable:

---
import MainLayout from '../layouts/MainLayout.astro'
---

<MainLayout>
  <script is:inline>
    // Redirect your homepage to the first page of documentation.
    // If you have a landing page, remove this script and add it here!
    // window.location.pathname = '/en/introduction';
    window.location.replace('/en/introduction')
  </script>
  <noscript>
    JavaScript disabled.

    Please <a href="/en/introduction">click here</a> to manually redirect to English introduction.
  </noscript>
</MainLayout>

However, the "click here" link isn't visible for some reason because of the <a> tag and I have no idea why. Suggestions and PRs welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants