From c04cd087e4e0cf5a73df17eb9bbb000dddd38b0c Mon Sep 17 00:00:00 2001 From: Lucas Steinmacher Date: Tue, 17 Oct 2023 13:17:11 -0700 Subject: [PATCH] npm i --- package-lock.json | 112 ++++++++++++++---- .../[slug].tsx => app/blog/[slug]/page.tsx} | 102 ++++++++-------- src/app/blog/page.tsx | 56 +++++++++ src/pages/blog/index.tsx | 53 --------- 4 files changed, 197 insertions(+), 126 deletions(-) rename src/{pages/blog/[slug].tsx => app/blog/[slug]/page.tsx} (81%) create mode 100644 src/app/blog/page.tsx delete mode 100644 src/pages/blog/index.tsx diff --git a/package-lock.json b/package-lock.json index 044fc19..15ba0b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -935,6 +935,64 @@ "node": ">=16.0.0" } }, + "node_modules/@react-email/render/node_modules/@selderee/plugin-htmlparser2": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/@selderee/plugin-htmlparser2/-/plugin-htmlparser2-0.10.0.tgz", + "integrity": "sha512-gW69MEamZ4wk1OsOq1nG1jcyhXIQcnrsX5JwixVw/9xaiav8TCyjESAruu1Rz9yyInhgBXxkNwMeygKnN2uxNA==", + "dependencies": { + "domhandler": "^5.0.3", + "selderee": "^0.10.0" + }, + "funding": { + "url": "https://ko-fi.com/killymxi" + } + }, + "node_modules/@react-email/render/node_modules/html-to-text": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-9.0.3.tgz", + "integrity": "sha512-hxDF1kVCF2uw4VUJ3vr2doc91pXf2D5ngKcNviSitNkhP9OMOaJkDrFIFL6RMvko7NisWTEiqGpQ9LAxcVok1w==", + "dependencies": { + "@selderee/plugin-htmlparser2": "^0.10.0", + "deepmerge": "^4.2.2", + "dom-serializer": "^2.0.0", + "htmlparser2": "^8.0.1", + "selderee": "^0.10.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@react-email/render/node_modules/parseley": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/parseley/-/parseley-0.11.0.tgz", + "integrity": "sha512-VfcwXlBWgTF+unPcr7yu3HSSA6QUdDaDnrHcytVfj5Z8azAyKBDrYnSIfeSxlrEayndNcLmrXzg+Vxbo6DWRXQ==", + "dependencies": { + "leac": "^0.6.0", + "peberminta": "^0.8.0" + }, + "funding": { + "url": "https://ko-fi.com/killymxi" + } + }, + "node_modules/@react-email/render/node_modules/peberminta": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/peberminta/-/peberminta-0.8.0.tgz", + "integrity": "sha512-YYEs+eauIjDH5nUEGi18EohWE0nV2QbGTqmxQcqgZ/0g+laPCQmuIqq7EBLVi9uim9zMgfJv0QBZEnQ3uHw/Tw==", + "funding": { + "url": "https://ko-fi.com/killymxi" + } + }, + "node_modules/@react-email/render/node_modules/selderee": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/selderee/-/selderee-0.10.0.tgz", + "integrity": "sha512-DEL/RW/f4qLw/NrVg97xKaEBC8IpzIG2fvxnzCp3Z4yk4jQ3MXom+Imav9wApjxX2dfS3eW7x0DXafJr85i39A==", + "dependencies": { + "parseley": "^0.11.0" + }, + "funding": { + "url": "https://ko-fi.com/killymxi" + } + }, "node_modules/@rushstack/eslint-patch": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.5.1.tgz", @@ -942,12 +1000,14 @@ "dev": true }, "node_modules/@selderee/plugin-htmlparser2": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/@selderee/plugin-htmlparser2/-/plugin-htmlparser2-0.10.0.tgz", - "integrity": "sha512-gW69MEamZ4wk1OsOq1nG1jcyhXIQcnrsX5JwixVw/9xaiav8TCyjESAruu1Rz9yyInhgBXxkNwMeygKnN2uxNA==", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@selderee/plugin-htmlparser2/-/plugin-htmlparser2-0.11.0.tgz", + "integrity": "sha512-P33hHGdldxGabLFjPPpaTxVolMrzrcegejx+0GxjrIb9Zv48D8yAIA/QTDR2dFl7Uz7urX8aX6+5bCZslr+gWQ==", + "optional": true, + "peer": true, "dependencies": { "domhandler": "^5.0.3", - "selderee": "^0.10.0" + "selderee": "^0.11.0" }, "funding": { "url": "https://ko-fi.com/killymxi" @@ -4184,15 +4244,17 @@ } }, "node_modules/html-to-text": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-9.0.3.tgz", - "integrity": "sha512-hxDF1kVCF2uw4VUJ3vr2doc91pXf2D5ngKcNviSitNkhP9OMOaJkDrFIFL6RMvko7NisWTEiqGpQ9LAxcVok1w==", + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-9.0.5.tgz", + "integrity": "sha512-qY60FjREgVZL03vJU6IfMV4GDjGBIoOyvuFdpBDIX9yTlDw0TjxVBQp+P8NvpdIXNJvfWBTNul7fsAQJq2FNpg==", + "optional": true, + "peer": true, "dependencies": { - "@selderee/plugin-htmlparser2": "^0.10.0", - "deepmerge": "^4.2.2", + "@selderee/plugin-htmlparser2": "^0.11.0", + "deepmerge": "^4.3.1", "dom-serializer": "^2.0.0", - "htmlparser2": "^8.0.1", - "selderee": "^0.10.0" + "htmlparser2": "^8.0.2", + "selderee": "^0.11.0" }, "engines": { "node": ">=14" @@ -6870,12 +6932,14 @@ } }, "node_modules/parseley": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/parseley/-/parseley-0.11.0.tgz", - "integrity": "sha512-VfcwXlBWgTF+unPcr7yu3HSSA6QUdDaDnrHcytVfj5Z8azAyKBDrYnSIfeSxlrEayndNcLmrXzg+Vxbo6DWRXQ==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/parseley/-/parseley-0.12.1.tgz", + "integrity": "sha512-e6qHKe3a9HWr0oMRVDTRhKce+bRO8VGQR3NyVwcjwrbhMmFCX9KszEV35+rn4AdilFAq9VPxP/Fe1wC9Qjd2lw==", + "optional": true, + "peer": true, "dependencies": { "leac": "^0.6.0", - "peberminta": "^0.8.0" + "peberminta": "^0.9.0" }, "funding": { "url": "https://ko-fi.com/killymxi" @@ -6939,9 +7003,11 @@ } }, "node_modules/peberminta": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/peberminta/-/peberminta-0.8.0.tgz", - "integrity": "sha512-YYEs+eauIjDH5nUEGi18EohWE0nV2QbGTqmxQcqgZ/0g+laPCQmuIqq7EBLVi9uim9zMgfJv0QBZEnQ3uHw/Tw==", + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/peberminta/-/peberminta-0.9.0.tgz", + "integrity": "sha512-XIxfHpEuSJbITd1H3EeQwpcZbTLHc+VVr8ANI9t5sit565tsI4/xK3KWTUFE2e6QiangUkh3B0jihzmGnNrRsQ==", + "optional": true, + "peer": true, "funding": { "url": "https://ko-fi.com/killymxi" } @@ -7836,11 +7902,13 @@ } }, "node_modules/selderee": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/selderee/-/selderee-0.10.0.tgz", - "integrity": "sha512-DEL/RW/f4qLw/NrVg97xKaEBC8IpzIG2fvxnzCp3Z4yk4jQ3MXom+Imav9wApjxX2dfS3eW7x0DXafJr85i39A==", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/selderee/-/selderee-0.11.0.tgz", + "integrity": "sha512-5TF+l7p4+OsnP8BCCvSyZiSPc4x4//p5uPwK8TCnVPJYRmU2aYKMpOXvw8zM5a5JvuuCGN1jmsMwuU2W02ukfA==", + "optional": true, + "peer": true, "dependencies": { - "parseley": "^0.11.0" + "parseley": "^0.12.0" }, "funding": { "url": "https://ko-fi.com/killymxi" diff --git a/src/pages/blog/[slug].tsx b/src/app/blog/[slug]/page.tsx similarity index 81% rename from src/pages/blog/[slug].tsx rename to src/app/blog/[slug]/page.tsx index 526d485..668ee17 100644 --- a/src/pages/blog/[slug].tsx +++ b/src/app/blog/[slug]/page.tsx @@ -15,7 +15,56 @@ type Props = { comments: Comment[]; }; -export default function Post({ post, stats }: Props) { +export async function generateMetadata({ slug }: { slug: string }) { + const postData: NonNullablePostOptions = await getPostBySlug(slug, [ + 'title', + 'excerpt', + ]); + return { + title: postData.title, + description: postData.excerpt, + } +} + +export async function getStaticPaths() { + const slugs = await getPostSlugs(); + const paths = slugs.map(slug => { + return { + params: { + slug: slug.replace(/\.md$/, ''), // Remove file extension for each post slug + }, + }; + }); + + return { + paths, + fallback: false, + }; +} + +async function getPostData(slug: string) { + const postData: NonNullablePostOptions = await getPostBySlug(slug, [ + 'title', + 'date', + 'slug', + 'author', + 'content', + ]); + const parsedContent = await markdownToHtml(postData.content || ''); + const stats = readingTime(postData.content || ''); + return { + post: { + title: postData.title, + date: postData.date, + slug: postData.slug, + author: postData.author, + content: parsedContent, + }, + stats, + }; + +export default function Post({ slug }: { slug: string }) { + const post = await getPostData(slug); const router = useRouter(); if (!post.slug) throw router.push('/404'); @@ -64,53 +113,4 @@ export default function Post({ post, stats }: Props) { ); -} - -type Params = { - params: { - slug: string; - }; -}; - -export const getStaticProps = async ({ params }: Params) => { - const postData: NonNullablePostOptions = await getPostBySlug(params.slug, [ - 'title', - 'date', - 'slug', - 'author', - 'content', - ]); - - const parsedContent = await markdownToHtml(postData.content || ''); - const stats = readingTime(postData.content || ''); - if (!postData.slug) throw new Error('No slug found for post'); - - return { - props: { - post: { - title: postData.title, - date: postData.date, - slug: postData.slug, - author: postData.author, - content: parsedContent, - }, - stats, - }, - }; -}; - -export async function getStaticPaths() { - const slugs = await getPostSlugs(); - const paths = slugs.map(slug => { - return { - params: { - slug: slug.replace(/\.md$/, ''), // Remove file extension for each post slug - }, - }; - }); - - return { - paths, - fallback: false, - }; -} +} \ No newline at end of file diff --git a/src/app/blog/page.tsx b/src/app/blog/page.tsx new file mode 100644 index 0000000..76a0559 --- /dev/null +++ b/src/app/blog/page.tsx @@ -0,0 +1,56 @@ +import { getAllPosts } from 'lib/blogApi'; +import { type PostOptions } from '../../interfaces/post'; +import Link from 'next/link'; + +type Props = { + allPosts: PostOptions[]; +}; + +export const metadata = { + title: 'Blog list', + description: 'Blog Posts for Lucas Steinmacher', +}; + +export default function Blog({ allPosts }: Props) { + return ( + <> +
+
+ Blog +
{JSON.stringify(allPosts, null, 2)}
+
+

Blog Posts

+

+ Hey! You made it to the blog list! Thanks for checking this + out! +

+ +
+ + ); +} + +export const getStaticProps = async () => { + const allPosts = await getAllPosts(['date', 'slug']); + + return { + props: { allPosts }, + }; +}; diff --git a/src/pages/blog/index.tsx b/src/pages/blog/index.tsx deleted file mode 100644 index a042e60..0000000 --- a/src/pages/blog/index.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import { getAllPosts } from "lib/blogApi" -import { type PostOptions } from "../../interfaces/post" -import Link from "next/link" -import Head from "next/head" - -type Props = { - allPosts: PostOptions[] -} - -export default function Blog({ allPosts } : Props) { - return ( - <> - - Blog list - - - -
-
- Blog -
{JSON.stringify(allPosts, null, 2)}
-
-

Blog Posts

-

Hey! You made it to the blog list! Thanks for checking this out!

- -
- - ) -} - -export const getStaticProps = async () => { - const allPosts = await getAllPosts([ - 'date', - 'slug', - ]) - - return { - props: { allPosts }, - } - }