From 7063b199b4748a9c354ed37e64cdc84c512f2c0c Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Thu, 14 Dec 2023 15:30:34 +0100 Subject: refactor(pages): rewrite helpers to output schema in json-ld format * make sure url are absolutes * nest breadcrumb schema in webpage schema * trim HTML tags from content/description * use a regular script instead of next/script (with the latter the schema is not updated on route change) * place the script in document head * add keywords, wordCount and readingTime keys in BlogPosting schema * fix breadcrumbs in search page (without query) * add tests (a `MatchInlineSnapshot` will be better but Prettier 3 is not supported yet) --- .../organisms/comment/approved-comment/approved-comment.test.tsx | 3 ++- src/components/organisms/comment/approved-comment/approved-comment.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/components/organisms/comment') diff --git a/src/components/organisms/comment/approved-comment/approved-comment.test.tsx b/src/components/organisms/comment/approved-comment/approved-comment.test.tsx index b244a63..473f845 100644 --- a/src/components/organisms/comment/approved-comment/approved-comment.test.tsx +++ b/src/components/organisms/comment/approved-comment/approved-comment.test.tsx @@ -1,6 +1,7 @@ import { describe, expect, it } from '@jest/globals'; import { userEvent } from '@testing-library/user-event'; import { render, screen as rtlScreen } from '../../../../../tests/utils'; +import { COMMENT_ID_PREFIX } from '../../../../utils/constants'; import { ApprovedComment, type CommentAuthor } from './approved-comment'; describe('ApprovedComment', () => { @@ -30,7 +31,7 @@ describe('ApprovedComment', () => { ).toBeInTheDocument(); expect(rtlScreen.getByRole('link')).toHaveAttribute( 'href', - `#comment-${id}` + `#${COMMENT_ID_PREFIX}${id}` ); }); diff --git a/src/components/organisms/comment/approved-comment/approved-comment.tsx b/src/components/organisms/comment/approved-comment/approved-comment.tsx index d834ba3..6611c11 100644 --- a/src/components/organisms/comment/approved-comment/approved-comment.tsx +++ b/src/components/organisms/comment/approved-comment/approved-comment.tsx @@ -1,6 +1,7 @@ import NextImage from 'next/image'; import { type ForwardRefRenderFunction, forwardRef, useCallback } from 'react'; import { useIntl } from 'react-intl'; +import { COMMENT_ID_PREFIX } from '../../../../utils/constants'; import { Button, Link, Time } from '../../../atoms'; import { Card, @@ -99,7 +100,7 @@ const ApprovedCommentWithRef: ForwardRefRenderFunction< ) => { const intl = useIntl(); const commentClass = `${className}`; - const commentId = `comment-${id}`; + const commentId = `${COMMENT_ID_PREFIX}${id}`; const commentLink = `#${commentId}`; const publicationDateLabel = intl.formatMessage({ defaultMessage: 'Published on:', -- cgit v1.2.3