Skip to content

Commit

Permalink
Fix Authors and LerningPaths
Browse files Browse the repository at this point in the history
  • Loading branch information
macx committed Jan 3, 2025
1 parent e968de6 commit 3132477
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 14 deletions.
4 changes: 4 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,9 @@ export default defineConfig({
}
}
}
},
experimental: {
responsiveImages: true,
svg: true
}
})
7 changes: 5 additions & 2 deletions src/components/ArticleMeta.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import FormattedDate from '@components/FormattedDate.astro'
interface Props {
date: Date
author: object
author: {
id: string
[key: string]: any
}
readingTime: {
minutes: number
words: number
}
}
const { date, author, readingTime } = Astro.props
const authorProfile = await getEntry('authors', (author as { id: string }).id)
const authorProfile = await getEntry('authors', author.id)
---

<div class='meta'>
Expand Down
8 changes: 4 additions & 4 deletions src/components/Switch.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const currentPath = pathname.split('/').slice(3).join('').trim()
interface LearnPath {
title: string
id: string
slug: string
}
export interface Props {
Expand All @@ -19,11 +19,11 @@ const { entries } = Astro.props
{
entries.map(
(entry) =>
entry.id && (
entry.slug && (
<li>
<a
href={entry.id}
class:list={[currentPath === entry.id ? 'current' : null]}
href={entry.slug}
class:list={[currentPath === entry.slug ? 'current' : null]}
>
{entry.title}
</a>
Expand Down
6 changes: 3 additions & 3 deletions src/content.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineCollection, reference, z } from 'astro:content'
import { glob } from 'astro/loaders'
import { glob, file } from 'astro/loaders'

const tutorials = defineCollection({
loader: glob({ pattern: '**/*.mdx', base: './src/data/tutorials' }),
Expand Down Expand Up @@ -32,10 +32,10 @@ const tutorials = defineCollection({
})

const authors = defineCollection({
loader: glob({ pattern: '**/[^_]*.json', base: './src/data/authors' }),
loader: file('./src/data/authors.json'),
schema: z.object({
name: z.string(),
bio: z.string(),
bio: z.string().optional(),
threads: z.string().optional()
})
})
Expand Down
8 changes: 8 additions & 0 deletions src/data/authors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"id": "david-maciejewski",
"name": "David Maciejewski",
"bio": "UI-UX Engineer",
"threads": "https://www.threads.net/@macx"
}
]
4 changes: 0 additions & 4 deletions src/data/authors/david-maciejewski.json

This file was deleted.

2 changes: 1 addition & 1 deletion src/pages/tutorials/lernpfade/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const collection = (related ?? []).map((id: string) => {
<Switch
entries={learningPaths.map(({ data }: { data: any }) => ({
title: data.title || '',
id: data.id || ''
slug: data.slug || ''
}))}
/>

Expand Down

0 comments on commit 3132477

Please sign in to comment.