Skip to content

Commit af35861

Browse files
committed
Add dynamic content to posts
1 parent ea7f751 commit af35861

File tree

18 files changed

+4264
-1899
lines changed

18 files changed

+4264
-1899
lines changed

package-lock.json

Lines changed: 3616 additions & 1873 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,20 @@
1414
"@types/remark-prism": "^1.3.7",
1515
"gray-matter": "^4.0.3",
1616
"install": "^0.13.0",
17-
"next": "14.2.4",
17+
"next": "^14.2.23",
1818
"npm": "^10.8.2",
1919
"prism": "^1.0.0",
2020
"prismjs": "^1.29.0",
2121
"react": "^18",
2222
"react-dom": "^18",
23+
"reagraph": "^4.21.2",
2324
"rehype": "^13.0.1",
2425
"rehype-katex": "^7.0.0",
2526
"rehype-mathjax": "^6.0.0",
2627
"rehype-pretty-code": "^0.13.2",
2728
"rehype-raw": "^7.0.0",
29+
"rehype-react": "^8.0.0",
30+
"rehype-sanitize": "^6.0.0",
2831
"remark": "^15.0.1",
2932
"remark-html": "^16.0.1",
3033
"remark-math": "^6.0.0",

public/posts/data/test2.turing

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
0/m->1/m/R
2+
0/*->0/*/R
3+
4+
1/m->1/m/R
5+
1/u->2/u/R
6+
1/*->0/*/R
7+
8+
2/m->1/m/R
9+
2/*->0/*/R
10+
2/l->3/l/R
11+
12+
3/m->1/m/R
13+
3/*->0/*/R
14+
3/(->4/(/R

public/posts/test2.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ $$
2424
$$
2525
where $a_i=a_{i-1}+i$ for all $i\geq 1$ and $a_0=0$
2626

27-
This is it.
27+
# React Component Rendering
28+
<turing-machine label="String Detection" machine="/posts/data/test2.turing" tape="mul(3,9) "/>

src/app/globals.css

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ body {
3535
main {
3636
padding-bottom: 40px;
3737
min-height: calc(100vh - 168px);
38-
}
39-
40-
main>* {
41-
margin: 40px;
38+
max-width: 800px;
39+
margin: 0 auto;
40+
display: flex;
41+
flex-direction: column;
42+
gap: 40px;
43+
padding: 20px;
4244
}
4345

4446
main>section {
@@ -68,6 +70,16 @@ button {
6870
text-transform: capitalize;
6971
}
7072

73+
button:disabled {
74+
cursor: default;
75+
border: 2px solid var(--background-light-color);
76+
color: var(--background-light-color);
77+
}
78+
79+
button:disabled:hover {
80+
filter: none;
81+
}
82+
7183
button:hover {
7284
filter: brightness(0.7);
7385
}

src/app/page.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Link from "next/link";
1010
import { YearsSince } from "@/components/visual/CurrentYear";
1111
import Image from "next/image";
1212
import { ProjectCard } from "@/components/project/ProjectCard";
13+
import { Automota } from "@/components/visual/automota/AutomotaComponent";
1314

1415
const featuredProjects = [
1516
"mineclone",
@@ -33,6 +34,10 @@ export default function HomePage() {
3334
I am always open to learning new technologies and fields when I get the chance.</p>
3435
</section>
3536
</TwoCol>
37+
<Automota boardHeight={10} tileSize={20} ruleSet={{
38+
born: [3,4],
39+
survive: [3,4]
40+
}} />
3641
<TwoCol fit="none">
3742
<div>
3843
<h1>Experience</h1>

src/app/post/[id]/page.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,12 @@ export async function generateMetadata({params}: any, parent: ResolvingMetadata)
1010
const post = await renderMarkdownFile(`posts/${params.id}`);
1111

1212
const title = `${post.metadata.name || "Post"} | ${parentData.title?.absolute}`;
13-
const preview = (/<p>(.*?)<\/p>/g.exec(post.content) || ["", undefined])[1];
14-
1513

1614
return {
1715
title: title,
18-
description: preview,
1916
openGraph: {
2017
type: "article",
2118
title: title,
22-
description: preview,
2319
authors: post.metadata.author,
2420
publishedTime: post.metadata.date
2521
}
@@ -29,14 +25,18 @@ export async function generateMetadata({params}: any, parent: ResolvingMetadata)
2925
export default async function PostPage({params}: {params: {id: string}}) {
3026
const post = await renderMarkdownFile(`posts/${params.id}`);
3127

32-
return <main className={styles.page}>
28+
return <main className={styles.page} suppressHydrationWarning>
3329
{post.metadata.name && <h1 className={styles.titleLine}>{post.metadata.name}</h1>}
3430
<h2 className={styles.authorLine}>
3531
{post.metadata.author && <span>{post.metadata.author}</span>}
3632
{post.metadata.author && post.metadata.date && <span>&bull;</span>}
3733
{post.metadata.date && <span>{post.metadata.date}</span>}
3834
</h2>
39-
<div className={contentStyles.content} dangerouslySetInnerHTML={{__html: post.content}} />
35+
<div className={contentStyles.content}>
36+
{
37+
post.content
38+
}
39+
</div>
4040
</main>
4141
}
4242

src/app/project/[id]/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ export default async function ProjectPage({params}: {params: {id: string}}) {
5050
</div>
5151
<main>
5252
<h1 className={styles.title}>{project.metadata.name}</h1>
53-
<div className={contentStyles.content} dangerouslySetInnerHTML={{__html: project.content}} />
53+
<div className={contentStyles.content}>
54+
{
55+
project.content
56+
}
57+
</div>
5458
</main>
5559
</>
5660
}

src/components/navigation/NavBar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import { useEffect, useState } from "react";
77
import { usePathname } from "next/navigation";
88

99
export const NavBar = () => {
10-
const [isDesktop, setIsDesktop] = useState<boolean>(typeof window != "undefined" ? window.innerWidth >= 700 : true);
10+
const [isDesktop, setIsDesktop] = useState<boolean>(false);
1111
const [hamburgerOpen, setHamburgerOpen] = useState<boolean>(false);
1212

1313
useEffect(() => {
1414
window.addEventListener('resize', () => setIsDesktop(window.innerWidth >= 700));
15+
setIsDesktop(typeof window != "undefined" ? window.innerWidth >= 700 : true);
1516
}, [setIsDesktop]);
1617

1718
return <>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"use client"
2+
import { useState } from "react"
3+
4+
export const Counter = ({defaultvalue}: {defaultvalue: string}) => {
5+
const [value, setValue] = useState<number>(parseInt(defaultvalue));
6+
7+
return <button onClick={() => setValue(value + 1)}>
8+
{value}
9+
</button>
10+
}

0 commit comments

Comments
 (0)