Skip to content

Commit

Permalink
glob
Browse files Browse the repository at this point in the history
  • Loading branch information
soohoonc committed Aug 18, 2024
1 parent b0df393 commit 1c8304a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"caniuse-lite": "^1.0.30001649",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"glob": "^11.0.0",
"lucide-react": "^0.263.1",
"next": "^14.2.5",
"next-themes": "^0.2.1",
Expand Down
3 changes: 3 additions & 0 deletions public/b/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Test

hi there :)
7 changes: 7 additions & 0 deletions public/p/tabnam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Tabnam

this is the project we moved out to sf with.

it was dynamic product feedback forms and feedback analysis with, get this, **AI**.

tbf we've actually heard a surprising number of high quality founders have this exact idea as their first start up lol.
22 changes: 19 additions & 3 deletions src/app/p/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import fs from 'fs';
import path from 'path';
import glob from 'glob';
import { remark } from 'remark';
import html from 'remark-html';

export const dynamicParams = false;

export function generateStaticParams() {
const projects = [{ slug: 'test' }, { slug: '8bit' }, { slug: 'reviewr' }, { slug: 'tabnam' }];
return projects;
const projectFiles = glob.sync('public/p/*.md');
return projectFiles.map((file) => {
const slug = path.basename(file, '.md');
return { slug };
});
}

interface ProjectPageProps {
Expand All @@ -11,11 +20,18 @@ interface ProjectPageProps {
};
}

const Page = ({ params }: ProjectPageProps) => {
const Page = async ({ params }: ProjectPageProps) => {
const { slug } = params;
const filePath = path.join(process.cwd(), 'public', 'projects', `${slug}.md`);
const fileContent = fs.readFileSync(filePath, 'utf8');

const processedContent = await remark().use(html).process(fileContent);
const contentHtml = processedContent.toString();

return (
<div>
<h2>{slug}</h2>
{contentHtml}
</div>
);
};
Expand Down

0 comments on commit 1c8304a

Please sign in to comment.