Skip to content

Commit

Permalink
Add h1 on every page
Browse files Browse the repository at this point in the history
  • Loading branch information
lasseklovstad committed Mar 22, 2024
1 parent ed1a302 commit 577f07b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/components/PageLayout/PageLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import styles from "./PageLayout.module.css";

type Props = {
pageTitle: string;
content: React.ReactNode;
rightContent?: React.ReactNode;
};
export function PageLayout({ content, rightContent }: Props) {
export function PageLayout({ content, rightContent, pageTitle }: Props) {
return (
<main className={styles.container}>
<h1 className="sr-only">{pageTitle}</h1>
<article>{content}</article>
{rightContent ? <aside>{rightContent}</aside> : null}
</main>
Expand Down
12 changes: 12 additions & 0 deletions app/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ body {
padding: 0;
}

.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}

h1,
h2,
h3,
Expand Down
5 changes: 4 additions & 1 deletion app/routes/$pageSlug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ export default function Page() {
const { page } = useLoaderData<typeof clientLoader>();

if (page === null) {
return <PageLayout content={<NotFound />} />;
return (
<PageLayout pageTitle="Det oppstod en feil" content={<NotFound />} />
);
}

return (
<PageLayout
pageTitle={page.title}
content={<PortableText value={page.content} components={components} />}
rightContent={
page.sideContent ? (
Expand Down

0 comments on commit 577f07b

Please sign in to comment.