-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
65 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
import { defineCollection, z } from 'astro:content'; | ||
|
||
const blog = defineCollection({ | ||
// Type-check frontmatter using a schema | ||
schema: z.object({ | ||
title: z.string(), | ||
description: z.string(), | ||
// Transform string to Date object | ||
pubDate: z.coerce.date(), | ||
updatedDate: z.coerce.date().optional(), | ||
heroImage: z.string().optional(), | ||
}), | ||
// Type-check frontmatter using a schema | ||
type: 'content', | ||
schema: z.object({ | ||
title: z.string(), | ||
description: z.string(), | ||
pubDate: z.coerce.date(), | ||
updatedDate: z.coerce.date().optional(), | ||
tags: z.array(z.string()), | ||
draft: z.boolean().optional().default(false) | ||
}), | ||
}); | ||
|
||
export const collections = { blog }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
--- | ||
export async function getStaticPaths() { | ||
import { getCollection } from 'astro:content'; | ||
const allPosts = await Astro.glob('../../content/blog/*.mdx') // returns an array of posts that live at ./src/pages/post/*.md | ||
const posts = allPosts.filter((post) => !post.frontmatter.draft) | ||
export async function getStaticPaths() { | ||
const posts = await getCollection('blog', ({ data }) => { | ||
return data.draft !== true; | ||
}); | ||
return posts.map((post) => { | ||
return { | ||
params: { slug: post.file.split("/").pop()?.split(".").shift() }, | ||
params: { slug: post.slug }, | ||
props: { post }, | ||
}; | ||
}); | ||
} | ||
const { Content } = Astro.props.post; | ||
const { slug } = Astro.params; | ||
import { getEntry } from 'astro:content'; | ||
const entry = await getEntry('blog', slug!); | ||
const { Content } = await entry!.render(); | ||
--- | ||
|
||
<Content/> | ||
<Content /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
--- | ||
import BlogPostItem from '../../components/BlogPostItem.astro' | ||
import Section from '../../components/Section.astro' | ||
import Layout from '../../layouts/Layout.astro' | ||
import { getCollection } from 'astro:content'; | ||
import BlogPostItem from '../../components/BlogPostItem.astro'; | ||
import Section from '../../components/Section.astro'; | ||
import Layout from '../../layouts/Layout.astro'; | ||
const allPosts = await Astro.glob('../../content/blog/*.mdx') // returns an array of posts that live at ./src/pages/post/*.md | ||
const posts = allPosts.filter((post) => !post.frontmatter.draft) | ||
const posts = await getCollection('blog', ({ data }) => { | ||
return data.draft !== true; | ||
}); | ||
--- | ||
|
||
<Layout title="Kharann • All posts"> | ||
<section> | ||
<h1 class="text-4xl font-bold text-primary-9">Blog</h1> | ||
<p class="my-4"> | ||
Here you can find all the posts I've written. I write about web development, technology, and | ||
other things I find interesting. | ||
</p> | ||
<Section name="All posts."> | ||
<BlogPostItem posts={posts} /> | ||
</Section> | ||
</section> | ||
<section> | ||
<h1 class="text-4xl font-bold text-primary-9">Blog</h1> | ||
<p class="my-4"> | ||
Here you can find all the posts I've written. I write about web development, technology, and other things I find | ||
interesting. | ||
</p> | ||
<Section name="All posts."> | ||
<BlogPostItem posts={posts} /> | ||
</Section> | ||
</section> | ||
</Layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export type Frontmatter = { | ||
title: string; | ||
pubDate: string; | ||
description: string; | ||
tags: string[]; | ||
minutesRead: number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
{ | ||
"extends": "astro/tsconfigs/strictest", | ||
"extends": "astro/tsconfigs/strict", | ||
"compilerOptions": { | ||
"strictNullChecks": true | ||
} | ||
"strictNullChecks": true, | ||
"types": ["bun-types"] | ||
}, | ||
|
||
} |
a288bf0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
homepage-web – ./
homepage-web-roan.vercel.app
homepage-web-git-master-kharann.vercel.app
homepage-web-kharann.vercel.app