Skip to content

Commit

Permalink
Remove 'views' field from blog data retrieval across multiple compon…
Browse files Browse the repository at this point in the history
…ents
  • Loading branch information
jeromehardaway committed Dec 21, 2024
1 parent 60f2b31 commit 3fd40e1
Show file tree
Hide file tree
Showing 18 changed files with 25 additions and 38 deletions.
9 changes: 2 additions & 7 deletions src/components/blog-card/blog-05.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import SocialShare from "@components/social-share/layout-03";

type TProps = Pick<
IBlog,
"image" | "path" | "title" | "postedAt" | "views" | "category" | "author" | "excerpt"
"image" | "path" | "title" | "postedAt" | "category" | "author" | "excerpt"
> & {
className?: string;
};

const BlogCard = forwardRef<HTMLDivElement, TProps>(
({ className, image, path, title, postedAt, views, category, author, excerpt }, ref) => {
({ className, image, path, title, postedAt, category, author, excerpt }, ref) => {
return (
<div
className={clsx(
Expand Down Expand Up @@ -60,11 +60,6 @@ const BlogCard = forwardRef<HTMLDivElement, TProps>(
text={postedAt}
icon="far fa-calendar"
/>
<BlogMetaItem
className="tw-pr-5 md:tw-pr-8"
text={`${views} views`}
icon="far fa-eye"
/>
</div>
<p className="tw-mt-4" dangerouslySetInnerHTML={{ __html: excerpt }} />
<div className="tw-flex tw-items-center tw-justify-between tw-mt-7.5">
Expand Down
12 changes: 2 additions & 10 deletions src/components/blog-card/blog-06.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ import { IBlog } from "@utils/types";
import Button from "@components/ui/button";
import SocialShare from "@components/social-share/layout-03";

type TProps = Pick<
IBlog,
"image" | "path" | "title" | "postedAt" | "views" | "author" | "excerpt"
> & {
type TProps = Pick<IBlog, "image" | "path" | "title" | "postedAt" | "author" | "excerpt"> & {
className?: string;
};

const BlogCard = forwardRef<HTMLDivElement, TProps>(
({ className, image, path, title, postedAt, views, author, excerpt }, ref) => {
({ className, image, path, title, postedAt, author, excerpt }, ref) => {
return (
<div
className={clsx(
Expand Down Expand Up @@ -54,11 +51,6 @@ const BlogCard = forwardRef<HTMLDivElement, TProps>(
text={postedAt}
icon="far fa-calendar"
/>
<BlogMetaItem
className="tw-pr-5 md:tw-pr-8"
text={`${views} views`}
icon="far fa-eye"
/>
</div>
<p className="tw-mt-4" dangerouslySetInnerHTML={{ __html: excerpt }} />
<div className="tw-flex tw-items-center tw-justify-between tw-mt-7.5 md:tw-mt-9">
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blogs/author/[author]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const getStaticProps = ({ params }: Params) => {
const author = getAuthorBySlug(params.author, ["id", "name", "slug"]);
const { posts, count } = getPostsByAuthor(
author.id,
["title", "image", "category", "postedAt", "views"],
["title", "image", "category", "postedAt"],
0,
POSTS_PER_PAGE
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blogs/author/[author]/page/[page].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const getStaticProps = ({ params }: Params) => {
const skip = (currentPage - 1) * POSTS_PER_PAGE;
const { posts, count } = getPostsByAuthor(
author.id,
["title", "image", "category", "postedAt", "views"],
["title", "image", "category", "postedAt"],
skip,
POSTS_PER_PAGE
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blogs/blog-classic/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ BlogClassic.Layout = Layout01;

export const getStaticProps: GetStaticProps = () => {
const { blogs, count } = getAllBlogs(
["title", "image", "category", "postedAt", "views", "author", "excerpt"],
["title", "image", "category", "postedAt", "author", "excerpt"],
0,
POSTS_PER_PAGE
);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/blogs/blog-classic/page/[page].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const getStaticPaths: GetStaticPaths = () => {
.filter(Boolean);

const paths = pagesToGenerate.map((page) => {
return { params: { page: String(page) } }; // cast page to string
return { params: { page: String(page) } };
});

return {
Expand All @@ -78,7 +78,7 @@ export const getStaticProps: GetStaticProps<TProps, Params> = ({ params }) => {
const currentPage = !page || Number.isNaN(+page) ? 1 : +page;
const skip = (currentPage - 1) * POSTS_PER_PAGE;
const { blogs, count } = getAllBlogs(
["title", "image", "category", "postedAt", "views", "author", "excerpt"],
["title", "image", "category", "postedAt", "author", "excerpt"],
skip,
POSTS_PER_PAGE
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blogs/blog-grid-sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ BlogGridSidebar.Layout = Layout01;

export const getStaticProps: GetStaticProps = () => {
const { blogs, count } = getAllBlogs(
["title", "image", "category", "postedAt", "views"],
["title", "image", "category", "postedAt"],
0,
POSTS_PER_PAGE
);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/blogs/blog-grid-sidebar/page/[page].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const getStaticPaths: GetStaticPaths = () => {
.filter(Boolean);

const paths = pagesToGenerate.map((page) => {
return { params: { page: String(page) } }; // cast page to string
return { params: { page: String(page) } };
});

return {
Expand All @@ -78,7 +78,7 @@ export const getStaticProps: GetStaticProps<TProps, Params> = ({ params }) => {
const currentPage = !page || Number.isNaN(+page) ? 1 : +page;
const skip = (currentPage - 1) * POSTS_PER_PAGE;
const { blogs, count } = getAllBlogs(
["title", "slug", "image", "category", "postedAt", "views"],
["title", "slug", "image", "category", "postedAt"],
skip,
POSTS_PER_PAGE
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blogs/blog-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ BlogList.Layout = Layout01;

export const getStaticProps: GetStaticProps = () => {
const { blogs, count } = getAllBlogs(
["title", "image", "postedAt", "views", "author", "excerpt"],
["title", "image", "postedAt", "author", "excerpt"],
0,
POSTS_PER_PAGE
);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/blogs/blog-list/page/[page].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const getStaticPaths: GetStaticPaths = () => {
.filter(Boolean);

const paths = pagesToGenerate.map((page) => {
return { params: { page: String(page) } }; // cast page to string
return { params: { page: String(page) } };
});

return {
Expand All @@ -72,7 +72,7 @@ export const getStaticProps: GetStaticProps<TProps, Params> = ({ params }) => {
const currentPage = !page || Number.isNaN(+page) ? 1 : +page;
const skip = (currentPage - 1) * POSTS_PER_PAGE;
const { blogs, count } = getAllBlogs(
["title", "image", "category", "postedAt", "views", "author", "excerpt"],
["title", "image", "category", "postedAt", "author", "excerpt"],
skip,
POSTS_PER_PAGE
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blogs/blog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ BlogGrid.Layout = Layout01;

export const getStaticProps: GetStaticProps = () => {
const { blogs, count } = getAllBlogs(
["title", "image", "category", "postedAt", "views"],
["title", "image", "category", "postedAt"],
0,
POSTS_PER_PAGE
);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/blogs/blog/page/[page].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const getStaticPaths: GetStaticPaths = () => {
.filter(Boolean);

const paths = pagesToGenerate.map((page) => {
return { params: { page: String(page) } }; // cast page to string
return { params: { page: String(page) } };
});
return {
paths,
Expand All @@ -67,7 +67,7 @@ export const getStaticProps: GetStaticProps<TProps, Params> = ({ params }) => {
const currentPage = !page || Number.isNaN(+page) ? 1 : +page;
const skip = (currentPage - 1) * POSTS_PER_PAGE;
const { blogs, count } = getAllBlogs(
["title", "slug", "image", "category", "postedAt", "views"],
["title", "slug", "image", "category", "postedAt"],
skip,
POSTS_PER_PAGE
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blogs/category/[category]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type Params = {
export const getStaticProps = ({ params }: Params) => {
const { posts, count } = getPostsByCategory(
params.category,
["title", "image", "category", "postedAt", "views"],
["title", "image", "category", "postedAt"],
0,
POSTS_PER_PAGE
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blogs/category/[category]/page/[page].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const getStaticProps = ({ params }: Params) => {
const skip = (currentPage - 1) * POSTS_PER_PAGE;
const { posts, count } = getPostsByCategory(
params.category,
["title", "image", "category", "postedAt", "views"],
["title", "image", "category", "postedAt"],
skip,
POSTS_PER_PAGE
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blogs/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const BlogSearch: PageProps = ({ data }) => {
BlogSearch.Layout = Layout01;

export const getStaticProps: GetStaticProps = () => {
const { blogs } = getAllBlogs(["title", "image", "category", "postedAt", "views", "content"]);
const { blogs } = getAllBlogs(["title", "image", "category", "postedAt", "content"]);

return {
props: {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blogs/tag/[tag]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type Params = {
export const getStaticProps = ({ params }: Params) => {
const { posts, count } = getPostsByTag(
params.tag,
["title", "image", "tags", "postedAt", "views"],
["title", "image", "tags", "postedAt"],
0,
POSTS_PER_PAGE
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blogs/tag/[tag]/page/[page].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const getStaticProps = ({ params }: Params) => {
const skip = (currentPage - 1) * POSTS_PER_PAGE;
const { posts, count } = getPostsByTag(
params.tag,
["title", "image", "category", "postedAt", "views"],
["title", "image", "category", "postedAt"],
skip,
POSTS_PER_PAGE
);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { getallEvents } from "../lib/event";

interface PageContent {
section: string;
[key: string]: unknown; // Add index signature
[key: string]: unknown;
}

interface PageData {
Expand Down Expand Up @@ -78,7 +78,7 @@ export const getStaticProps: GetStaticProps = () => {
const page = getPageData("home", "index");
const courses = getallCourses(["title", "thumbnail"], 0, 6);
const events = getallEvents(["title", "thumbnail", "start_date", "location"], 0, 6);
const { blogs } = getAllBlogs(["title", "image", "category", "postedAt", "views"], 0, 3);
const { blogs } = getAllBlogs(["title", "image", "category", "postedAt"], 0, 3);
return {
props: {
data: {
Expand Down

0 comments on commit 3fd40e1

Please sign in to comment.