diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..43a36ac --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "artifacts"] + path = artifacts + url = https://codeberg.org/ryanchristo/artifacts diff --git a/app/artifacts/essays/[id]/page.module.css b/app/artifacts/essays/[id]/page.module.css new file mode 100644 index 0000000..79ba582 --- /dev/null +++ b/app/artifacts/essays/[id]/page.module.css @@ -0,0 +1,24 @@ +.container { + composes: container from "../../../../styles/page.css"; +} + +.banner { + composes: banner from "../../../../styles/page.css"; +} + +.content { + composes: content from "../../../../styles/page.css"; +} + +.content { + text-align: center; +} + +.content h1 { + font-size: 1.6em; + margin: 1em 0; +} + +.content p { + margin: 1em 0; +} diff --git a/app/artifacts/essays/[id]/page.tsx b/app/artifacts/essays/[id]/page.tsx new file mode 100644 index 0000000..228ff94 --- /dev/null +++ b/app/artifacts/essays/[id]/page.tsx @@ -0,0 +1,37 @@ +import { Metadata } from "next"; + +import { getArtifact, getArtifacts } from "@utils"; + +import styles from "./page.module.css"; + +export const metadata: Metadata = { + title: "ryan christoffersen | artifacts", +}; + +export const generateStaticParams = () => { + return getArtifacts("essays"); +}; + +const ArtifactPage = async ({ params }: any) => { + const artifact = await getArtifact("essays", params.id); + return ( +
+
+
+
+

{`author: ${artifact.author}`}

+

{`title: ${artifact.title}`}

+

{`description: ${artifact.description}`}

+

{`created: ${artifact.created.toDateString()}`}

+

{`updated: ${artifact.updated.toDateString()}`}

+
+
+
+
+
+
+
+ ); +}; + +export default ArtifactPage; diff --git a/app/artifacts/film/[id]/page.module.css b/app/artifacts/film/[id]/page.module.css new file mode 100644 index 0000000..79ba582 --- /dev/null +++ b/app/artifacts/film/[id]/page.module.css @@ -0,0 +1,24 @@ +.container { + composes: container from "../../../../styles/page.css"; +} + +.banner { + composes: banner from "../../../../styles/page.css"; +} + +.content { + composes: content from "../../../../styles/page.css"; +} + +.content { + text-align: center; +} + +.content h1 { + font-size: 1.6em; + margin: 1em 0; +} + +.content p { + margin: 1em 0; +} diff --git a/app/artifacts/film/[id]/page.tsx b/app/artifacts/film/[id]/page.tsx new file mode 100644 index 0000000..529a272 --- /dev/null +++ b/app/artifacts/film/[id]/page.tsx @@ -0,0 +1,37 @@ +import { Metadata } from "next"; + +import { getArtifact, getArtifacts } from "@utils"; + +import styles from "./page.module.css"; + +export const metadata: Metadata = { + title: "ryan christoffersen | artifacts", +}; + +export const generateStaticParams = () => { + return getArtifacts("film"); +}; + +const ArtifactPage = async ({ params }: any) => { + const artifact = await getArtifact("film", params.id); + return ( +
+
+
+
+

{`author: ${artifact.author}`}

+

{`title: ${artifact.title}`}

+

{`description: ${artifact.description}`}

+

{`created: ${artifact.created.toDateString()}`}

+

{`updated: ${artifact.updated.toDateString()}`}

+
+
+
+
+
+
+
+ ); +}; + +export default ArtifactPage; diff --git a/app/artifacts/film/page.module.css b/app/artifacts/film/page.module.css deleted file mode 100644 index 4bd418c..0000000 --- a/app/artifacts/film/page.module.css +++ /dev/null @@ -1,11 +0,0 @@ -.container { - composes: container from "../../../styles/page.css"; -} - -.content { - composes: content from "../../../styles/page.css"; -} - -.content { - text-align: center; -} diff --git a/app/artifacts/film/page.tsx b/app/artifacts/film/page.tsx deleted file mode 100644 index b788671..0000000 --- a/app/artifacts/film/page.tsx +++ /dev/null @@ -1,107 +0,0 @@ -import { Metadata } from "next"; -import Link from "next/link"; - -import styles from "./page.module.css"; - -export const metadata: Metadata = { - title: "ryan christoffersen | artifacts", -}; - -const ArtifactsPage = () => { - return ( -
-
-

{"Rosa - These Storms | 2014"}

-

- {"Camera Operator"} -

-

- { - '"Rosa, a young Mayan woman, sits alone. She stares directly into the camera and for the first time has the courage to share her story. She has wrestled with rejection, forgiveness and the fight to keep her child alive. Now 27, she must overcome her past to follow dreams she once thought impossible."' - } -

-

- {"Photography, Cinematography"} -

-

- - {"more information"} - -

-
-

{"Alleviating Poverty in Vietnam | 2013"}

-

- {"Videographer"} -

-

- { - '"Alleviating Poverty in Vietnam is a short promotional video that explores a day in the life of Whole Planet Foundation\'s Field Director, Daniel Zoltani, as he visits one of their partners in Vietnam. Daniel visits Tao Yeu Mai (TYM) - the leading microfinance institution in Thai Nguyen Province of Northern Vietnam. Daniel and the TYM staff go out to meet with their clients."' - } -

-

- - { - "Production, Photography, Videography, Audio Recording, Video Editing" - } - -

-

- - {"watch video"} - -

-
-

{"Living on One Dollar | 2010 - 2012"}

-

- {"Co-Producer, Cinematographer, Assistant Editor"} -

-

- { - '"Living on One Dollar follows the experience of four young friends as they live on less than $1 a day for two months in rural Guatemala. They battle hunger, parasites and the realization that there are no easy answers. Yet, the generosity and strength of Rosa, a 20-year-old woman with her husband Anthony, and Chino, a 12-year-old boy gives them hope that there are ways to make a difference."' - } -

-

- - { - "Production, Photography, Cinematography, Audio Recording, Video Editing" - } - -

-

- - {"more information"} - -

-
-

{"Aspectator | 2010"}

-

- {"Co-Producer, Cinematographer"} -

-

- { - '"The subject of a psychology study begins to lose his identity when he decides to follow a woman whose presence deteriorates his sight while also invigorating his desire to rediscover himself."' - } -

-

- {"Production, Cinematography, Audio Recording, Video Editing"} -

-

- - {"watch trailer"} - -

-
-
- ); -}; - -export default ArtifactsPage; diff --git a/app/artifacts/page.module.css b/app/artifacts/page.module.css index 7571c22..58fef72 100644 --- a/app/artifacts/page.module.css +++ b/app/artifacts/page.module.css @@ -5,3 +5,21 @@ .content { composes: content from "../../styles/page.css"; } + +.content h2 { + font-size: 1.3em; + margin: 2em 0 1.5em 0; +} + +.content ul { + list-style: none inside none; +} + +.content li { + margin: 2em 0; +} + +.content p { + color: var(--color-text); + font-weight: 300; +} diff --git a/app/artifacts/page.tsx b/app/artifacts/page.tsx index 62c8879..c047bf9 100644 --- a/app/artifacts/page.tsx +++ b/app/artifacts/page.tsx @@ -1,39 +1,75 @@ import { Metadata } from "next"; import Link from "next/link"; +import { getArtifacts } from "@utils"; + import styles from "./page.module.css"; export const metadata: Metadata = { title: "ryan christoffersen | artifacts", }; -const ArtifactsPage = () => { +async function getArtifactsByGroup() { + return [ + { + group: "essays", + items: getArtifacts("essays").sort((a, b) => b.order - a.order), + }, + { + group: "film / video", + items: [...getArtifacts("film"), ...getArtifacts("videos")].sort( + (a, b) => b.order - a.order, + ), + }, + { + group: "software", + items: getArtifacts("software").sort((a, b) => b.order - a.order), + }, + ]; +} + +const ArtifactsPage = async () => { + const artifacts = await getArtifactsByGroup(); return (
-

{"artifacts"}

-

- {"What do artifacts do?"} -

-
-

{"essays"}

-

- {"maybe something soon"} -

-
-

{"film / video"}

-

- - {"just this page for now"} - -

-
-

{"software"}

-

- - {"just this page for now"} - -

+ {!artifacts.length ? ( +

+ {"failed to load artifacts"} +

+ ) : ( +
+ {artifacts.map(({ group, items }) => ( +
+

{group}

+
    + {items.map( + ({ + id, + category, + title, + description, + created, + updated, + }) => ( +
  • + +

    {title}

    +

    {description}

    +

    + {`created: ${created.toDateString()}`} + {" | "} + {`updated: ${updated.toDateString()}`} +

    + +
  • + ), + )} +
+
+ ))} +
+ )}
); diff --git a/app/artifacts/software/[id]/page.module.css b/app/artifacts/software/[id]/page.module.css new file mode 100644 index 0000000..79ba582 --- /dev/null +++ b/app/artifacts/software/[id]/page.module.css @@ -0,0 +1,24 @@ +.container { + composes: container from "../../../../styles/page.css"; +} + +.banner { + composes: banner from "../../../../styles/page.css"; +} + +.content { + composes: content from "../../../../styles/page.css"; +} + +.content { + text-align: center; +} + +.content h1 { + font-size: 1.6em; + margin: 1em 0; +} + +.content p { + margin: 1em 0; +} diff --git a/app/artifacts/software/[id]/page.tsx b/app/artifacts/software/[id]/page.tsx new file mode 100644 index 0000000..e859ab8 --- /dev/null +++ b/app/artifacts/software/[id]/page.tsx @@ -0,0 +1,37 @@ +import { Metadata } from "next"; + +import { getArtifact, getArtifacts } from "@utils"; + +import styles from "./page.module.css"; + +export const metadata: Metadata = { + title: "ryan christoffersen | artifacts", +}; + +export const generateStaticParams = () => { + return getArtifacts("software"); +}; + +const ArtifactPage = async ({ params }: any) => { + const artifact = await getArtifact("software", params.id); + return ( +
+
+
+
+

{`author: ${artifact.author}`}

+

{`title: ${artifact.title}`}

+

{`description: ${artifact.description}`}

+

{`created: ${artifact.created.toDateString()}`}

+

{`updated: ${artifact.updated.toDateString()}`}

+
+
+
+
+
+
+
+ ); +}; + +export default ArtifactPage; diff --git a/app/artifacts/software/page.module.css b/app/artifacts/software/page.module.css deleted file mode 100644 index 4bd418c..0000000 --- a/app/artifacts/software/page.module.css +++ /dev/null @@ -1,11 +0,0 @@ -.container { - composes: container from "../../../styles/page.css"; -} - -.content { - composes: content from "../../../styles/page.css"; -} - -.content { - text-align: center; -} diff --git a/app/artifacts/software/page.tsx b/app/artifacts/software/page.tsx deleted file mode 100644 index 489bd62..0000000 --- a/app/artifacts/software/page.tsx +++ /dev/null @@ -1,269 +0,0 @@ -import { Metadata } from "next"; -import Link from "next/link"; - -import styles from "./page.module.css"; - -export const metadata: Metadata = { - title: "ryan christoffersen | artifacts", -}; - -const ArtifactsPage = () => { - return ( -
-
-

{"Chora AI | 2026 - Present"}

-

- {"Software Engineer, Protocol Researcher"} -

-

- { - "Chora AI is focused on local-first and privacy-preserving tools and infrastructure for building and managing agents. Chora AI is a project of Chora Studio that feeds back into research on agentic systems." - } -

-

- {"Rust, LLMs"} -

-

- {/* - {"website"} - - {" | "}*/} - - {"source"} - -

-
-

{"Chora Studio | 2024 - Present"}

-

- {"Owner, Software Engineer, Protocol Researcher"} -

-

- { - "Chora Studio is a software research and development company building software for decentralized protocols and agentic systems. Chora Studio also offers software research and development as a service." - } -

-

- {"Rust, LLMs, Go, TypeScript, Cosmos"} -

-

- - {"website"} - - {" | "} - - {"source"} - -

-
-

{"Regen Network | 2021 - 2023"}

-

- - {"Technical Product Manager, Software Engineer, Network Operations"} - -

-

- { - "Regen Network aligns economics with ecology to drive regenerative land management. I primarily worked on Regen Ledger and Cosmos SDK, the underlying blockchain infrastructure for Regen Network." - } -

-

- {"Go, TypeScript, Cosmos"} -

-

- - {"website"} - - {" | "} - - {"source"} - -

-
-

{"Chora | 2020 - 2023"}

-

- {"Software Engineer, Protocol Researcher"} -

-

- { - "Chora is software for commons governance and ecological regeneration built with distributed ledger technology. Chora started out as an evolving side project that later became a project of Chora Studio." - } -

-

- {"Go, TypeScript, Cosmos"} -

-

- - {"website"} - - {" | "} - - {"source"} - -

-
-

{"ChainSafe | 2019 - 2020"}

-

- {"Software Engineer, Protocol Researcher"} -

-

- { - "ChainSafe is a team of developers building tools and infrastructure for a variety of decentralized protocols. I primarily worked on Gossamer, a node client implementation for the Polkadot network written in Go." - } -

-

- {"Go, Polkadot, Solidity, Ethereum"} -

-

- - {"website"} - - {" | "} - - {"source"} - -

-
-

{"Colony | 2018 - 2019"}

-

- {"Developer Relations Manager, Software Engineer"} -

-

- { - "Colony is a platform for open organizations built on Ethereum. I helped build and maintain developer tools, wrote documentation, explored integrations, and managed developer relations." - } -

-

- {"JavaScript, React, Redux, Webpack, IPFS, Solidity, Ethereum"} -

-

- - {"website"} - - {" | "} - - {"source"} - -

-
-

{"Chora | 2018"}

-

- {"Software Engineer"} -

-

- { - "Chora was a project I created to learn about and explore Ethereum. The demo application allowed users to create organizations, projects, and tasks using smart contracts on the Ethereum network." - } -

-

- {"JavaScript, React, Redux, Webpack, Solidity, Ethereum"} -

-
-

{"Horizon App | 2017 - 2018"}

-

- {"Full Stack Engineer"} -

-

- { - "Horizon App uses groups and mutual friends to help members find people and places to stay. I designed and developed the web application, rebuilt the latest version of the API, and integrated email services." - } -

-

- {"JavaScript, React, Redux, Webpack, Ruby, Rails, PostgreSQL"} -

-
-

{"Ushahidi | 2017"}

-

- {"Full Stack Engineer"} -

-

- { - "Ushahidi is a crowdsourcing application with a focus on disaster response that makes it easy to collect and visualize data on a map. I volunteered for three months implementing features and fixing bugs." - } -

-

- {"JavaScript, AngularJS, PHP"} -

-
-

{"Joglo Northwest | 2017"}

-

- {"Full Stack Engineer"} -

-

- { - "Joglo Northwest is a small business that buys and sells Indonesian art, furniture and stone. I rebuilt the website and content management system using my very own simple-cms as the foundation (see below)." - } -

-

- {"JavaScript, React, Redux, Webpack, Node, Express, MongoDB"} -

-
-

{"Simple CMS | 2017"}

-

- {"Full Stack Engineer"} -

-

- { - "After working my way through freeCodeCamp, I developed Simple CMS to test my skills on a larger project - a simple yet customizable content management system for small businesses and freelancers." - } -

-

- {"JavaScript, React, Redux, Webpack, Node, Express, MongoDB"} -

-
-

{"freeCodeCamp | 2016 - 2017"}

-

- {"Full Stack Engineer"} -

-

- { - "To advance my skills, I worked my way through the freeCodeCamp coursework and projects. The freeCodeCamp curriculum focuses on full-stack development with React, Node, Express, and MongoDB." - } -

-

- {"JavaScript, React, Redux, Webpack, Node, Express, MongoDB"} -

-
-

{"Joglo Northwest | 2014"}

-

- {"Web Developer"} -

-

- { - "Joglo Northwest is a small business that buys and sells Indonesian art, furniture, and stone. I designed and developed a simple gallery website with a custom content management system and integrated email services." - } -

-

- {"HTML, CSS, JavaScript, PHP, SQL"} -

-
-

{"Ancient Greek | 2014"}

-

- {"Web Developer"} -

-

- { - "Ancient Greek was a web application for learning Ancient Greek. The app included a dictionary, interactive reading exercises, and flashcards for practicing vocabulary, verb conjugations, and noun declensions." - } -

-

- {"HTML, CSS, JavaScript, PHP, SQL"} -

-
-

{"Documentary Art Network | 2013"}

-

- {"Web Developer"} -

-

- { - "Documentary Art Network was a professional network for documentary artists. Users could post articles and stories, discuss ideas, find people to collaborate with, and rent or exchange equipment." - } -

-

- {"HTML, CSS, JavaScript, PHP, SQL"} -

-
-
- ); -}; - -export default ArtifactsPage; diff --git a/app/artifacts/video/[id]/page.module.css b/app/artifacts/video/[id]/page.module.css new file mode 100644 index 0000000..79ba582 --- /dev/null +++ b/app/artifacts/video/[id]/page.module.css @@ -0,0 +1,24 @@ +.container { + composes: container from "../../../../styles/page.css"; +} + +.banner { + composes: banner from "../../../../styles/page.css"; +} + +.content { + composes: content from "../../../../styles/page.css"; +} + +.content { + text-align: center; +} + +.content h1 { + font-size: 1.6em; + margin: 1em 0; +} + +.content p { + margin: 1em 0; +} diff --git a/app/artifacts/video/[id]/page.tsx b/app/artifacts/video/[id]/page.tsx new file mode 100644 index 0000000..196264d --- /dev/null +++ b/app/artifacts/video/[id]/page.tsx @@ -0,0 +1,37 @@ +import { Metadata } from "next"; + +import { getArtifact, getArtifacts } from "@utils"; + +import styles from "./page.module.css"; + +export const metadata: Metadata = { + title: "ryan christoffersen | artifacts", +}; + +export const generateStaticParams = () => { + return getArtifacts("videos"); +}; + +const ArtifactPage = async ({ params }: any) => { + const artifact = await getArtifact("videos", params.id); + return ( +
+
+
+
+

{`author: ${artifact.author}`}

+

{`title: ${artifact.title}`}

+

{`description: ${artifact.description}`}

+

{`created: ${artifact.created.toDateString()}`}

+

{`updated: ${artifact.updated.toDateString()}`}

+
+
+
+
+
+
+
+ ); +}; + +export default ArtifactPage; diff --git a/app/globals.css b/app/globals.css index 80ee34a..907674d 100644 --- a/app/globals.css +++ b/app/globals.css @@ -62,9 +62,9 @@ --transition: 0.25s; /* light theme */ - --background-primary: rgb(245, 245, 245); /* #F5F5F5 */ - --box-shadow: 0 0 3px rgb(200, 200, 200); /* #C8C8C8 */ - --box-shadow-color: rgb(200, 200, 200); /* #C8C8C8 */ + --background-primary: rgb(255, 255, 255); /* #FFFFFF */ + --box-shadow: 0 0 3px rgb(230, 230, 230); /* #C8C8C8 */ + --box-shadow-color: rgb(230, 230, 230); /* #C8C8C8 */ --color-text: rgb(25, 25, 25); /* #191919 */ } @@ -72,7 +72,7 @@ --background-primary: rgb(25, 25, 25); /* #191919 */ --box-shadow: 0 0 3px rgb(75, 75, 75); /* #4B4B4B */ --box-shadow-color: rgb(75, 75, 75); /* #4B4B4B */ - --color-text: rgb(245, 245, 245); /* #F5F5F5 */ + --color-text: rgb(255, 255, 255); /* #FFFFFF */ } * { @@ -99,7 +99,7 @@ h2, h3, h4, h5 { - font-weight: 400; + font-weight: 300; } p, @@ -110,7 +110,6 @@ li { a, a:active { color: var(--color-theme); - font-weight: 400; text-decoration: none; transition: var(--transition); } diff --git a/app/page.module.css b/app/page.module.css index 2341542..def294c 100644 --- a/app/page.module.css +++ b/app/page.module.css @@ -6,6 +6,33 @@ composes: content from "../styles/page.css"; } -.item { - composes: item from "../styles/page.css"; +.content h2 { + font-size: 1.3em; + margin: 2em 0 1.5em 0; +} + +.content h3 { + font-size: 1.1em; + margin: 1em 0; +} + +.content hr { + margin: 5vh 0; +} + +.content p { + margin: 1em 0; +} + +.content div { + margin: 2em 0; +} + +.content ul { + list-style-position: inside; + margin: 1em 0; +} + +.content li { + margin: 0.5em 0; } diff --git a/app/page.tsx b/app/page.tsx index 877e2cb..66eb09a 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -92,7 +92,7 @@ const HomePage = () => {

{"public accounts"}

{ - "I take a minimalist approach to social media and other platforms. All public accounts that I'm actively using are listed here:" + "I take a minimalist approach to social media and other platforms. All public accounts that I'm actively (or occasionally) using are listed here:" }

    diff --git a/artifacts b/artifacts new file mode 160000 index 0000000..65a118e --- /dev/null +++ b/artifacts @@ -0,0 +1 @@ +Subproject commit 65a118e4a27b93f175018506952f754f7b4d1100 diff --git a/bun.lockb b/bun.lockb old mode 100644 new mode 100755 index a103191..ee23e92 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/icons/ThemeIcon.tsx b/components/icons/ThemeIcon.tsx index d5b86a8..82fda9b 100644 --- a/components/icons/ThemeIcon.tsx +++ b/components/icons/ThemeIcon.tsx @@ -3,13 +3,13 @@ import * as React from "react"; const ThemeIcon = ({ darkTheme }: any) => ( - - + + ); diff --git a/package.json b/package.json index 6548dfd..147df31 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,12 @@ "clean": "rm -rf .next dist node_modules" }, "dependencies": { + "gray-matter": "^4", "next": "^14", "react": "^18", - "react-dom": "^18" + "react-dom": "^18", + "remark": "^15", + "remark-html": "^16" }, "devDependencies": { "@types/node": "^20", @@ -34,6 +37,7 @@ "eslint-config-next": "^14", "postcss": "^8", "prettier": "^3", + "sharp": "^0.33", "typescript": "^5" } } diff --git a/styles/page.css b/styles/page.css index e70f872..c667ce3 100644 --- a/styles/page.css +++ b/styles/page.css @@ -10,6 +10,34 @@ padding-top: var(--header-height); } +/* banner */ + +.banner { + align-items: center; + display: flex; + font-size: 1em; + justify-content: center; + min-height: 10vh; + padding: 2em 0; + text-align: center; +} + +@media (max-width: 850px) { + .banner { + font-size: 1em; + } +} + +.banner p { + padding: 0.2em 0; +} + +@media (max-width: 850px) { + .banner p { + padding: 0.15em 0 !important; + } +} + /* content */ .content { @@ -25,39 +53,3 @@ width: auto; } } - -.content h1 { - font-size: 1.6em; - margin: 1em 0; -} - -.content h2 { - font-size: 1.3em; - margin: 1em 0; -} - -.content h3 { - font-size: 1em; - margin: 1em 0; -} - -.content hr { - margin: 5vh 0; -} - -.content p { - margin: 1em 0; -} - -.content div { - margin: 2em 0; -} - -.content ul { - list-style-position: inside; - margin: 1em 0; -} - -.content li { - margin: 0.5em 0; -} diff --git a/tsconfig.json b/tsconfig.json index f3c0970..ec4f671 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,7 +21,8 @@ ], "paths": { "@components/*": ["components/*"], - "@contexts": ["contexts"] + "@contexts": ["contexts"], + "@utils": ["utils"] } }, "include": [ diff --git a/utils/getArtifact.ts b/utils/getArtifact.ts new file mode 100644 index 0000000..8651cd2 --- /dev/null +++ b/utils/getArtifact.ts @@ -0,0 +1,27 @@ +import fs from "fs"; +import path from "path"; +import matter from "gray-matter"; +import { remark } from "remark"; +import html from "remark-html"; + +const root = path.join(process.cwd(), "artifacts"); + +export async function getArtifact(dir: string, id: string) { + const fullPath = path.join(root, dir, `${id}.md`); + + // read file contents + const fileContents = fs.readFileSync(fullPath, "utf8"); + + // parse file contents + const { content, data } = matter(fileContents); + + // convert markdown to html + const processedContent = await remark().use(html).process(content); + + // return id, content, and data + return { + id, + content: processedContent.toString(), + ...data, + } as any; +} diff --git a/utils/getArtifacts.ts b/utils/getArtifacts.ts new file mode 100644 index 0000000..21c9038 --- /dev/null +++ b/utils/getArtifacts.ts @@ -0,0 +1,31 @@ +import fs from "fs"; +import path from "path"; +import matter from "gray-matter"; + +const root = path.join(process.cwd(), "artifacts"); + +export const getArtifacts = (dir: string) => { + const fileNames = fs.readdirSync(root + "/" + dir); + + const filtered = fileNames.filter((fileName) => fileName.includes(`.md`)); + + return filtered.map((fileName) => { + // set id + const id = fileName.replace(/\.md$/, ""); + + // set full path + const fullPath = path.join(root, dir, fileName); + + // read file contents + const fileContents = fs.readFileSync(fullPath, "utf8"); + + // parse file contents + const { data } = matter(fileContents); + + // return id and data + return { + id, + ...data, + }; + }) as any[]; +}; diff --git a/utils/index.ts b/utils/index.ts new file mode 100644 index 0000000..5441782 --- /dev/null +++ b/utils/index.ts @@ -0,0 +1,2 @@ +export { getArtifact } from "./getArtifact"; +export { getArtifacts } from "./getArtifacts";