diff --git a/_content/cases/stepsy.wiki.md b/_content/cases/stepsy.wiki.md index 600a5ec..e939ea1 100644 --- a/_content/cases/stepsy.wiki.md +++ b/_content/cases/stepsy.wiki.md @@ -3,6 +3,7 @@ title: Multi-tenant knowledge base website based on Google APIs goal: Create a modern multi-tenant web app that lets users use their Google Drive as a knowledge base role: Design and implement the web app date: Jul 29, 2023 - Nov 5, 2023 +z: 1 ---
diff --git a/_content/cases/wellsfargo.md b/_content/cases/wellsfargo.md new file mode 100644 index 0000000..0cb7eaf --- /dev/null +++ b/_content/cases/wellsfargo.md @@ -0,0 +1,8 @@ +--- +title: Wells Fargo Open Banking APIs integration +goal: +role: +date: Feb, 2021 - Aug, 2021 +z: 3 +draft: true +--- diff --git a/new.ts b/new.ts new file mode 100644 index 0000000..9a156b6 --- /dev/null +++ b/new.ts @@ -0,0 +1,28 @@ +import { baseDir, getAllContent } from "@/app/lib/content"; +import fs from "fs" + +const args = process.argv.slice(2) + +const path = args[0] + +if (!path) { + throw new Error("Path is needed!") +} + +const slug = path.split("/"); +const t = slug[slug.length - 1] + +const nextZ = Math.max.apply(Math, getAllContent().map(c => Number(c.data.z))) + 1 + +const meta = (title: string = t, goal: string = "", role: string = "", date: string = "", z: number = nextZ) => `--- +title: ${title} +goal: ${goal} +role: ${role} +date: ${date} +z: ${z} +draft: true +--- +` + +fs.writeFileSync(`${baseDir}${path}.md`, meta(), {flag: "w+"}) + diff --git a/package.json b/package.json index 615d5ed..97800ad 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "dev": "next dev", "build": "next build", "start": "next start", - "lint": "next lint" + "lint": "next lint", + "new": "bun new.ts" }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^6.4.2", diff --git a/src/app/c/[...slug]/page.tsx b/src/app/c/[...slug]/page.tsx index 84bc094..19d2e89 100644 --- a/src/app/c/[...slug]/page.tsx +++ b/src/app/c/[...slug]/page.tsx @@ -23,56 +23,47 @@ export default function Content({ params }: Props) { const imgSize = 1024; const { data, content } = getContent(params.slug); - const title = () => { - return ( - - {data.title} - - ) - } - const goal = () => { - const g = data.goal - return g ? + const title = () => + + {data.title} + + const goal = () => + data.goal ? (

The goal

- {g} + {data.goal}
) : "" - } - const role = () => { - const r = data.role - return r ? + const role = () => + data.role ? (

My role

- {r} + {data.role}
) : "" - } - const ctnt = () => { - return ( - - {alt!} - - ) - } - }} - > - {content} - - ) - } + const ctnt = () => + + {alt!} + + ) + } + }} + > + {content} + + return (
diff --git a/src/app/cases/page.tsx b/src/app/cases/page.tsx index 2503574..8a9414c 100644 --- a/src/app/cases/page.tsx +++ b/src/app/cases/page.tsx @@ -1,7 +1,5 @@ import Cases from "$components/cases"; -export default function CasesPage() { - return ( - - ) -} +const CasesPage = () => + +export default CasesPage diff --git a/src/app/components/cases.tsx b/src/app/components/cases.tsx index f210d37..b4dbf88 100644 --- a/src/app/components/cases.tsx +++ b/src/app/components/cases.tsx @@ -2,24 +2,16 @@ import { GrayMatterFile } from "gray-matter"; import Link from "next/link"; import { getCases } from "../lib/content"; -export default function Cases() { - const cases: GrayMatterFile[] = getCases() - return ( -
- {cases.map((c) => { - const d = c.data; - const date = d.date.split("-") - const from = date[0]?.trim() - const to = date[1]?.trim() - return ( -
- - {d.title} - {from} {to ? `- ${to}` : ""} - -
- ) - })} -
- ) -} +const cases: GrayMatterFile[] = getCases() +const Cases = () => +
+ {cases.filter(c => !c.data.draft).sort(c => c.data.z).map((c) => c.data).map((d) => +
+ + {d.title} + {d.date} + +
+ )} +
+export default Cases; diff --git a/src/app/components/links.tsx b/src/app/components/links.tsx index b9e647d..d781ee9 100644 --- a/src/app/components/links.tsx +++ b/src/app/components/links.tsx @@ -2,18 +2,16 @@ import { faGithub, faGitlab } from "@fortawesome/free-brands-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import Link from "next/link"; -export default function Links() { - - return ( -
-
- - - - - - -
+const Links = () => +
+
+ + + + + +
- ) -} +
+ +export default Links diff --git a/src/app/components/navbar.tsx b/src/app/components/navbar.tsx index 9c38739..4f1a9a1 100644 --- a/src/app/components/navbar.tsx +++ b/src/app/components/navbar.tsx @@ -2,24 +2,21 @@ import Link from "next/link"; import { usePathname } from "next/navigation"; -export default function Navbar() { +const link = (text: string, href: string) => { const path = usePathname() - - const link = (text: string, href: string) => { - return ( - - {text} - - ) - } - return ( -
-
- {link("Home", "/")} - {link("Cases", "/cases")} - {link("Contact", "/contact")} -
-
+ + {text} + ) } +const Navbar = () => +
+
+ {link("Home", "/")} + {link("Cases", "/cases")} + {link("Contact", "/contact")} +
+
+ +export default Navbar diff --git a/src/app/contact/page.tsx b/src/app/contact/page.tsx index 2027d13..77def2d 100644 --- a/src/app/contact/page.tsx +++ b/src/app/contact/page.tsx @@ -1,16 +1,13 @@ import { faEnvelope } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -export default function Contact() { - - const email = "ivan@idimitrov.dev"; - const mailto = `mailto:${email}` - - return ( -
-
- -
+const email = "ivan@idimitrov.dev"; +const mailto = `mailto:${email}` +const Contact = () => +
+
+
- ) -} +
+ +export default Contact diff --git a/src/app/lib/content.ts b/src/app/lib/content.ts index 3388e4a..aa07891 100644 --- a/src/app/lib/content.ts +++ b/src/app/lib/content.ts @@ -2,7 +2,7 @@ import fs from "fs"; import matter, { GrayMatterFile } from "gray-matter"; import path from "path"; -const baseDir = "./_content/" +export const baseDir = "./_content/" export const getContent = (slug: string[]): GrayMatterFile => { let p = path.join(baseDir) @@ -17,13 +17,10 @@ export const getContent = (slug: string[]): GrayMatterFile => { const getAllPathsRecursive = (base = baseDir): string[] => { let results = [] as string[]; - const files = fs.readdirSync(base); - for (const file of files) { const filePath = path.join(base, file); const stat = fs.statSync(filePath); - if (stat.isDirectory()) { results = results.concat(getAllPathsRecursive(filePath)); } else if (path.extname(filePath) === '.md') { @@ -33,11 +30,9 @@ const getAllPathsRecursive = (base = baseDir): string[] => { return results; } -export const getAllPaths = (base = baseDir): string[] => { - return getAllPathsRecursive(base).map(p => p.substring(9)) -} +export const getAllPaths = (base = baseDir): string[] => getAllPathsRecursive(base).map(p => p.substring(9)) -export const getCases = (): GrayMatterFile[] => { - return getAllPaths(`${baseDir}cases/`).map(s => s.split("/")).map(getContent) -} +export const getCases = (): GrayMatterFile[] => getAllPaths(`${baseDir}cases/`).map(s => s.split("/")).map(getContent) + +export const getAllContent = (): GrayMatterFile[] => getAllPaths().map(s => s.split("/")).map(getContent) diff --git a/src/app/page.tsx b/src/app/page.tsx index ea77018..5fa9fb6 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,7 +1,5 @@ import Links from "$components/links"; -export default function Home() { - return ( - - ) -} +const Home = () => + +export default Home;