diff --git a/content/_schemas.ts b/content/_schemas.ts index 9026beac..eb15c5d8 100644 --- a/content/_schemas.ts +++ b/content/_schemas.ts @@ -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) => diff --git a/src/components/layouts/Post/Actions.astro b/src/components/layouts/Post/Actions.astro index 3cacf03c..92c74a36 100644 --- a/src/components/layouts/Post/Actions.astro +++ b/src/components/layouts/Post/Actions.astro @@ -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 = [ { diff --git a/src/components/layouts/Post/index.astro b/src/components/layouts/Post/index.astro index bb67976e..28beb880 100644 --- a/src/components/layouts/Post/index.astro +++ b/src/components/layouts/Post/index.astro @@ -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 --- @@ -46,7 +46,7 @@ const { title, date, updated, image, linkurl, toc, style } = data - {collection !== 'photos' && } + {collection !== 'photos' && } { /* */ diff --git a/src/lib/astro.ts b/src/lib/astro.ts index c4b4df83..f8a6f8f0 100644 --- a/src/lib/astro.ts +++ b/src/lib/astro.ts @@ -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 } )