Add questions on homepage

pull/4459/head
Kamran Ahmed 1 year ago
parent 9c75404d0c
commit 0eebcd03a4
  1. 25
      src/components/FeaturedItems/FeaturedItem.astro
  2. 6
      src/components/FeaturedItems/FeaturedItems.astro
  3. 12
      src/pages/index.astro

@ -6,11 +6,18 @@ export interface FeaturedItemType {
isNew?: boolean; isNew?: boolean;
url: string; url: string;
text: string; text: string;
allowBookmark?: boolean;
} }
export interface Props extends FeaturedItemType {} export interface Props extends FeaturedItemType {}
const { isUpcoming = false, isNew = false, text, url } = Astro.props; const {
isUpcoming = false,
isNew = false,
text,
url,
allowBookmark = true,
} = Astro.props;
--- ---
<a <a
@ -26,11 +33,17 @@ const { isUpcoming = false, isNew = false, text, url } = Astro.props;
{text} {text}
</span> </span>
<MarkFavorite {
resourceId={url.split('/').pop()!} allowBookmark && (
resourceType={url.includes('best-practices') ? 'best-practice' : 'roadmap'} <MarkFavorite
client:only="react" resourceId={url.split('/').pop()!}
/> resourceType={
url.includes('best-practices') ? 'best-practice' : 'roadmap'
}
client:only='react'
/>
)
}
{ {
isNew && ( isNew && (

@ -4,15 +4,16 @@ import FeaturedItem, { FeaturedItemType } from './FeaturedItem.astro';
export interface Props { export interface Props {
featuredItems: FeaturedItemType[]; featuredItems: FeaturedItemType[];
heading: string; heading: string;
allowBookmark?: boolean;
} }
const { featuredItems, heading } = Astro.props; const { featuredItems, heading, allowBookmark = true } = Astro.props;
--- ---
<div class='relative border-b border-b-[#1e293c] py-10 sm:py-14'> <div class='relative border-b border-b-[#1e293c] py-10 sm:py-14'>
<div class='container'> <div class='container'>
<h2 <h2
class='text-md font-regular absolute flex rounded-lg border border-[#1e293c] bg-slate-900 px-3 py-1 text-slate-400 -top-[17px] sm:left-1/2 sm:-translate-x-1/2' class='text-md font-regular absolute -top-[17px] flex rounded-lg border border-[#1e293c] bg-slate-900 px-3 py-1 text-slate-400 sm:left-1/2 sm:-translate-x-1/2'
> >
{heading} {heading}
</h2> </h2>
@ -22,6 +23,7 @@ const { featuredItems, heading } = Astro.props;
featuredItems.map((featuredItem) => ( featuredItems.map((featuredItem) => (
<li> <li>
<FeaturedItem <FeaturedItem
allowBookmark={allowBookmark}
text={featuredItem.text} text={featuredItem.text}
url={featuredItem.url} url={featuredItem.url}
isNew={featuredItem.isNew} isNew={featuredItem.isNew}

@ -8,10 +8,12 @@ import { getAllBestPractices } from '../lib/best-pratice';
import { getAllGuides } from '../lib/guide'; import { getAllGuides } from '../lib/guide';
import { getRoadmapsByTag } from '../lib/roadmap'; import { getRoadmapsByTag } from '../lib/roadmap';
import { getAllVideos } from '../lib/video'; import { getAllVideos } from '../lib/video';
import { getAllQuestionGroups } from '../lib/question-group';
const roleRoadmaps = await getRoadmapsByTag('role-roadmap'); const roleRoadmaps = await getRoadmapsByTag('role-roadmap');
const skillRoadmaps = await getRoadmapsByTag('skill-roadmap'); const skillRoadmaps = await getRoadmapsByTag('skill-roadmap');
const bestPractices = await getAllBestPractices(); const bestPractices = await getAllBestPractices();
const questionGroups = await getAllQuestionGroups();
const guides = await getAllGuides(); const guides = await getAllGuides();
const videos = await getAllVideos(); const videos = await getAllVideos();
@ -58,6 +60,16 @@ const videos = await getAllVideos();
}))} }))}
/> />
<!--<FeaturedItems-->
<!-- heading='Questions'-->
<!-- allowBookmark={false}-->
<!-- featuredItems={questionGroups.map((questionGroup) => ({-->
<!-- text: questionGroup.frontmatter.briefTitle,-->
<!-- url: `/questions/${questionGroup.id}`,-->
<!-- isNew: questionGroup.frontmatter.isNew,-->
<!-- }))}-->
<!--/>-->
<div class='grid grid-cols-1 gap-7 bg-gray-50 py-7 sm:gap-16 sm:py-16'> <div class='grid grid-cols-1 gap-7 bg-gray-50 py-7 sm:gap-16 sm:py-16'>
<FeaturedGuides heading='Guides' guides={guides.slice(0, 7)} /> <FeaturedGuides heading='Guides' guides={guides.slice(0, 7)} />
<FeaturedVideos heading='Videos' videos={videos.slice(0, 7)} /> <FeaturedVideos heading='Videos' videos={videos.slice(0, 7)} />

Loading…
Cancel
Save