aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/organisms
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-12-14 15:30:34 +0100
committerArmand Philippot <git@armandphilippot.com>2023-12-14 16:30:04 +0100
commit7063b199b4748a9c354ed37e64cdc84c512f2c0c (patch)
tree7506c3003c56b49a248e9adb40be610780bb540e /src/components/organisms
parent85c4c42bd601270d7be0f34a0767a34bb85e29bb (diff)
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)
Diffstat (limited to 'src/components/organisms')
-rw-r--r--src/components/organisms/comment/approved-comment/approved-comment.test.tsx3
-rw-r--r--src/components/organisms/comment/approved-comment/approved-comment.tsx3
2 files changed, 4 insertions, 2 deletions
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:',