From a5d262bcf263e4a11c079e70442325b85573d109 Mon Sep 17 00:00:00 2001
From: r-freeman
Date: Tue, 17 Jan 2023 21:42:10 +0000
Subject: [PATCH] Updated views component
---
src/components/ArticleLayout.tsx | 2 +-
src/components/Views.tsx | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/components/ArticleLayout.tsx b/src/components/ArticleLayout.tsx
index 3df6a5f..7dca972 100644
--- a/src/components/ArticleLayout.tsx
+++ b/src/components/ArticleLayout.tsx
@@ -97,7 +97,7 @@ export function ArticleLayout({
- {' '}·{' '}
+
{children}
diff --git a/src/components/Views.tsx b/src/components/Views.tsx
index 4f75ddb..33d5500 100644
--- a/src/components/Views.tsx
+++ b/src/components/Views.tsx
@@ -13,7 +13,9 @@ type ViewsType = {
}
export function Views({as: Component = 'span', slug}: { as?: ElementType, slug: string }) {
- const {data} = useSWR(`/api/views/${slug}`, fetcher)
+ const {data} = useSWR(`/api/views/${slug}`, fetcher, {
+ revalidateOnFocus: false
+ })
const views = Number(data?.views)
useEffect(() => {
@@ -27,7 +29,7 @@ export function Views({as: Component = 'span', slug}: { as?: ElementType, slug:
return (
- {views > 0 ? `${numberFormat(views)} views` : ''}
+ {views > 0 ? ` ยท ${numberFormat(views)} views` : ''}
)
}
\ No newline at end of file