redo the NoJS stuff

This commit is contained in:
Lio 2023-05-27 10:57:07 +02:00
parent c652fd1575
commit ba9c217156
3 changed files with 53 additions and 49 deletions

View file

@ -15,31 +15,33 @@ const Post = (props: { post: string, slug: string, matter: any }) => {
// console.log(props.matter)
let Index = (
<main id={index.layout}>
<Head>
<title>{props.matter}</title>
</Head>
<Sidebar />
<section id={index.main}>
<Markdown
children={props.post}
options={{
overrides: {
a: ({ ...props }) => <Link href={props.href} title={props.children} withArrow />,
img: ({ ...props }) => <Image src={props.src} alt={props.alt} />,
p: ({ children, ...props }) => {
const ParaComponent = children[0]?.type?.name === 'img' ? 'div' : 'p'
return <ParaComponent {...props}>{children}</ParaComponent>
},
}
}}
/>
</section>
<Lanyard />
</main>
return (
<RenderWithoutJS>
<main id={index.layout}>
<Head>
<title>{props.matter.title} | lio's blog</title>
</Head>
<Sidebar />
<section id={index.main}>
<Markdown
children={props.post}
options={{
overrides: {
a: ({ ...props }) => <Link href={props.href} title={props.children} withArrow />,
img: ({ ...props }) => <Image src={props.src} alt={props.alt} />,
p: ({ children, ...props }) => {
const ParaComponent = children[0]?.type?.name === 'img' ? 'div' : 'p'
return <ParaComponent {...props}>{children}</ParaComponent>
},
}
}}
/>
</section>
<Lanyard />
</main>
</RenderWithoutJS>
);
return <RenderWithoutJS children={Index} />
};
export default Post
@ -50,7 +52,7 @@ export async function getStaticProps(context: any) {
.process(await read(`${listFiles('./src/blog').find(file => file.includes(context.params.slug))}`))
return {
props: {
post: (post.value as string).replace(/(---)\n*([a-zA-Z0-9\/\[\]\"_:,\-\s*]*)*/mi, ""),
post: (post.value as string).replace(/^(---)\n*([a-zA-Z0-9\/\#[\]\"_:,\-\s*]*)(---)$/mi, ""),
matter: matter(post.value).data,
slug: context.params.slug
}

View file

@ -9,10 +9,10 @@ import PostList from "@/components/PostList";
import Head from "next/head"
const IndexPage = (props: { posts: [{ title: string, date: string, link: string }] }) => {
let Index = (
return (<RenderWithoutJS>
<main id={index.layout}>
<Head>
<title>blog</title>
<title>lio's blog</title>
</Head>
<Sidebar />
<section id={index.blogMain}>
@ -22,8 +22,7 @@ const IndexPage = (props: { posts: [{ title: string, date: string, link: string
<Lanyard />
{/* <Copyright /> */}
</main>
);
return <RenderWithoutJS children={Index} />
</RenderWithoutJS>)
};
export default IndexPage

View file

@ -13,29 +13,32 @@ function randomHello() {
const IndexPage = () => {
let Index = (
<main id={index.layout}>
<Head>
<title>lio</title>
</Head>
<Sidebar />
<section id={index.main}>
<h1>
<noscript>Hey there!</noscript>
{randomHello()}
</h1>
<p>
my name's lio. i'm a 21y/o software dev student and ui designer from germany.
</p>
{/* <p>
return (
<RenderWithoutJS>
<main id={index.layout}>
<Head>
<title>lio</title>
</Head>
<Sidebar />
<section id={index.main}>
<h1>
<noscript>Hey there!</noscript>
{randomHello()}
</h1>
<p>
my name's lio. i'm a 21y/o software dev student and ui designer from germany.
</p>
{/* <p>
you might know me from Projects like <Link />
</p> */}
</section>
<Lanyard />
{/* <Copyright /> */}
</main>
</section>
<Lanyard />
{/* <Copyright /> */}
</main>
</RenderWithoutJS>
);
return <RenderWithoutJS children={Index} />
};
export default IndexPage