Resolving failing pipeline
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
apatil 2025-05-05 23:22:31 +01:00
parent 0a78ae9deb
commit 0e47ca2572
7 changed files with 35 additions and 25 deletions

View File

@ -1,18 +1,22 @@
import { Box, Typography } from '@mui/material';
import { getPostBySlug, getAllSlugs } from '../../../lib/posts'; import { getPostBySlug, getAllSlugs } from '../../../lib/posts';
import { notFound } from 'next/navigation'; import { notFound } from 'next/navigation';
type Params = { slug: string };
type Props = { params: Promise<{ slug: string }> };
export async function generateStaticParams() { export async function generateStaticParams() {
const slugs = getAllSlugs(); const slugs = getAllSlugs();
return slugs.map(slug => ({ slug })); return slugs.map(slug => ({ slug: slug.params?.slug }));
} }
export default async function BlogPost({ params }: { params: Params }) { export default async function BlogPost({ params }: Props) {
const post = await getPostBySlug(params.slug); const { slug } = await params;
const post = await getPostBySlug(slug);
if (!post) return notFound(); if (!post) return notFound();
return ( return (
<article> <Box component={'article'}>
<h1>{post.title}</h1> <Typography variant='h2'>{post.title}</Typography>
<p >{post.date}</p> <Typography variant='body2'>{post.date}</Typography>
<div dangerouslySetInnerHTML={{ __html: post.contentHtml }} /> <Box dangerouslySetInnerHTML={{ __html: post.contentHtml }} />
</article> </Box>
); );
} }

View File

@ -1,4 +1,3 @@
import { getAllPosts } from '../../lib/posts'; import { getAllPosts } from '../../lib/posts';
import ArticleIcon from '@mui/icons-material/Article'; import ArticleIcon from '@mui/icons-material/Article';
import { Avatar, Box, Link, List, ListItem, ListItemAvatar, ListItemButton, ListItemText, Typography } from '@mui/material'; import { Avatar, Box, Link, List, ListItem, ListItemAvatar, ListItemButton, ListItemText, Typography } from '@mui/material';

View File

@ -1,7 +1,9 @@
import { Box, Typography } from "@mui/material";
export default function Home() { export default function Home() {
return ( return (
<div> <Box textAlign={'center'} alignContent={'center'} color='error.main'>
<h1>Nothing to see here</h1> <Typography variant="body1">Nothing to see here</Typography>
</div> </Box>
); );
} }

View File

@ -42,8 +42,8 @@ export default function Header() {
</Box> </Box>
) )
return ( return (
<Box sx={{ flexGrow: 1 }}> <>
<AppBar position="fixed" sx={{ backgroundColor: 'primary.main', opacity: '80%' }}> <AppBar position="static" sx={{ backgroundColor: 'primary.main', opacity: '80%' }}>
<Toolbar> <Toolbar>
<IconButton <IconButton
size='large' size='large'
@ -57,6 +57,7 @@ export default function Header() {
<Typography variant="h6" padding={2} color='background.paper'> <Typography variant="h6" padding={2} color='background.paper'>
TCG TCG
</Typography> </Typography>
<Box sx={{ flexGrow: 1 }} />
<ModeSwitch /> <ModeSwitch />
</Toolbar> </Toolbar>
</AppBar> </AppBar>
@ -68,6 +69,6 @@ export default function Header() {
> >
{drawer} {drawer}
</Drawer> </Drawer>
</Box> </>
) )
} }

View File

@ -2,7 +2,7 @@
import * as React from 'react'; import * as React from 'react';
import FormControl from '@mui/material/FormControl'; import FormControl from '@mui/material/FormControl';
import { useColorMode } from '@/theme/ThemeContext'; import { useColorMode } from '@/theme/ThemeContext';
import { styled, Switch } from '@mui/material'; import { Box, styled, Switch } from '@mui/material';
const MaterialUISwitch = styled(Switch)(({ theme }) => ({ const MaterialUISwitch = styled(Switch)(({ theme }) => ({
width: 62, width: 62,
@ -63,9 +63,11 @@ export default function ModeSwitch() {
return null; return null;
} }
return ( return (
<Box>
<FormControl fullWidth> <FormControl fullWidth>
{/* eslint-disable-next-line @typescript-eslint/no-unused-vars */} {/* eslint-disable-next-line @typescript-eslint/no-unused-vars */}
<MaterialUISwitch aria-labelledby='mode-select-label' value={mode} onChange={(_e) => toggleColorMode()} /> <MaterialUISwitch checked={mode === 'dark'} onChange={(_e) => toggleColorMode()} />
</FormControl> </FormControl>
</Box>
); );
} }

View File

@ -1,4 +1,3 @@
// lib/posts.ts
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import matter from 'gray-matter'; import matter from 'gray-matter';
@ -30,6 +29,9 @@ export function getAllPosts() {
export async function getPostBySlug(slug: string) { export async function getPostBySlug(slug: string) {
const fullPath = path.join(postsDirectory, `${slug}.md`); const fullPath = path.join(postsDirectory, `${slug}.md`);
if (!fs.existsSync(fullPath)) {
throw new Error(`Post not found: ${slug}`);
}
const fileContents = fs.readFileSync(fullPath, 'utf8'); const fileContents = fs.readFileSync(fullPath, 'utf8');
const { data, content } = matter(fileContents); const { data, content } = matter(fileContents);
@ -45,7 +47,7 @@ export async function getPostBySlug(slug: string) {
}; };
} }
export const getAllSlugs = (): Array<{ params: { slug: string } }> => { export const getAllSlugs = () => {
return fs.readdirSync(postsDirectory).map((fileName) => ({ return fs.readdirSync(postsDirectory).map((fileName) => ({
params: { slug: fileName.replace(/\.md$/, '') }, params: { slug: fileName.replace(/\.md$/, '') },
})); }));

View File

@ -5,6 +5,6 @@ slug: 'first-post'
excerpt: 'This is an excerpt from the first post.' excerpt: 'This is an excerpt from the first post.'
--- ---
# My First Post # First Heading
Welcome to my blog post written in **Markdown**. Welcome to my blog post written in **Markdown**.