diff --git a/pages/articles/[slug].tsx b/pages/articles/[slug].tsx
index 7f485f52..b8007f7f 100644
--- a/pages/articles/[slug].tsx
+++ b/pages/articles/[slug].tsx
@@ -6,6 +6,7 @@ import type {
GetServerSidePropsContext,
} from "next";
import { Menu, Transition } from "@headlessui/react";
+import Link from "next/link";
import Head from "next/head";
import {
HeartIcon,
@@ -102,7 +103,10 @@ const ArticlePage: NextPage = ({
-
+
0 && (
{post.tags.map(({ tag }) => (
-
{tag.title}
-
+
))}
)}
diff --git a/pages/articles/index.tsx b/pages/articles/index.tsx
index 5bf62dc8..e32d9d25 100644
--- a/pages/articles/index.tsx
+++ b/pages/articles/index.tsx
@@ -1,5 +1,6 @@
import { Children, Fragment, useEffect } from "react";
import Head from "next/head";
+import { TagIcon } from "@heroicons/react/outline";
import ArticlePreview from "../../components/ArticlePreview/ArticlePreview";
import ArticleLoading from "../../components/ArticlePreview/ArticleLoading";
import Layout from "../../components/Layout/Layout";
@@ -10,7 +11,8 @@ import { useRouter } from "next/router";
const ArticlesPage = () => {
const router = useRouter();
- const { filter } = router.query;
+ const { filter, tag: dirtyTag } = router.query;
+ const tag = typeof dirtyTag === "string" ? dirtyTag.toLowerCase() : null;
type Filter = "newest" | "oldest" | "top";
const filters: Filter[] = ["newest", "oldest", "top"];
@@ -27,7 +29,7 @@ const ArticlesPage = () => {
const { status, data, isFetchingNextPage, fetchNextPage, hasNextPage } =
trpc.post.all.useInfiniteQuery(
- { limit: 15, sort: selectedSortFilter },
+ { limit: 15, sort: selectedSortFilter, tag },
{
getNextPageParam: (lastPage) => lastPage.nextCursor,
}
@@ -41,6 +43,10 @@ const ArticlesPage = () => {
}
}, [inView]);
+ // @TODO make a list of words like "JavaScript" that we can map the words to if they exist
+ const capitalize = (str: string) =>
+ str.replace(/(?:^|\s|["'([{])+\S/g, (match) => match.toUpperCase());
+
return (
<>
@@ -67,7 +73,14 @@ const ArticlesPage = () => {
- Articles
+ {typeof tag === "string" ? (
+
+
+ {capitalize(tag)}
+
+ ) : (
+ "Articles"
+ )}