diff --git a/src/app/_lib/all-routes.ts b/src/app/_lib/all-routes.ts index 4a65563c..62b27322 100644 --- a/src/app/_lib/all-routes.ts +++ b/src/app/_lib/all-routes.ts @@ -1,6 +1,6 @@ import { getUniqueCategoryList } from '~/lib/categories' import { slug } from '~/lib/slug' -import { getUniqueTagListFromPosts } from '~/lib/tags' +import { getUniqueTagList } from '~/lib/tags' import { config } from 'global-config' import { posts } from '#content' @@ -15,7 +15,7 @@ const commonPaths = [ 'blog/feed', 'guestbook' ] -const tagPaths = getUniqueTagListFromPosts().map(tag => `blog/tag/${slug(tag)}`) +const tagPaths = getUniqueTagList().map(tag => `blog/tag/${slug(tag)}`) const categoryPaths = getUniqueCategoryList().map( category => `blog/categories/${slug(category)}` ) diff --git a/src/app/blog/tag/[tag]/page.tsx b/src/app/blog/tag/[tag]/page.tsx index 3f005c96..abfad93a 100644 --- a/src/app/blog/tag/[tag]/page.tsx +++ b/src/app/blog/tag/[tag]/page.tsx @@ -5,7 +5,7 @@ import { Tag } from '@phosphor-icons/react/dist/ssr' import { PostList } from '~/components/post-list' import { - getUniqueTagListFromPosts, + getUniqueTagList, getPostListBasedOnTag, getNormalTagString } from '~/lib/tags' @@ -25,6 +25,7 @@ export function generateMetadata({ params }: Props): Metadata { export default function Page({ params }: Props) { const { tag } = params + const postList = getSortedPosts(getPostListBasedOnTag(slug(tag))) return ( @@ -41,7 +42,7 @@ export default function Page({ params }: Props) { } export async function generateStaticParams() { - const tagList = getUniqueTagListFromPosts() + const tagList = getUniqueTagList() return tagList.map(tag => ({ tag: slug(tag) })) } diff --git a/src/components/kbar/provider.tsx b/src/components/kbar/provider.tsx index ed3666e8..7bd17991 100644 --- a/src/components/kbar/provider.tsx +++ b/src/components/kbar/provider.tsx @@ -35,7 +35,7 @@ import { getSortedPosts } from '~/lib/get-sorted-posts' import { KBar } from '~/components/kbar' import { slug } from '~/lib/slug' import { getUniqueCategoryList } from '~/lib/categories' -import { getUniqueTagListFromPosts } from '~/lib/tags' +import { getUniqueTagList } from '~/lib/tags' import { posts, projects, tils } from '#content' export function CustomKBarProvider({ children }: { children: ReactNode }) { @@ -124,7 +124,7 @@ export function CustomKBarProvider({ children }: { children: ReactNode }) { section: 'Blog', perform: () => push(`/blog/categories/${slug(category)}`) })) - const tagsAsAction: Action[] = getUniqueTagListFromPosts() + const tagsAsAction: Action[] = getUniqueTagList() .sort() .map(tag => ({ id: slug(tag), diff --git a/src/lib/tags.ts b/src/lib/tags.ts index 5c0e0973..168702e1 100644 --- a/src/lib/tags.ts +++ b/src/lib/tags.ts @@ -3,19 +3,21 @@ import { removeRepeatedValuesFromArray } from '~/lib/remove-repeated-values-from import { getFrequencyOfValue } from '~/lib/get-frequency-of-value' import { Post, posts, tils } from '#content' -const getRawTagListFromPosts = () => - posts.filter((post: Post) => !post.test).flatMap(post => post.tags) +const getRawTagList = () => [ + ...posts.filter((post: Post) => !post.test).flatMap(post => post.tags), + ...tils.flatMap(til => til.tags) +] -export const getUniqueTagListFromPosts = () => - removeRepeatedValuesFromArray(getRawTagListFromPosts()) +export const getUniqueTagList = () => + removeRepeatedValuesFromArray(getRawTagList()) export interface TagsAndNumberOfPosts { tag: string numberOfPosts: number } export function getTagsAndNumberOfPosts(): TagsAndNumberOfPosts[] { - const rawTagList = getRawTagListFromPosts() - const uniqueTagList = getUniqueTagListFromPosts() + const rawTagList = getRawTagList() + const uniqueTagList = getUniqueTagList() const tagsAndNumberOfPosts = uniqueTagList.map(tag => { const numberOfPosts = getFrequencyOfValue(rawTagList, tag) @@ -39,7 +41,7 @@ export function getPostListBasedOnTag(tag: string) { } export function getNormalTagString(tag: string) { - const allTags = getUniqueTagListFromPosts() + const allTags = getUniqueTagList() return allTags.find(currTag => slug(currTag) === slug(tag)) }