added projects
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
rei
2022-12-29 13:42:04 +01:00
parent 446c4a4241
commit e545a596ec
9 changed files with 474 additions and 32 deletions

View File

@@ -3,7 +3,7 @@ import fs from "fs";
import { ParsedUrlQuery } from "querystring";
import {
BLOGS_PATH,
getFileContentBySlug,
getBlogContentBySlug,
renderMarkdown,
} from "../../utils/markdown";
import { MarkdownRenderingResult } from "../../types/types";
@@ -27,15 +27,17 @@ export const BlogArticle = ({ frontMatter, html }: MarkdownRenderingResult) => {
{date}
</div>
<div className="lg:text-5xl font-bold">{title}</div>
<div className="mt-2 font-medium">
By{" "}
{authorLink && (
<Link href={authorLink} className="text-action">
@{author}
</Link>
)}
{!authorLink && <span className="text-action">@{author}</span>}
</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>
<div
className="mt-4 prose prose-headings:text-primary-text prose-p:text-gray-400"
@@ -62,7 +64,7 @@ export const getStaticPaths: GetStaticPaths<BlogProps> = async () => {
export const getStaticProps: GetStaticProps<MarkdownRenderingResult> = async ({
params,
}) => {
const markdownContent = getFileContentBySlug(params?.slug as string);
const markdownContent = getBlogContentBySlug(params?.slug as string);
const renderedHTML = await renderMarkdown(markdownContent.content);
return {
props: {

View File

@@ -1,8 +1,9 @@
import { GetServerSideProps } from "next";
import { MainLayout } from "../../layouts/MainLayout";
import { BlogPost, getAllFilesFrontMatter } from "../../utils/markdown";
import { Post, getAllBlogsFrontMatter } from "../../utils/markdown";
import { FrontMatter } from "../../types/types";
import Link from "next/link";
import { formatDate } from "../../utils/general";
export interface BasicBlogProps extends FrontMatter {
title: string;
@@ -13,19 +14,10 @@ export interface BasicBlogProps extends FrontMatter {
}
const BlogCard = ({ blog, slug }: { blog: BasicBlogProps; slug: string }) => {
const format = (date: string) => {
const [day, month, year] = date.split(".");
const d = new Date(`${year}-${month}-${day}`);
return d.toLocaleDateString("en-US", {
month: "long",
day: "numeric",
year: "numeric",
});
};
return (
<div className="p-4 rounded-md border border-gray-700">
<div className="text-sm font-medium text-gray-500">
{format(blog.date)}
{formatDate(blog.date)}
</div>
<h2 className="text-2xl font-bold">{blog.title}</h2>
<p className="text-gray-400 text-lg">{blog.description}</p>
@@ -38,7 +30,7 @@ const BlogCard = ({ blog, slug }: { blog: BasicBlogProps; slug: string }) => {
);
};
const Blog = ({ posts }: { posts: BlogPost[] }) => {
const Blog = ({ posts }: { posts: Post[] }) => {
return (
<MainLayout>
<h1 className="text-3xl font-bold">Blog</h1>
@@ -57,7 +49,7 @@ const Blog = ({ posts }: { posts: BlogPost[] }) => {
};
export const getServerSideProps: GetServerSideProps = async () => {
const posts = getAllFilesFrontMatter();
const posts = getAllBlogsFrontMatter();
return {
props: {
posts,