Skip to content

Commit

Permalink
blog ready
Browse files Browse the repository at this point in the history
  • Loading branch information
fifaeiou committed Jun 3, 2024
1 parent 39511c0 commit b8aafca
Show file tree
Hide file tree
Showing 28 changed files with 4,228 additions and 316 deletions.
6 changes: 5 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// @ts-check
// Import the MDX plugin
const withMDX = require('@next/mdx')();

/** @type {import('next').NextConfig} */
const nextConfig = {
pageExtensions: ['js', 'jsx', 'mdx', 'ts', 'tsx'],
images: {
remotePatterns: [{protocol: 'https', hostname: 'img.icons8.com'},{protocol: 'https', hostname: 'images.unsplash.com'} ],
},
}

module.exports = nextConfig
// Use the MDX plugin
module.exports = withMDX(nextConfig);
3,987 changes: 3,729 additions & 258 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"dependencies": {
"@headlessui/react": "^1.4.2",
"@heroicons/react": "^1.0.5",
"@mdx-js/loader": "^3.0.1",
"@mdx-js/react": "^3.0.1",
"@next/mdx": "^14.2.3",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-slot": "^1.0.2",
"@vercel/analytics": "^1.2.2",
Expand All @@ -24,6 +27,7 @@
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@types/mdx": "^2.0.13",
"@types/node": "20.12.7",
"@types/react": "18.3.1",
"autoprefixer": "^10.4.19",
Expand Down
9 changes: 9 additions & 0 deletions src/app/blogs/(posts)/eight/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const metadata = {
title: "Post eight",
publishDate: "2024-01-09T00:00:00Z",
categories: ["rock"],
};

# Post eight

Ac felis donec et odio pellentesque diam volutpat commodo. Nunc eget lorem dolor sed viverra. Odio tempor orci dapibus ultrices in iaculis nunc sed. Neque convallis a cras semper auctor neque vitae tempus. Non nisi est sit amet. Leo vel fringilla est ullamcorper. Id interdum velit laoreet id donec ultrices. Risus in hendrerit gravida rutrum quisque non tellus orci. Turpis cursus in hac habitasse platea. Nunc vel risus commodo viverra maecenas accumsan lacus vel facilisis. Semper risus in hendrerit gravida. Commodo ullamcorper a lacus vestibulum sed arcu non odio. Faucibus pulvinar elementum integer enim.
9 changes: 9 additions & 0 deletions src/app/blogs/(posts)/five/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const metadata = {
title: "Post five",
publishDate: "2024-01-06T00:00:00Z",
categories: ["cat"],
};

# Post five

Feugiat nibh sed pulvinar proin gravida hendrerit. Lectus mauris ultrices eros in cursus turpis massa. Turpis cursus in hac habitasse platea dictumst. Quisque id diam vel quam elementum. Cursus turpis massa tincidunt dui ut ornare lectus sit. Eget nulla facilisi etiam dignissim diam quis enim lobortis scelerisque. Cursus sit amet dictum sit. Dictum sit amet justo donec enim diam. Lorem donec massa sapien faucibus. Tempus urna et pharetra pharetra massa. Suscipit tellus mauris a diam maecenas sed. Pellentesque elit ullamcorper dignissim cras tincidunt lobortis. Placerat in egestas erat imperdiet. In nibh mauris cursus mattis molestie a iaculis at erat.
9 changes: 9 additions & 0 deletions src/app/blogs/(posts)/four/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const metadata = {
title: "Post four",
publishDate: "2024-01-05T00:00:00Z",
categories: ["dog", "cat"],
};

# Post four

Feugiat nibh sed pulvinar proin gravida hendrerit. Lectus mauris ultrices eros in cursus turpis massa. Turpis cursus in hac habitasse platea dictumst. Quisque id diam vel quam elementum. Cursus turpis massa tincidunt dui ut ornare lectus sit. Eget nulla facilisi etiam dignissim diam quis enim lobortis scelerisque. Cursus sit amet dictum sit. Dictum sit amet justo donec enim diam. Lorem donec massa sapien faucibus. Tempus urna et pharetra pharetra massa. Suscipit tellus mauris a diam maecenas sed. Pellentesque elit ullamcorper dignissim cras tincidunt lobortis. Placerat in egestas erat imperdiet. In nibh mauris cursus mattis molestie a iaculis at erat.
9 changes: 9 additions & 0 deletions src/app/blogs/(posts)/hello-world/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const metadata = {
title: "Hello world",
publishDate: "2024-01-01T00:00:00Z",
categories: ["dog"],
};

# Hello world

Welcome to by blog!
9 changes: 9 additions & 0 deletions src/app/blogs/(posts)/nine/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const metadata = {
title: "Post nine",
publishDate: "2024-01-10T00:00:00Z",
categories: ["dog", "rock"],
};

# Post nine

Consectetur adipiscing elit duis tristique sollicitudin nibh sit amet commodo. Velit laoreet id donec ultrices tincidunt arcu non. Suscipit tellus mauris a diam maecenas sed. Eleifend donec pretium vulputate sapien nec sagittis aliquam malesuada. Ultrices tincidunt arcu non sodales neque sodales ut etiam sit. Arcu risus quis varius quam quisque id diam vel quam. At consectetur lorem donec massa sapien faucibus et molestie ac. Mi bibendum neque egestas congue quisque egestas diam. Hendrerit gravida rutrum quisque non tellus. Consequat id porta nibh venenatis cras sed felis eget velit. Egestas congue quisque egestas diam in arcu cursus euismod. Tortor at auctor urna nunc id cursus. Mattis ullamcorper velit sed ullamcorper morbi tincidunt ornare massa eget. Commodo nulla facilisi nullam vehicula ipsum a. Semper auctor neque vitae tempus quam. Velit ut tortor pretium viverra suspendisse potenti nullam ac tortor.
9 changes: 9 additions & 0 deletions src/app/blogs/(posts)/one/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const metadata = {
title: "Post one",
publishDate: "2024-01-02T00:00:00Z",
categories: ["cat"],
};

# Post one

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Eget mi proin sed libero. Nunc lobortis mattis aliquam faucibus purus in massa. Sollicitudin aliquam ultrices sagittis orci a. Morbi quis commodo odio aenean sed adipiscing diam donec adipiscing. Sapien faucibus et molestie ac. In metus vulputate eu scelerisque felis imperdiet. Mattis molestie a iaculis at erat pellentesque adipiscing commodo elit. Eget dolor morbi non arcu risus quis. Nunc aliquet bibendum enim facilisis gravida neque convallis. Volutpat odio facilisis mauris sit amet massa vitae tortor condimentum. Ac feugiat sed lectus vestibulum. In fermentum et sollicitudin ac orci phasellus. Mauris vitae ultricies leo integer malesuada nunc vel risus. Sed elementum tempus egestas sed. Enim facilisis gravida neque convallis a cras. In nulla posuere sollicitudin aliquam ultrices.
9 changes: 9 additions & 0 deletions src/app/blogs/(posts)/seven/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const metadata = {
title: "Post seven",
publishDate: "2024-01-08T00:00:00Z",
categories: ["rock"],
};

# Post seven

Nulla facilisi cras fermentum odio eu feugiat. Magnis dis parturient montes nascetur ridiculus. Erat pellentesque adipiscing commodo elit at imperdiet dui. Ac tortor vitae purus faucibus ornare. Interdum velit laoreet id donec ultrices tincidunt. Pulvinar neque laoreet suspendisse interdum consectetur libero id faucibus. Aliquet nec ullamcorper sit amet risus nullam eget. Mollis nunc sed id semper risus in hendrerit gravida rutrum. Facilisi morbi tempus iaculis urna id volutpat. Sodales ut etiam sit amet nisl purus. Pulvinar sapien et ligula ullamcorper malesuada proin. Arcu cursus euismod quis viverra nibh cras. Sollicitudin ac orci phasellus egestas. Sit amet porttitor eget dolor morbi non arcu risus quis. Ullamcorper dignissim cras tincidunt lobortis. Scelerisque mauris pellentesque pulvinar pellentesque habitant morbi. Nulla facilisi morbi tempus iaculis. Diam vel quam elementum pulvinar etiam non quam lacus suspendisse. At consectetur lorem donec massa sapien faucibus et. Aenean sed adipiscing diam donec.
9 changes: 9 additions & 0 deletions src/app/blogs/(posts)/six/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const metadata = {
title: "Post six",
publishDate: "2024-01-07T00:00:00Z",
categories: ["rock"],
};

# Post six

Risus nullam eget felis eget. Orci eu lobortis elementum nibh tellus. Ultrices vitae auctor eu augue ut lectus. Non diam phasellus vestibulum lorem sed risus ultricies tristique. Congue mauris rhoncus aenean vel elit scelerisque mauris. Quis ipsum suspendisse ultrices gravida dictum fusce. Mauris pharetra et ultrices neque ornare aenean. Maecenas accumsan lacus vel facilisis volutpat est. Quis blandit turpis cursus in hac. Metus dictum at tempor commodo ullamcorper a lacus. Sed risus ultricies tristique nulla aliquet enim tortor at auctor.
9 changes: 9 additions & 0 deletions src/app/blogs/(posts)/ten/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const metadata = {
title: "Post ten",
publishDate: "2024-01-11T00:00:00Z",
categories: ["dog", "cat"],
};

# Post ten

Molestie a iaculis at erat. Ipsum dolor sit amet consectetur adipiscing elit. Ipsum dolor sit amet consectetur adipiscing elit ut. Curabitur vitae nunc sed velit dignissim sodales. Integer enim neque volutpat ac tincidunt vitae semper. Urna et pharetra pharetra massa massa ultricies. Varius duis at consectetur lorem donec. Elit at imperdiet dui accumsan sit amet nulla. Orci phasellus egestas tellus rutrum tellus pellentesque. Dictum sit amet justo donec enim diam vulputate ut. Erat imperdiet sed euismod nisi porta lorem. Viverra nibh cras pulvinar mattis nunc sed. Sed risus pretium quam vulputate dignissim suspendisse in. Elementum pulvinar etiam non quam lacus suspendisse faucibus interdum posuere. Vel orci porta non pulvinar neque laoreet suspendisse. Ultrices sagittis orci a scelerisque purus semper eget. Interdum posuere lorem ipsum dolor sit amet consectetur adipiscing. Ipsum a arcu cursus vitae congue mauris rhoncus aenean vel. Ultrices eros in cursus turpis massa tincidunt.
9 changes: 9 additions & 0 deletions src/app/blogs/(posts)/three/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const metadata = {
title: "Post three",
publishDate: "2024-01-04T00:00:00Z",
categories: ["dog", "cat", "rock"],
};

# Post three

Mollis nunc sed id semper risus in hendrerit gravida rutrum. Placerat vestibulum lectus mauris ultrices. A diam maecenas sed enim. Elit ullamcorper dignissim cras tincidunt lobortis feugiat vivamus at augue. Mauris a diam maecenas sed enim ut sem viverra. Porta non pulvinar neque laoreet suspendisse. Mi in nulla posuere sollicitudin aliquam ultrices sagittis orci a. Vulputate odio ut enim blandit volutpat maecenas. Curabitur gravida arcu ac tortor dignissim convallis aenean et. Mattis vulputate enim nulla aliquet. Commodo elit at imperdiet dui accumsan. Scelerisque eu ultrices vitae auctor eu augue.
9 changes: 9 additions & 0 deletions src/app/blogs/(posts)/two/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const metadata = {
title: "Post two",
publishDate: "2024-01-03T00:00:00Z",
categories: ["rock"],
};

# Post two

Duis at consectetur lorem donec massa sapien faucibus et molestie. Pulvinar pellentesque habitant morbi tristique senectus et netus. Tempor id eu nisl nunc mi ipsum faucibus vitae aliquet. Duis ultricies lacus sed turpis. Vulputate odio ut enim blandit volutpat maecenas volutpat blandit aliquam. Nisi vitae suscipit tellus mauris a diam. Et ultrices neque ornare aenean. Et malesuada fames ac turpis egestas sed. Suspendisse sed nisi lacus sed viverra tellus in hac. Semper risus in hendrerit gravida rutrum quisque non tellus. Sit amet commodo nulla facilisi nullam vehicula ipsum a arcu. Eu mi bibendum neque egestas. Integer vitae justo eget magna fermentum. Ac turpis egestas maecenas pharetra convallis posuere. Nulla facilisi nullam vehicula ipsum. Laoreet id donec ultrices tincidunt arcu non sodales. Tristique sollicitudin nibh sit amet commodo. In hendrerit gravida rutrum quisque.
7 changes: 0 additions & 7 deletions src/app/blogs/[slug]/page.tsx

This file was deleted.

45 changes: 45 additions & 0 deletions src/app/blogs/category/[category]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { categories, type Category } from "@lib/categories";
import { Pagination } from "@components/pagination";
import { Posts } from "@components/posts";
import {
getPaginatedPostsByCategory,
postsPerPage,
} from "../../../../posts";
import { notFound } from "next/navigation";

export default async function Category({
params,
}: {
params: { category: Category };
}) {
const { category } = params;

// 404 if the category does not exist
if (categories.indexOf(category) == -1) notFound();

const { posts, total } = await getPaginatedPostsByCategory({
category,
page: 1,
limit: postsPerPage,
});

return (
<main>
<h1>Category: {category}</h1>
<Posts posts={posts} />

<Pagination
baseUrl={`/blogs/category/${category}/page`}
page={1}
perPage={postsPerPage}
total={total}
/>
</main>
);
}

export function generateStaticParams() {
return categories.map((category) => ({
category,
}));
}
62 changes: 62 additions & 0 deletions src/app/blogs/category/[category]/page/[page]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Category, categories } from "@lib/categories";
import { Pagination } from "@components/pagination";
import { Posts } from "@components/posts";
import {
getPaginatedPostsByCategory,
getPostsByCategory,
postsPerPage,
} from "../../../../../../posts";
import { notFound, redirect } from "next/navigation";

export default async function Page({
params,
}: {
params: { category: Category; page: number };
}) {
let { category, page } = params;
page = Number(page);

if (page < 1) notFound();

if (page == 1) redirect(`/category/${category}`);

const { posts, total } = await getPaginatedPostsByCategory({
category,
page,
limit: postsPerPage,
});

if (!posts.length) notFound();

return (
<main>
<h1>
Category: {category} (Page: {page})
</h1>
<Posts posts={posts} />

<Pagination
baseUrl={`/blogs/category/${category}/page`}
page={page}
perPage={postsPerPage}
total={total}
/>
</main>
);
}

export async function generateStaticParams() {
const paths = await Promise.all(
categories.map(async (category) => {
const posts = await getPostsByCategory({ category });
const pages = Math.ceil(posts.length / postsPerPage);

return [...Array(pages)].map((_, i) => ({
category,
page: `${i + 1}`,
}));
})
);

return paths.flat();
}
32 changes: 32 additions & 0 deletions src/app/blogs/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use client";
import type { Metadata } from "next";
import PageWrap from "@components/PageWrap";
import { usePathname } from "next/navigation";

// export const metadata: Metadata = {
// title: "Blog",
// };

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
const pathname = usePathname();

// Define a pattern to match paths that should skip the layout
const shouldSkipLayout = pathname.match(/\/blogs\/\d+|\/blogs\/\w+/);

if (shouldSkipLayout) {
return (
<>
<div className="max-w-6xl mx-auto">
<h1 className="text-5xl md:text-9xl font-bold my-24 text-center md:text-left bg-gradient-to-r from-orange-700 via-blue-500 to-green-400 text-transparent bg-clip-text animate-gradient" />
{children}
</div>
</>
);
}

return <PageWrap title={"Blogs"}>{children}</PageWrap>;
}
69 changes: 21 additions & 48 deletions src/app/blogs/page.tsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,26 @@
import { Categories } from "@components/categories";
import { Pagination } from "@components/pagination";
import { Posts } from "@components/posts";
import { getPaginatedPosts, postsPerPage } from "../../posts";
import PageWrap from "@components/PageWrap";
import React from "react";

export default function Blogs() {
return (
<PageWrap title="Blogs">
<div className="grid grid-cols-1 gap-12 md:gap-5 md:grid-cols-3 items-start">
<Blog />
<Blog />
<Blog />
<Blog />
<Blog />
<Blog />
</div>
</PageWrap>
);
}
export default async function Home() {
const { posts, total } = await getPaginatedPosts({
page: 1,
limit: postsPerPage,
});

function Blog() {
return (
<>
<article className="flex flex-col rounded-lg shadow-md overflow-hidden">
<a
rel="noopener noreferrer"
href="#"
aria-label="Te nulla oportere reprimique his dolorum"
>
<img
alt=""
className="object-cover w-full h-60 transition duration-300 hover:scale-110"
src="https://source.unsplash.com/200x200/?fashion?2"
/>
</a>
<div className="flex flex-col flex-1 p-6 bg-white/90 dark:bg-gray-900/90">
<a
rel="noopener noreferrer"
href="#"
className="text-xs tracking-wider uppercase hover:underline text-indigo-600 dark:text-indigo-400"
>
Convenire
</a>
<h3 className="flex-1 py-2 text-lg font-semibold leading-snug text-gray-900 dark:text-gray-100">
Te nulla oportere reprimique his dolorum
</h3>
<div className="flex flex-wrap justify-between pt-3 space-x-2 text-xs text-gray-600 dark:text-gray-400">
<span>June 2, 2020</span>
<span>2.2K views</span>
</div>
</div>
</article>
</>
<>
<Posts posts={posts} />

<Pagination
baseUrl="/blogs/page"
page={1}
perPage={postsPerPage}
total={total}
/>
<Categories/>
</>
);
}
}
Loading

0 comments on commit b8aafca

Please sign in to comment.