dark mode and light mode support

This commit is contained in:
rei
2022-12-30 15:01:25 +01:00
parent d397503c66
commit 4d9092ae3d
10 changed files with 148 additions and 146 deletions

View File

@@ -6,36 +6,21 @@ import { MarkdownRenderingResult } from "../../types/types";
import { MainLayout } from "../../layouts/MainLayout";
import Link from "next/link";
import { IoMdArrowRoundBack as BackIcon } from "react-icons/io";
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";
import { StyledMarkdown } from "../../components/StyledMarkdown";
export const BlogArticle = ({ frontMatter, html }: MarkdownRenderingResult) => {
return (
<MainLayout>
<Link href="/blog">
<button className="flex flex-row items-center gap-2 text-secondary hover:text-secondary/50 transition-all ease-in duration-75">
<button className="flex flex-row items-center gap-2 text-primary hover:text-primary-dark dark:text-secondary dark:hover:text-secondary/50 transition-all ease-in duration-75">
<BackIcon />
<span>Go Back</span>
</button>
</Link>
<PostHeader frontMatter={frontMatter} estTime={readingTime(html)} />
<div
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>
<StyledMarkdown html={html} />
</MainLayout>
);
};

View File

@@ -1,7 +1,6 @@
import { GetServerSideProps } from "next";
import { MainLayout } from "../../layouts/MainLayout";
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";
@@ -14,12 +13,14 @@ const BlogCard = ({
slug: string;
}) => {
return (
<div className="p-4 rounded-md border border-gray-700">
<div className="p-4 rounded-md border border-gray-200 shadow-md shadow-gray-200 dark:border-gray-700">
<div className="text-sm font-medium text-gray-500">
{formatDate(blog.date)}
</div>
<h2 className="text-2xl font-bold">{blog.title}</h2>
<p className="text-gray-400 text-lg">{blog.description}</p>
<p className="text-gray-600 dark:text-gray-400 text-lg">
{blog.description}
</p>
<Link href={`blog/${slug}`}>
<button className="bg-action px-2 py-1 rounded-md mt-4 hover:bg-action/60 transition-all ease-in duration-100 font-bold text-white">
Read more
@@ -32,9 +33,9 @@ const BlogCard = ({
const Blog = ({ posts }: { posts: Post[] }) => {
return (
<MainLayout>
<h1 className="text-3xl font-bold">Blog</h1>
<div className="w-full h-0.5 bg-white/50 my-4 rounded-full" />
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<h1 className="text-3xl font-bold text-gray-800">Blog</h1>
<div className="w-full h-0.5 bg-gray-200 dark:bg-gray-800 my-4 rounded-full" />
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
{posts.map((post, index) => (
<BlogCard
key={index}

View File

@@ -6,11 +6,9 @@ import { MarkdownRenderingResult } from "../../types/types";
import { MainLayout } from "../../layouts/MainLayout";
import Link from "next/link";
import { IoMdArrowRoundBack as BackIcon } from "react-icons/io";
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";
import { StyledMarkdown } from "../../components/StyledMarkdown";
export const ProjectArticle = ({
frontMatter,
@@ -19,27 +17,15 @@ export const ProjectArticle = ({
return (
<MainLayout>
<Link href="/projects">
<button className="flex flex-row items-center gap-2 text-secondary hover:text-secondary/50 transition-all ease-in duration-75">
<button className="flex flex-row items-center gap-2 text-primary hover:text-primary-dark dark:text-secondary dark:hover:text-secondary/50 transition-all ease-in duration-75">
<BackIcon />
<span>Go Back</span>
</button>
</Link>
<PostHeader frontMatter={frontMatter} estTime={readingTime(html)} />
<div
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>
<StyledMarkdown html={html} />
</MainLayout>
);
};

View File

@@ -13,13 +13,15 @@ const ProjectCard = ({
slug: string;
}) => {
return (
<div className="p-4 rounded-md border border-gray-700 grid grid-cols-1 xl:grid-cols-2 items-center gap-4">
<div className="p-4 rounded-md border border-gray-200 shadow-md shadow-gray-200 dark:border-gray-700 grid grid-cols-1 xl:grid-cols-2 items-center gap-4">
<div className="order-last xl:order-1">
<div className="text-sm font-medium text-gray-500">
{formatDate(project.date)}
</div>
<h2 className="text-2xl font-bold">{project.title}</h2>
<p className="text-gray-400 text-lg">{project.description}</p>
<p className="text-gray-600 dark:text-gray-400 text-lg">
{project.description}
</p>
<Link href={`project/${slug}`}>
<button className="bg-action px-2 py-1 rounded-md mt-4 hover:bg-action/60 transition-all ease-in duration-100 font-bold text-white">
Read more
@@ -40,8 +42,8 @@ const ProjectCard = ({
const Projects = ({ posts }: { posts: Post[] }) => {
return (
<MainLayout>
<h1 className="text-3xl font-bold">Projects</h1>
<div className="w-full h-0.5 bg-white/50 my-4 rounded-full" />
<h1 className="text-3xl font-bold text-gray-800">Projects</h1>
<div className="w-full h-0.5 bg-gray-200 dark:bg-gray-800 my-4 rounded-full" />
<div className="grid grid-cols-1 gap-4">
{posts.map((post, index) => (
<ProjectCard