diff --git a/src/app/c/[...slug]/content.module.css b/src/app/c/[...slug]/content.module.css index 2709655..db2c5d0 100644 --- a/src/app/c/[...slug]/content.module.css +++ b/src/app/c/[...slug]/content.module.css @@ -1,59 +1,58 @@ .md * { - @apply py-2 + @apply py-2; } .md ol { - @apply list-decimal list-inside + @apply list-decimal list-inside; } .md ul { - @apply list-disc list-inside + @apply list-disc list-inside; } .md hr { - @apply m-4 + @apply m-4; } .md blockquote { - @apply border-l-neutral-500 border-l-4 p-2 + @apply border-l-neutral-500 border-l-4 p-2; } .md blockquote p { - @apply before:content-['"'] after:content-['"'] + @apply before:content-['"'] after:content-['"']; } .md details { - @apply p-20 + @apply p-20; } .md code { - @apply rounded-lg + @apply rounded-lg; } .md h1 { - @apply text-6xl + @apply text-6xl; } .md h2 { - @apply text-5xl + @apply text-5xl; } .md h3 { - @apply text-4xl + @apply text-4xl; } .md h4 { - @apply text-3xl + @apply text-3xl; } .md h5 { - @apply text-2xl + @apply text-2xl; } .md h6 { - @apply text-xl + @apply text-xl; } .md a { - @apply underline text-teal-200 hover:text-cyan-500 + @apply underline text-teal-200 hover:text-cyan-500; } - diff --git a/src/app/c/[...slug]/page.tsx b/src/app/c/[...slug]/page.tsx index 64e2696..f46123c 100644 --- a/src/app/c/[...slug]/page.tsx +++ b/src/app/c/[...slug]/page.tsx @@ -1,4 +1,4 @@ -import styles from "./content.module.css" +import styles from "./content.module.css"; import { getAllPaths, getContent } from "$lib/content"; import Markdown from "react-markdown"; import remarkGfm from "remark-gfm"; @@ -9,19 +9,19 @@ import { notFound } from "next/navigation"; import Link from "next/link"; import CopyButton from "$components/copy-button"; import { getText } from "$lib/react"; -import { Prism as SyntaxHighlighter } from "react-syntax-highlighter" -import codeStyle from 'react-syntax-highlighter/dist/esm/styles/prism/coldark-dark' +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import codeStyle from "react-syntax-highlighter/dist/esm/styles/prism/coldark-dark"; type Params = { - slug: string[] -} + slug: string[]; +}; type Props = { - params: Params -} + params: Params; +}; export async function generateStaticParams(): Promise { - return getAllPaths().map(p => ({ slug: p.split("/") })) + return getAllPaths().map(p => ({ slug: p.split("/") })); } export default function Content({ params }: Props) { @@ -29,34 +29,34 @@ export default function Content({ params }: Props) { const { data, content } = getContent(params.slug); if (data.draft) { - notFound() + notFound(); } - const title = () => {data.title} + const title = () => {data.title}; const goal = () => - data.goal ? - ( -
-

The goal

- {data.goal} -
- ) : - ""; + data.goal ? ( +
+

The goal

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

My role

- {data.role} -
- ) : - ""; + data.role ? ( +
+

My role

+ {data.role} +
+ ) : ( + "" + ); - const date = () => data.date ? ({data.date}) : "" + const date = () => (data.date ? {data.date} : ""); - const ctnt = () => + const ctnt = () => ( - {alt!} + {alt!} - ) + ); }, a({ href, children, className }) { return ( - {children} - ) + + {children} + + ); }, pre({ children, className }) { return ( @@ -80,26 +87,24 @@ export default function Content({ params }: Props) {
{children}
- ) + ); }, code({ children, ref, className, node, ...rest }) { - const match = /language-(\w+)/.exec(className || '') + const match = /language-(\w+)/.exec(className || ""); return match ? ( - {getText(children)} + + {getText(children)} + ) : ( {children} - ) - } - }} - > + ); + }, + }}> {content}
+ ); return (
@@ -109,9 +114,7 @@ export default function Content({ params }: Props) { {role()} {date()}
-
- {ctnt()} -
+
{ctnt()}
- ) + ); } diff --git a/src/app/contact/page.tsx b/src/app/contact/page.tsx index a1df4f6..7031d11 100644 --- a/src/app/contact/page.tsx +++ b/src/app/contact/page.tsx @@ -2,12 +2,15 @@ import { faEnvelope } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; const email = "ivan@idimitrov.dev"; -const mailto = `mailto:${email}` -const Contact = () => +const mailto = `mailto:${email}`; +const Contact = () => (
- + + +
+); -export default Contact +export default Contact; diff --git a/src/app/globals.css b/src/app/globals.css index a64e960..28871cb 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -4,29 +4,28 @@ @layer components { .btn { - @apply bg-gray-900 transition ease-in duration-200 text-gray-300 hover:bg-gray-700/60 rounded-md px-3 py-2 text-sm + @apply bg-gray-900 transition ease-in duration-200 text-gray-300 hover:bg-gray-700/60 rounded-md px-3 py-2 text-sm; } } @layer utilities { .gradient { - @apply bg-gradient-to-br from-slate-950 via-red-700 to-yellow-400 + @apply bg-gradient-to-br from-slate-950 via-red-700 to-yellow-400; } } html * { - @apply scrollbar scrollbar-thin scrollbar-thumb-sky-400 + @apply scrollbar scrollbar-thin scrollbar-thumb-sky-400; } body { - @apply gradient text-slate-50 w-screen h-screen overflow-hidden + @apply gradient text-slate-50 w-screen h-screen overflow-hidden; } main { - @apply flex flex-col w-full h-full bg-slate-950/95 + @apply flex flex-col w-full h-full bg-slate-950/95; } svg { - @apply hover:text-sky-400 transition duration-200 ease-in + @apply hover:text-sky-400 transition duration-200 ease-in; } - diff --git a/src/app/layout.tsx b/src/app/layout.tsx index e19b22b..cdcb0a6 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,17 +1,13 @@ -import './globals.css' -import Navbar from '$components/navbar' -import type { Metadata } from 'next' +import "./globals.css"; +import Navbar from "$components/navbar"; +import type { Metadata } from "next"; export const metadata: Metadata = { title: "Ivan Dimitrov", description: "Freelance Software Developer", -} +}; -export default function RootLayout({ - children, -}: { - children: React.ReactNode -}) { +export default function RootLayout({ children }: { children: React.ReactNode }) { return ( @@ -21,5 +17,5 @@ export default function RootLayout({ - ) + ); } diff --git a/src/app/page.tsx b/src/app/page.tsx index 638d49b..327a5cc 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -5,18 +5,10 @@ import Link from "next/link"; const Home = () => (
- + - +
diff --git a/src/components/copy-button.tsx b/src/components/copy-button.tsx index 9ebb3d8..955ac78 100644 --- a/src/components/copy-button.tsx +++ b/src/components/copy-button.tsx @@ -1,28 +1,29 @@ -"use client" -import { faCheck, faCopy } from "@fortawesome/free-solid-svg-icons" -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" -import { useState } from "react" +"use client"; +import { faCheck, faCopy } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { useState } from "react"; type Props = { - text: string -} + text: string; +}; const CopyButton = ({ text }: Props) => { - const [visible, setVisible] = useState("invisible") + const [visible, setVisible] = useState("invisible"); return ( - ) -} + ); +}; export default CopyButton; diff --git a/src/components/navbar.tsx b/src/components/navbar.tsx index 20638e3..7161503 100644 --- a/src/components/navbar.tsx +++ b/src/components/navbar.tsx @@ -1,9 +1,9 @@ -"use client" +"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; const Navbar = () => { - const path = usePathname() + const path = usePathname(); const link = (text: string, href: string) => { return ( @@ -11,8 +11,8 @@ const Navbar = () => { {text}
- ) - } + ); + }; return (
@@ -21,8 +21,7 @@ const Navbar = () => { {link("Contact", "/contact")}
- ) -} + ); +}; - -export default Navbar +export default Navbar; diff --git a/src/lib/content.ts b/src/lib/content.ts index aa07891..960483c 100644 --- a/src/lib/content.ts +++ b/src/lib/content.ts @@ -2,18 +2,18 @@ import fs from "fs"; import matter, { GrayMatterFile } from "gray-matter"; import path from "path"; -export const baseDir = "./_content/" +export const baseDir = "./_content/"; export const getContent = (slug: string[]): GrayMatterFile => { - let p = path.join(baseDir) + let p = path.join(baseDir); slug.forEach(s => { - p = path.join(p, s) - }) - const file = fs.readFileSync(p, "utf8") + p = path.join(p, s); + }); + const file = fs.readFileSync(p, "utf8"); const m = matter(file); - m.data.slug = `/c/${slug.join("/")}` - return m -} + m.data.slug = `/c/${slug.join("/")}`; + return m; +}; const getAllPathsRecursive = (base = baseDir): string[] => { let results = [] as string[]; @@ -23,16 +23,21 @@ const getAllPathsRecursive = (base = baseDir): string[] => { const stat = fs.statSync(filePath); if (stat.isDirectory()) { results = results.concat(getAllPathsRecursive(filePath)); - } else if (path.extname(filePath) === '.md') { + } else if (path.extname(filePath) === ".md") { results.push(filePath); } } return results; -} +}; -export const getAllPaths = (base = baseDir): string[] => getAllPathsRecursive(base).map(p => p.substring(9)) +export const getAllPaths = (base = baseDir): string[] => getAllPathsRecursive(base).map(p => p.substring(9)); -export const getCases = (): GrayMatterFile[] => getAllPaths(`${baseDir}cases/`).map(s => s.split("/")).map(getContent) - -export const getAllContent = (): GrayMatterFile[] => getAllPaths().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/lib/react.ts b/src/lib/react.ts index fa238da..5ee23df 100644 --- a/src/lib/react.ts +++ b/src/lib/react.ts @@ -1,10 +1,10 @@ -import { ReactNode } from "react" +import { ReactNode } from "react"; export const getText = (node: ReactNode | any) => { - const props = node.props + const props = node.props; if (!props) { - return node + return node; } - const c = props.children || "" - return typeof c === "string" ? c : c.map(getText).join("") -} + const c = props.children || ""; + return typeof c === "string" ? c : c.map(getText).join(""); +};