summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-01-16 14:15:27 +0100
committerArmand Philippot <git@armandphilippot.com>2022-01-16 14:16:32 +0100
commite63d74d4147e66ec79c287b7c3fda0dadc139275 (patch)
tree39d74f56ff11c32f9334b794e01d2ebff7025e5a
parent6f46e54e382bf3f535f27ebead18c2bdf4628e49 (diff)
chore(meta): add a link to comments on single post pages
-rw-r--r--src/components/PostMeta/PostMeta.tsx9
-rw-r--r--src/pages/article/[slug].tsx2
2 files changed, 9 insertions, 2 deletions
diff --git a/src/components/PostMeta/PostMeta.tsx b/src/components/PostMeta/PostMeta.tsx
index ece355a..0b68d70 100644
--- a/src/components/PostMeta/PostMeta.tsx
+++ b/src/components/PostMeta/PostMeta.tsx
@@ -16,6 +16,7 @@ const PostMeta = ({
const { author, commentCount, dates, subjects, thematics, website } = meta;
const { asPath, locale } = useRouter();
const isThematic = () => asPath.includes('/thematique/');
+ const isArticle = () => asPath.includes('/article/');
const dateOptions: Intl.DateTimeFormatOptions = {
day: 'numeric',
@@ -120,7 +121,13 @@ const PostMeta = ({
{commentCount !== undefined && (
<div className={styles.item}>
<dt className={styles.term}>{t`Comments`}</dt>
- {getCommentsCount()}
+ <dd className={styles.description}>
+ {isArticle() ? (
+ <a href="#comments">{getCommentsCount()}</a>
+ ) : (
+ getCommentsCount()
+ )}
+ </dd>
</div>
)}
</dl>
diff --git a/src/pages/article/[slug].tsx b/src/pages/article/[slug].tsx
index 477503e..e519c27 100644
--- a/src/pages/article/[slug].tsx
+++ b/src/pages/article/[slug].tsx
@@ -71,7 +71,7 @@ const SingleArticle: NextPageWithLayout<ArticleProps> = ({ post }) => {
<Sidebar position="right">
<Sharing title={title} excerpt={intro} />
</Sidebar>
- <section className={styles.comments}>
+ <section id="comments" className={styles.comments}>
<CommentsList articleId={databaseId} comments={comments} />
<CommentForm articleId={post.databaseId} />
</section>