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

Fix the lang attribute of the <html> tag generated by SSG #399

Merged
merged 1 commit into from
Sep 18, 2021
Merged

Fix the lang attribute of the <html> tag generated by SSG #399

merged 1 commit into from
Sep 18, 2021

Conversation

calmery
Copy link
Contributor

@calmery calmery commented Sep 18, 2021

Regardless of the i18n.locales option in aleph.config.ts, all language generation results using SSG use defaultLocale for the lang attribute of <html> tag. The cause of this problem is that the URL received by the _createRouter function does not have a / at the beginning, which does not work as expected. (framework/core/routing.ts#L139-L146)

// examples/hello-world-i18n/aleph.config.ts
import type { Config } from 'aleph/types'

export default (): Config => ({
  ssr: true, // This problem only occurs when the `ssr` option is `true`.
  i18n: {
    defaultLocale: 'en',
    locales: ['en', 'zh']
  }
})
$ ALEPH_DEV=true deno run -A --unstable --location=http://localhost cli.ts build ./examples/hello-world-i18n -L debug

Before the change.

<!-- examples/hello-world-i18n/dist/index.html -->
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8" />...</html>
<!-- examples/hello-world-i18n/dist/zh/index.html -->
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8" />...</html>

After the change.

<!-- examples/hello-world-i18n/dist/index.html -->
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8" />...</html>
<!-- examples/hello-world-i18n/dist/zh/index.html -->
<!DOCTYPE html><html lang="zh"><head><meta charSet="utf-8" />...</html>

@calmery calmery requested a review from ije as a code owner September 18, 2021 07:48
@ije
Copy link
Member

ije commented Sep 18, 2021

lgtm, super! thanks @calmery

@ije ije merged commit 6f0c611 into alephjs:master Sep 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants