1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-06-28 08:37:57 +02:00

githubLink solution

This commit is contained in:
Matthias Kretschmann 2023-09-05 00:41:45 +01:00
parent 610dbde823
commit 9984105cc1
Signed by: m
GPG Key ID: 606EEEF3C479A91F
4 changed files with 10 additions and 4 deletions

View File

@ -24,7 +24,7 @@ const schemaShared = {
featured: z.boolean().optional(),
style: z.string().optional(),
toc: z.boolean().optional(),
slug: z.string().optional()
githubLink: z.string().optional()
}
export const schemaArticles = (image: ImageFunction) =>

View File

@ -4,7 +4,11 @@ import styles from './Actions.module.css'
import Action from './Action.astro'
import { Mastodon, Bitcoin, Github } from '@images/icons'
const githubLink = '?'
type Props = {
githubLink: string
}
const { githubLink } = Astro.props
const actions = [
{

View File

@ -14,7 +14,7 @@ type Props = CollectionEntry<'articles' | 'links' | 'photos'> & {
}
const { data, collection, lead, tableOfContents } = Astro.props
const { title, date, updated, image, linkurl, toc, style } = data
const { title, date, updated, image, linkurl, toc, style, githubLink } = data
---
<LayoutBase title={title} style={style}>
@ -46,7 +46,7 @@ const { title, date, updated, image, linkurl, toc, style } = data
<slot />
<Meta post={Astro.props} />
{collection !== 'photos' && <Actions />}
{collection !== 'photos' && <Actions githubLink={githubLink as string} />}
{
/* <RelatedPosts isPhotos={collection === 'photos'} tags={tags as string[]} /> */

View File

@ -36,9 +36,11 @@ export async function loadAndFormatCollection(
// use date from frontmatter, or grab from file path
const date = post.data.date ? post.data.date : slug.substring(1, 11)
const githubLink = `https://github.com/kremalicious/blog/blob/main/content/${post.collection}/${post.id}`
post.slug = slug
post.data.date = new Date(date)
post.data.githubLink = githubLink
}
)