diff --git a/src/blog/hello.md b/src/blog/hello.md deleted file mode 100644 index c7e94b9..0000000 --- a/src/blog/hello.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: Markdown Elements -date: 19/02/2023 ---- - -# Hi ~~Mars~~ Venus! - -## Hi ~~Mars~~ Venus! - -### Hi ~~Mars~~ Venus! - -#### Hi ~~Mars~~ Venus! - -##### Hi ~~Mars~~ Venus! - -_italics_ - -**bold** - -> blockquote - -1. Ordered -2. Lists - -- unordered -- lists - -`code` - -[A Link](../hello.md) - -![Alt Text](http://placekitten.com/1000/500) diff --git a/src/blog/markdown.md b/src/blog/markdown.md new file mode 100644 index 0000000..2ce17a1 --- /dev/null +++ b/src/blog/markdown.md @@ -0,0 +1,71 @@ +--- +title: Markdown Elements +date: 19-02-2023 +--- + +# Hi ~~Mars~~ Venus! 1 + +## Hi ~~Mars~~ Venus! 2 + +### Hi ~~Mars~~ Venus! 3 + +#### Hi ~~Mars~~ Venus! 4 + +##### Hi ~~Mars~~ Venus! 5 + +###### Hi ~~Mars~~ Venus! 6 + +_italics_ + +**bold** + +> blockquote + +1. Ordered +2. Lists + +- unordered +- lists + +`code` + +[A Link](../hello.md) + +![Alt Text](http://placekitten.com/1000/500) + +| Syntax | Description | +| --------- | ----------- | +| Header | Title | +| Paragraph | Text | + +--- + +# fenced code block + +``` +{ + "firstName": "John", + "lastName": "Smith", + "age": 25 +} +``` + + + + + + + + + + + + + + + diff --git a/src/blog/testing.md b/src/blog/testing.md new file mode 100644 index 0000000..6869448 --- /dev/null +++ b/src/blog/testing.md @@ -0,0 +1,6 @@ +--- +title: Testing +date: 19-02-2023 +--- + +# Hi ~~Mars~~ Venus! diff --git a/src/components/Header.tsx b/src/components/Header.tsx new file mode 100644 index 0000000..8c987d1 --- /dev/null +++ b/src/components/Header.tsx @@ -0,0 +1,38 @@ +import HeaderStyle from "@/styles/Header.module.sass" +import NextLink from "next/link" + + +const Header = ({ href, kind, title, asList = false, withArrow = true }: { href: string, kind: "h1" | "h2" | "h3" | "h4" | "h5" | "h6", title: string, asList?: boolean, withArrow?: boolean }) => { + let head; + switch (kind) { + case "h1": + head =

{title}{withArrow ? " ↗" : ""}

+ break; + case "h2": + head =

{title}{withArrow ? " ↗" : ""}

+ break; + case "h3": + head =

{title}{withArrow ? " ↗" : ""}

+ break; + case "h4": + head =

{title}{withArrow ? " ↗" : ""}

+ break; + case "h5": + head =
{title}{withArrow ? " ↗" : ""}
+ break; + case "h6": + head =
{title}{withArrow ? " ↗" : ""}
+ break; + + default: + break; + } + + return ( + + {head} + + ) +}; + +export default Header; \ No newline at end of file diff --git a/src/components/Image.tsx b/src/components/Image.tsx index af684a2..9fe67a9 100644 --- a/src/components/Image.tsx +++ b/src/components/Image.tsx @@ -1,3 +1,5 @@ + + const Image = ({ src, alt }: { src: string, alt: string }) => { return (
diff --git a/src/components/PostList.tsx b/src/components/PostList.tsx index 20461bc..a2db0b8 100644 --- a/src/components/PostList.tsx +++ b/src/components/PostList.tsx @@ -10,8 +10,11 @@ const PostList = ({ posts }: { diff --git a/src/pages/blog/[...slug].tsx b/src/pages/blog/[...slug].tsx index b115b54..57af202 100644 --- a/src/pages/blog/[...slug].tsx +++ b/src/pages/blog/[...slug].tsx @@ -9,9 +9,12 @@ import listFiles from "@/lib/listFiles"; import Markdown from 'markdown-to-jsx'; import Link from "@/components/Link"; import Image from "@/components/Image"; +import Header from "@/components/Header"; +import { useRouter } from 'next/router' -const Post = (props: { post: string }) => { - console.log(props.post) +const Post = (props: { post: string, slug: string }) => { + const router = useRouter() + console.log(router.asPath) let Index = (
@@ -20,17 +23,22 @@ const Post = (props: { post: string }) => { children={props.post} options={{ overrides: { - a: ({ ...props }) => , + a: ({ ...props }) => , img: ({ ...props }) => {props.alt}, p: ({ children, ...props }) => { const ParaComponent = children[0]?.type?.name === 'img' ? 'div' : 'p' return {children} - } + }, + // h1: ({ ...props }) =>
, + // h2: ({ ...props }) =>
, + // h3: ({ ...props }) =>
, + // h4: ({ ...props }) =>
, + // h5: ({ ...props }) =>
, + // h6: ({ ...props }) =>
, + // h6: ({ pass_this, ...props }) => { console.log("h6", { pass_this, props }) }, } }} /> - -
@@ -43,10 +51,12 @@ export default Post export async function getStaticProps(context: any) { let post = await remark() .use(remarkFrontmatter) - .process(await read(`${listFiles('./src/blog').filter(file => file.includes(context.params.slug))[0]}`)) + .process(await read(`${listFiles('./src/blog').find(file => file.includes(context.params.slug))}`)) + // .then(r => r.value.) return { props: { - post: (post.value as string).replace(/(---)\n*([a-zA-Z0-9\/_:\s*]*)*(---)/gmi, "") + post: (post.value as string).replace(/(---)\n*([a-zA-Z0-9\/_:-\s*]*)*/mi, ""), + slug: context.params.slug } } } @@ -54,10 +64,9 @@ export async function getStaticProps(context: any) { export async function getStaticPaths() { let path = './src/blog' - let paths = listFiles(path).map(file => file.replace(path, "/blog/").replace('.md', '').replace('.mdx', '')) - // console.log(paths) + let paths = listFiles(path).map(file => file.replace(path, "/blog").replace(/.mdx?/gmi, '')) return { paths, - fallback: 'blocking' + fallback: true } } \ No newline at end of file diff --git a/src/styles/Header.module.sass b/src/styles/Header.module.sass new file mode 100644 index 0000000..d92ff55 --- /dev/null +++ b/src/styles/Header.module.sass @@ -0,0 +1,11 @@ +@import "./_variables" + +.listLink, .link + color: $link + text-decoration: none + padding-top: .5rem + // padding-bottom: .5rem + padding-left: .5rem + border-radius: 8px + &:hover + background: $link-hover diff --git a/src/styles/Index.module.sass b/src/styles/Index.module.sass index 3648804..fc42bf9 100644 --- a/src/styles/Index.module.sass +++ b/src/styles/Index.module.sass @@ -9,6 +9,8 @@ #main padding-right: 2rem #blogMain - padding-right: 2rem + // padding-left: 2rem + @media (max-width:600px) + padding: 0 h1 padding: 0 0 1rem 0 diff --git a/src/styles/Link.module.sass b/src/styles/Link.module.sass index 22d93a5..269c63e 100644 --- a/src/styles/Link.module.sass +++ b/src/styles/Link.module.sass @@ -6,7 +6,6 @@ padding: .2rem border-radius: 8px &:hover - background: $link-hover .listLink diff --git a/src/styles/PostList.module.sass b/src/styles/PostList.module.sass index c38e0a8..45fe78c 100644 --- a/src/styles/PostList.module.sass +++ b/src/styles/PostList.module.sass @@ -4,4 +4,7 @@ .blog_post_row display: flex align-items: baseline + @media (max-width:600px) + display: block + // padding-left: 2rem diff --git a/src/styles/Sidebar.module.sass b/src/styles/Sidebar.module.sass index 6a72af1..8801e57 100644 --- a/src/styles/Sidebar.module.sass +++ b/src/styles/Sidebar.module.sass @@ -1,7 +1,7 @@ @import '_variables' #sidebar - margin-right: 2rem + min-width: 200px .me font-size: $h1-size diff --git a/src/styles/_variables.sass b/src/styles/_variables.sass index 68bbe04..d9bff63 100644 --- a/src/styles/_variables.sass +++ b/src/styles/_variables.sass @@ -1,8 +1,16 @@ // colors $dark: #222 + +$darker: #111 + +$darklight: #333 + $light: #ffffff + $link: #ff802c + $link-hover: #ff802c48 -// font sizes +// $h1-size: 1.6em +$border-radius: 10px diff --git a/src/styles/main.sass b/src/styles/main.sass index 4b5d894..44b861d 100644 --- a/src/styles/main.sass +++ b/src/styles/main.sass @@ -1,6 +1,6 @@ @import '_variables' -* +*:not(hr,table,th,td) padding: 0 margin: 0 text-decoration: none @@ -12,6 +12,7 @@ html color: $light font-size: 20px line-height: 1 + scroll-behavior: smooth @font-face font-family: "Flachbau" @@ -34,6 +35,8 @@ ul,ol section display: inline-block +// blog stuff + del text-decoration: line-through color: #555 @@ -44,7 +47,7 @@ ins blockquote padding-left: 15px - border-left: 3px solid #d7d7db + border-left: 5px solid #d7d7db font-size: 1rem figure @@ -54,3 +57,19 @@ figure margin: 1rem auto img max-width: 100% + +table + background-color: $darklight + color: $light + border-radius: $border-radius + th + // border-bottom: 5px solid $dark + text-align: left + th, td + padding: 1em !important + +pre:has(code) + background: $darker + padding: .5rem + // border-radius: $border-radius + border: 3px solid $darklight