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

SFR-1799/1800: Update page titles for accessibility #454

Merged
merged 4 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Feedback button test PW
- SFR-1797: Remove Playwright tests with clicks on header and footer links
- Update README with C4 diagrams and epub-to-webpub info
- Update Collection, Edition, and Work page titles for accessibility

## [0.17.4]

Expand Down
2 changes: 1 addition & 1 deletion src/constants/labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const documentTitles = {
home: "Digital Research Books Beta | NYPL",
advancedSearch: "Advanced Search | Digital Research Books Beta | NYPL",
search: "Search Results | Digital Research Books Beta | NYPL",
workItem: "Item Details | Digital Research Books Beta | NYPL",
workItem: "Work Details | Digital Research Books Beta | NYPL",
editionItem: "Edition Details | Digital Research Books Beta | NYPL",
readItem: "Read Online | Digital Research Books Beta | NYPL",
collection: "Collection | Digital Research Books Beta | NYPL",
Expand Down
14 changes: 14 additions & 0 deletions src/pages/collection/[collectionId].tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { GetServerSideProps } from "next";
import Head from "next/head";
import React from "react";
import Collection from "~/src/components/Collection/Collection";

import Layout from "~/src/components/Layout/Layout";
import { MAX_TITLE_LENGTH } from "~/src/constants/editioncard";
import { documentTitles } from "~/src/constants/labels";
import { collectionFetcher } from "~/src/lib/api/CollectionApi";
import { CollectionQuery, CollectionResult } from "~/src/types/CollectionQuery";
import { truncateStringOnWhitespace } from "~/src/util/Util";

export const getServerSideProps: GetServerSideProps = async (context) => {
const collectionQuery: CollectionQuery = {
Expand All @@ -31,6 +35,16 @@ const CollectionResults: React.FC<{
}> = ({ collectionResult, collectionQuery }) => {
return (
<Layout>
<Head>
<title>
{truncateStringOnWhitespace(
collectionResult.metadata.title,
MAX_TITLE_LENGTH
) +
" | " +
documentTitles.collection}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option here would be to use template literals

</title>
</Head>
<Collection
collectionResult={collectionResult}
collectionQuery={collectionQuery}
Expand Down
15 changes: 14 additions & 1 deletion src/pages/edition/[editionId].tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from "react";

import Layout from "~/src/components/Layout/Layout";
import Edition from "~/src/components/EditionDetail/Edition";
import { editionFetcher } from "~/src/lib/api/SearchApi";
import { EditionQuery, EditionResult } from "~/src/types/EditionQuery";
import { getBackToSearchUrl } from "~/src/util/LinkUtils";
import { documentTitles } from "~/src/constants/labels";
import Head from "next/head";
import { MAX_TITLE_LENGTH } from "~/src/constants/editioncard";
import { truncateStringOnWhitespace } from "~/src/util/Util";

export async function getServerSideProps(context: any) {
const editionQuery: EditionQuery = {
Expand All @@ -26,6 +29,16 @@ export async function getServerSideProps(context: any) {
const WorkResults: React.FC<any> = (props) => {
return (
<Layout>
<Head>
<title>
{truncateStringOnWhitespace(
props.editionResult.data.title,
MAX_TITLE_LENGTH
) +
" | " +
documentTitles.editionItem}
</title>
</Head>
<Edition editionResult={props.editionResult} backUrl={props.backUrl} />
</Layout>
);
Expand Down
15 changes: 14 additions & 1 deletion src/pages/work/[workId].tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import Head from "next/head";
import React from "react";

import Layout from "~/src/components/Layout/Layout";
import WorkDetail from "~/src/components/Work/Work";
import { MAX_TITLE_LENGTH } from "~/src/constants/editioncard";
import { documentTitles } from "~/src/constants/labels";
import { workFetcher } from "~/src/lib/api/SearchApi";
import { WorkQuery, WorkResult } from "~/src/types/WorkQuery";
import { getBackToSearchUrl } from "~/src/util/LinkUtils";
import { truncateStringOnWhitespace } from "~/src/util/Util";

export async function getServerSideProps(context: any) {
//TODO: Default query
Expand All @@ -27,6 +30,16 @@ export async function getServerSideProps(context: any) {
const WorkResults: React.FC<any> = (props) => {
return (
<Layout>
<Head>
<title>
{truncateStringOnWhitespace(
props.workResult.data.title,
MAX_TITLE_LENGTH
) +
" | " +
documentTitles.workItem}
</title>
</Head>
<WorkDetail workResult={props.workResult} backUrl={props.backUrl} />
</Layout>
);
Expand Down
Loading