fix: migrate content

feat/collection
Arik Chakma 4 weeks ago
parent 8ccc8aa17d
commit 904ba51b7b
  1. 4
      scripts/generate-og-images.mjs
  2. 6
      src/components/FeaturedGuides.astro
  3. 28
      src/components/Questions/QuestionGuide.astro
  4. 3
      src/lib/question-group.ts
  5. 8
      src/pages/index.astro

@ -12,8 +12,8 @@ const ALL_BEST_PRACTICE_DIR = path.join(
process.cwd(),
'/src/data/best-practices',
);
const ALL_GUIDE_DIR = path.join(process.cwd(), '/src/data/guides');
const ALl_AUTHOR_DIR = path.join(process.cwd(), '/src/data/authors');
const ALL_GUIDE_DIR = path.join(process.cwd(), '/src/content/guides');
const ALl_AUTHOR_DIR = path.join(process.cwd(), '/src/content/authors');
const ALL_ROADMAP_IMAGE_DIR = path.join(process.cwd(), '/public/roadmaps');
const ALL_BEST_PRACTICE_IMAGE_DIR = path.join(
process.cwd(),

@ -1,7 +1,7 @@
---
import type { GuideFileType } from '../lib/guide';
import GuideListItem from './GuideListItem.astro';
import { QuestionGroupType } from '../lib/question-group';
import type { QuestionGroupType } from '../lib/question-group';
export interface Props {
heading: string;
@ -15,8 +15,8 @@ const sortedGuides: (QuestionGroupType | GuideFileType)[] = [
...guides,
...questions,
].sort((a, b) => {
const aDate = new Date(a.frontmatter.date);
const bDate = new Date(b.frontmatter.date);
const aDate = new Date(a.data.date!);
const bDate = new Date(b.data.date!);
return bDate.getTime() - aDate.getTime();
});

@ -1,13 +1,9 @@
---
import {
getGuideTableOfContent,
type GuideFileType,
HeadingGroupType,
} from '../../lib/guide';
import { getGuideTableOfContent, type HeadingGroupType } from '../../lib/guide';
import MarkdownFile from '../MarkdownFile.astro';
import { TableOfContent } from '../TableOfContent/TableOfContent';
import { markdownToHtml, replaceVariables } from '../../lib/markdown';
import { QuestionGroupType } from '../../lib/question-group';
import type { QuestionGroupType } from '../../lib/question-group';
import { QuestionsList } from './QuestionsList';
interface Props {
@ -16,19 +12,17 @@ interface Props {
const { questionGroup } = Astro.props;
const allHeadings = questionGroup.getHeadings();
const { headings: allHeadings, Content } = await questionGroup.render();
const tableOfContent: HeadingGroupType[] = [
...getGuideTableOfContent(allHeadings),
{
depth: 2,
title: 'Test with Flashcards',
text: 'Test yourself with Flashcards',
children: [],
slug: 'test-with-flashcards',
text: 'Test yourself with Flashcards',
},
{
depth: 2,
title: 'Questions List',
children: [
{
depth: 2,
@ -58,7 +52,7 @@ const tableOfContent: HeadingGroupType[] = [
];
const showTableOfContent = tableOfContent.length > 0;
const { frontmatter: guideFrontmatter, author } = questionGroup;
const { data: guideFrontmatter, author } = questionGroup;
---
<article class='lg:grid lg:max-w-full lg:grid-cols-[1fr_minmax(0,700px)_1fr]'>
@ -90,11 +84,11 @@ const { frontmatter: guideFrontmatter, author } = questionGroup;
class='inline-flex items-center font-medium underline-offset-2 hover:text-gray-600 hover:underline'
>
<img
alt={author.frontmatter.name}
src={author.frontmatter.imageUrl}
alt={author.data.name}
src={author.data.imageUrl}
class='mb-0 mr-2 inline h-5 w-5 rounded-full'
/>
{author.frontmatter.name}
{author.data.name}
</a>
<span class='mx-2 hidden sm:inline'>&middot;</span>
<a
@ -107,7 +101,7 @@ const { frontmatter: guideFrontmatter, author } = questionGroup;
</p>
)
}
<questionGroup.Content />
<Content />
<h2 id='test-with-flashcards'>Test yourself with Flashcards</h2>
<p>
@ -136,8 +130,8 @@ const { frontmatter: guideFrontmatter, author } = questionGroup;
</h3>
{questionGroup.questions
.filter((q) => {
return q.topics
.map((t) => t.toLowerCase())
return q?.topics
?.map((t) => t.toLowerCase())
.includes(questionLevel);
})
.map((q) => (

@ -1,5 +1,5 @@
import slugify from 'slugify';
import { getAllAuthors } from './author.ts';
import { getAllAuthors, type AuthorFileType } from './author.ts';
import { getCollection, type CollectionEntry } from 'astro:content';
type RawQuestionGroupFileType = CollectionEntry<'question-groups'>;
@ -15,6 +15,7 @@ export type QuestionType = {
export type QuestionGroupType = RawQuestionGroupFileType & {
questions: QuestionType[];
allTopics: string[];
author?: AuthorFileType;
};
/**

@ -23,11 +23,11 @@ const projectGroups = [
title: 'Backend',
id: 'backend',
},
]
];
const guides = await getAllGuides();
const questionGuides = (await getAllQuestionGroups()).filter(
(questionGroup) => questionGroup.frontmatter.authorId,
(questionGroup) => questionGroup.data.authorId,
);
const videos = await getAllVideos();
---
@ -92,9 +92,9 @@ const videos = await getAllVideos();
heading='Questions'
allowBookmark={false}
featuredItems={questionGroups.map((questionGroup) => ({
text: questionGroup.frontmatter.briefTitle,
text: questionGroup.data.briefTitle,
url: `/questions/${questionGroup.id}`,
isNew: questionGroup.frontmatter.isNew,
isNew: questionGroup.data.isNew,
}))}
/>

Loading…
Cancel
Save