This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
import { GetStaticPaths, GetStaticProps } from "next";
|
||||
import fs from "fs";
|
||||
import { ParsedUrlQuery } from "querystring";
|
||||
import {
|
||||
BLOGS_PATH,
|
||||
getBlogContentBySlug,
|
||||
renderMarkdown,
|
||||
} from "../../utils/markdown";
|
||||
import { BLOGS_PATH, getBlogContentBySlug } from "../../utils/markdown";
|
||||
import { MarkdownRenderingResult } from "../../types/types";
|
||||
import { MainLayout } from "../../layouts/MainLayout";
|
||||
import Link from "next/link";
|
||||
import { IoMdArrowRoundBack as BackIcon } from "react-icons/io";
|
||||
import { BasicBlogProps } from ".";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import { MarkdownComponents } from "../../utils/reactmarkdown";
|
||||
import remarkGfm from "remark-gfm";
|
||||
import { PostHeader } from "../../components/PostHeader";
|
||||
import { readingTime } from "../../utils/general";
|
||||
|
||||
export const BlogArticle = ({ frontMatter, html }: MarkdownRenderingResult) => {
|
||||
const { title, author, date, description, authorLink } =
|
||||
frontMatter as BasicBlogProps;
|
||||
return (
|
||||
<MainLayout>
|
||||
<Link href="/blog">
|
||||
@@ -23,26 +21,21 @@ export const BlogArticle = ({ frontMatter, html }: MarkdownRenderingResult) => {
|
||||
<span>Go Back</span>
|
||||
</button>
|
||||
</Link>
|
||||
<div className="lg:mt-10 mt-4 mb-2 text-sm font-medium text-gray-500">
|
||||
{date}
|
||||
</div>
|
||||
<div className="lg:text-5xl font-bold">{title}</div>
|
||||
{author && (
|
||||
<div className="mt-2 font-medium">
|
||||
By{" "}
|
||||
{authorLink && (
|
||||
<Link href={authorLink} className="text-action">
|
||||
@{author}
|
||||
</Link>
|
||||
)}
|
||||
{!authorLink && <span className="text-action">@{author}</span>}
|
||||
</div>
|
||||
)}
|
||||
<div className="mt-2">{description}</div>
|
||||
<PostHeader frontMatter={frontMatter} estTime={readingTime(html)} />
|
||||
<div
|
||||
className="mt-4 prose prose-headings:text-primary-text prose-p:text-gray-400"
|
||||
dangerouslySetInnerHTML={{ __html: html }}
|
||||
/>
|
||||
className="
|
||||
prose prose-code:font-mono prose-code:text-gray-100 prose-code:bg-gray-700
|
||||
prose-code:p-1 prose-code:m-1 prose-code:rounded-md prose-headings:text-primary-text
|
||||
prose-p:text-gray-100 prose-img:w-full prose-img:h-auto xl:prose-img:max-h-96
|
||||
prose-img:object-cover prose-li:text-gray-300 prose-td:text-gray-400
|
||||
prose-a:text-action prose-strong:text-gray-50"
|
||||
>
|
||||
<ReactMarkdown
|
||||
components={MarkdownComponents}
|
||||
remarkPlugins={[remarkGfm]}
|
||||
children={html}
|
||||
/>
|
||||
</div>
|
||||
</MainLayout>
|
||||
);
|
||||
};
|
||||
@@ -65,11 +58,10 @@ export const getStaticProps: GetStaticProps<MarkdownRenderingResult> = async ({
|
||||
params,
|
||||
}) => {
|
||||
const markdownContent = getBlogContentBySlug(params?.slug as string);
|
||||
const renderedHTML = await renderMarkdown(markdownContent.content);
|
||||
return {
|
||||
props: {
|
||||
frontMatter: markdownContent.frontMatter,
|
||||
html: renderedHTML,
|
||||
html: markdownContent.content,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -4,16 +4,15 @@ import { Post, getAllBlogsFrontMatter } from "../../utils/markdown";
|
||||
import { FrontMatter } from "../../types/types";
|
||||
import Link from "next/link";
|
||||
import { formatDate } from "../../utils/general";
|
||||
import { BasicArticleProps } from "../../components/PostHeader";
|
||||
|
||||
export interface BasicBlogProps extends FrontMatter {
|
||||
title: string;
|
||||
description: string;
|
||||
date: string;
|
||||
author: string;
|
||||
authorLink: string;
|
||||
}
|
||||
|
||||
const BlogCard = ({ blog, slug }: { blog: BasicBlogProps; slug: string }) => {
|
||||
const BlogCard = ({
|
||||
blog,
|
||||
slug,
|
||||
}: {
|
||||
blog: BasicArticleProps;
|
||||
slug: string;
|
||||
}) => {
|
||||
return (
|
||||
<div className="p-4 rounded-md border border-gray-700">
|
||||
<div className="text-sm font-medium text-gray-500">
|
||||
@@ -39,7 +38,7 @@ const Blog = ({ posts }: { posts: Post[] }) => {
|
||||
{posts.map((post, index) => (
|
||||
<BlogCard
|
||||
key={index}
|
||||
blog={post.frontMatter as BasicBlogProps}
|
||||
blog={post.frontMatter as BasicArticleProps}
|
||||
slug={post.slug}
|
||||
/>
|
||||
))}
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
import { GetStaticPaths, GetStaticProps } from "next";
|
||||
import fs from "fs";
|
||||
import { ParsedUrlQuery } from "querystring";
|
||||
import {
|
||||
getProjectContentBySlug,
|
||||
PROJECTS_PATH,
|
||||
renderMarkdown,
|
||||
} from "../../utils/markdown";
|
||||
import { getProjectContentBySlug, PROJECTS_PATH } from "../../utils/markdown";
|
||||
import { MarkdownRenderingResult } from "../../types/types";
|
||||
import { MainLayout } from "../../layouts/MainLayout";
|
||||
import Link from "next/link";
|
||||
import { IoMdArrowRoundBack as BackIcon } from "react-icons/io";
|
||||
import { BasicProjectProps } from "../projects";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import remarkGfm from "remark-gfm";
|
||||
import { readingTime } from "../../utils/general";
|
||||
import { MarkdownComponents } from "../../utils/reactmarkdown";
|
||||
import { PostHeader } from "../../components/PostHeader";
|
||||
|
||||
export const ProjectArticle = ({
|
||||
frontMatter,
|
||||
html,
|
||||
}: MarkdownRenderingResult) => {
|
||||
const { title, author, date, description, authorLink } =
|
||||
frontMatter as BasicProjectProps;
|
||||
return (
|
||||
<MainLayout>
|
||||
<Link href="/projects">
|
||||
@@ -26,26 +24,22 @@ export const ProjectArticle = ({
|
||||
<span>Go Back</span>
|
||||
</button>
|
||||
</Link>
|
||||
<div className="lg:mt-10 mt-4 mb-2 text-sm font-medium text-gray-500">
|
||||
{date}
|
||||
</div>
|
||||
<div className="lg:text-5xl font-bold">{title}</div>
|
||||
{author && (
|
||||
<div className="mt-2 font-medium">
|
||||
By{" "}
|
||||
{authorLink && (
|
||||
<Link href={authorLink} className="text-action">
|
||||
@{author}
|
||||
</Link>
|
||||
)}
|
||||
{!authorLink && <span className="text-action">@{author}</span>}
|
||||
</div>
|
||||
)}
|
||||
<div className="mt-2 mb-10">{description}</div>
|
||||
|
||||
<PostHeader frontMatter={frontMatter} estTime={readingTime(html)} />
|
||||
<div
|
||||
className="prose prose-headings:text-primary-text prose-p:text-gray-400 prose-img:w-full prose-img:h-auto xl:prose-img:max-h-96 prose-img:object-cover"
|
||||
dangerouslySetInnerHTML={{ __html: html }}
|
||||
/>
|
||||
className="
|
||||
prose prose-code:font-mono prose-code:text-gray-100 prose-code:bg-gray-700
|
||||
prose-code:p-1 prose-code:m-1 prose-code:rounded-md prose-headings:text-primary-text
|
||||
prose-p:text-gray-100 prose-img:w-full prose-img:h-auto xl:prose-img:max-h-96
|
||||
prose-img:object-cover prose-li:text-gray-300 prose-td:text-gray-400
|
||||
prose-a:text-action prose-strong:text-gray-50"
|
||||
>
|
||||
<ReactMarkdown
|
||||
components={MarkdownComponents}
|
||||
remarkPlugins={[remarkGfm]}
|
||||
children={html}
|
||||
/>
|
||||
</div>
|
||||
</MainLayout>
|
||||
);
|
||||
};
|
||||
@@ -68,11 +62,10 @@ export const getStaticProps: GetStaticProps<MarkdownRenderingResult> = async ({
|
||||
params,
|
||||
}) => {
|
||||
const markdownContent = getProjectContentBySlug(params?.slug as string);
|
||||
const renderedHTML = await renderMarkdown(markdownContent.content);
|
||||
return {
|
||||
props: {
|
||||
frontMatter: markdownContent.frontMatter,
|
||||
html: renderedHTML,
|
||||
html: markdownContent.content,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,24 +1,15 @@
|
||||
import { GetServerSideProps } from "next";
|
||||
import { MainLayout } from "../../layouts/MainLayout";
|
||||
import { Post, getAllProjectsFrontMatter } from "../../utils/markdown";
|
||||
import { FrontMatter } from "../../types/types";
|
||||
import Link from "next/link";
|
||||
import { formatDate } from "../../utils/general";
|
||||
|
||||
export interface BasicProjectProps extends FrontMatter {
|
||||
title: string;
|
||||
description: string;
|
||||
date: string;
|
||||
author: string;
|
||||
authorLink: string;
|
||||
thumbnail: string;
|
||||
}
|
||||
import { BasicArticleProps } from "../../components/PostHeader";
|
||||
|
||||
const ProjectCard = ({
|
||||
project,
|
||||
slug,
|
||||
}: {
|
||||
project: BasicProjectProps;
|
||||
project: BasicArticleProps;
|
||||
slug: string;
|
||||
}) => {
|
||||
return (
|
||||
@@ -55,7 +46,7 @@ const Projects = ({ posts }: { posts: Post[] }) => {
|
||||
{posts.map((post, index) => (
|
||||
<ProjectCard
|
||||
key={index}
|
||||
project={post.frontMatter as BasicProjectProps}
|
||||
project={post.frontMatter as BasicArticleProps}
|
||||
slug={post.slug}
|
||||
/>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user