Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify concepts between articles and courses #213

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion src/collections/articles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default defineCollection({
z
.array(reference("tags"))
.min(1, "Article must have at least one tag")
.max(10, "Article must have at most three tags"),
.max(10, "Article must have at most ten tags"),
"tags",
),
title: z
Expand Down
15 changes: 10 additions & 5 deletions src/collections/courses.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { unique } from "@utils/unique";
import { defineCollection, reference, z } from "astro:content";

export default defineCollection({
Expand Down Expand Up @@ -55,11 +56,6 @@ export default defineCollection({
path: ["excerpt"],
},
),
extra: z
.object({
title: z.string().max(70, "Title must be at most 70 characters"),
})
.optional(),
faqs: z
.array(
z
Expand Down Expand Up @@ -100,13 +96,21 @@ export default defineCollection({
isFree: z.boolean().default(false),
isNew: z.boolean().default(false),
pricingPlanId: z.number().int().positive(),
publishedDate: z.date(),
question: z
.object({
image: image(),
text: z.string(),
})
.strict()
.optional(),
tags: unique(
z
.array(reference("tags"))
.min(1, "Course must have at least one tag")
.max(10, "Course must have at most ten tags"),
"tags",
),
technologies: z
.array(
z
Expand Down Expand Up @@ -134,6 +138,7 @@ export default defineCollection({
// .min(30, "Title must be at least 30 characters")
.max(70, "Title must be at most 70 characters"),
repositoryUrl: z.string().optional(),
updatedDate: z.date().optional(),
videoId: z.string().optional(),
hasGoal: z.boolean().default(true),
hasSkills: z.boolean().default(true),
Expand Down
2 changes: 0 additions & 2 deletions src/content/courses/zio-rite-of-passage/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ features:
one: images/feature1.png
two: images/feature2.png
three: images/feature3.png
extra:
title: What will you build?
---

import CourseLayout from "@pages/courses/_layouts/CourseLayout.astro";
Expand Down
10 changes: 5 additions & 5 deletions src/pages/articles/_layouts/ArticleLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface Props {
}

const { article, headings, minutesRead } = Astro.props;
const frontmatter = article.data;
const _frontmatter = article.data;
const {
canonicalUrl,
description,
Expand All @@ -34,12 +34,12 @@ const {
title,
updatedDate,
videoId,
} = frontmatter;
} = _frontmatter;
const author = await getEntry(
frontmatter.author.collection,
frontmatter.author.id,
_frontmatter.author.collection,
_frontmatter.author.id,
);
const tags = await getEntries(frontmatter.tags);
const tags = await getEntries(_frontmatter.tags);

const structuredData = JSON.stringify({
"@context": "https://schema.org",
Expand Down
12 changes: 12 additions & 0 deletions src/pages/courses/_layouts/CourseLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const [bundledCourses, _categoryFrontmatter, collaborators] = await Promise.all(
: [],
],
);
const tags = await getEntries(_frontmatter.tags);
const { color: categoryColor, faqs: categoryFaqs } = _categoryFrontmatter;
const {
includedInMembership,
Expand Down Expand Up @@ -160,6 +161,17 @@ const structuredData = JSON.stringify({
image={{ alt: title, src: heroImage.src }}
{structuredData}
>
{
instructors.map((instructor) => (
<div data-pagefind-filter={`Authors:${instructor.data.name}`} />
))
}
{
collaborators.map((collaborator) => (
<div data-pagefind-filter={`Authors:${collaborator.frontmatter.name}`} />
))
}
{tags.map((tag) => <div data-pagefind-filter={`Tags:${tag.id}`} />)}
<article>
<Hero {description} {heroImage} {pricingPlanId} {title} {active} />
{
Expand Down