Skip to content

Commit

Permalink
Fix sorting individual story tags
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinkipruto committed Sep 28, 2023
1 parent bdb840c commit 32b211a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion apps/codeforafrica/src/components/ArticlePage/ArticlePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ArticleHeader from "@/codeforafrica/components/ArticleHeader";
import Author from "@/codeforafrica/components/Author";
import CMSContent from "@/codeforafrica/components/CMSContent";
import SectionDivider from "@/codeforafrica/components/SectionDivider";
import equalsIgnoreCase from "@/codeforafrica/utils/equalsIgnoreCase";

function ArticlePage({
authors,
Expand All @@ -19,6 +20,9 @@ function ArticlePage({
publishedOn,
primaryTag,
}) {
const sortedTags = tags
.sort((a, b) => a.name.localeCompare(b.name))
.filter((tag) => !equalsIgnoreCase(tag.name, primaryTag));
return (
<Box component="article">
<Figure
Expand All @@ -35,7 +39,7 @@ function ArticlePage({
<ArticleHeader
title={title}
date={publishedOn}
tags={tags}
tags={sortedTags}
primaryTag={primaryTag}
excerpt={excerpt}
sx={{
Expand Down
2 changes: 1 addition & 1 deletion apps/codeforafrica/src/lib/data/utils/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export async function getPost(api, slug, primaryTag) {
title,
coverImage,
excerpt,
tags: formatTags(tags),
tags,
publishedOn: formatDate(publishedOn, {
includeTime: false,
month: "short",
Expand Down

0 comments on commit 32b211a

Please sign in to comment.