Skip to content

Commit

Permalink
fix: set the page language on the html element (#203)
Browse files Browse the repository at this point in the history
* fix: set the page language on the html element

Add a custom `_document.tsx` page layout and set `lang=en` on the root `<html>` element for each page.

* appease Prettier

* add a couple of tests and fix the language code
  • Loading branch information
eatyourgreens authored May 7, 2024
1 parent c588afa commit e2134c7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cypress/e2e/event-page.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ describe("event page admin", () => {
cy.visit("/event/1")
})

it("has page language", () => {
cy.get('html[lang="en-GB"]').should("exist")
})

it("has title", () => {
cy.contains('[data-cy="title"]', "Introduction to C++").should("be.visible")
})
Expand Down
4 changes: 4 additions & 0 deletions cypress/e2e/landing-page.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ describe("landing page", () => {
cy.contains("Course Events").should("be.visible")
})

it("has page language", () => {
cy.get('html[lang="en-GB"]').should("exist")
})

it("Create event button does not exist", () => {
cy.contains("Create new Event").should("not.exist")
})
Expand Down
13 changes: 13 additions & 0 deletions pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Html, Head, Main, NextScript } from "next/document"

export default function Document() {
return (
<Html lang="en-GB">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}

0 comments on commit e2134c7

Please sign in to comment.