From f5e980d8ec9abd2c6b4dd2f6a41b2d72fc2a34c0 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Thu, 19 Jan 2023 15:05:25 +0400 Subject: [PATCH] Add functionality to add note to the roadmaps --- src/components/FAQs/FAQs.astro | 8 +++----- src/components/RoadmapHeader.astro | 13 +++++-------- src/components/RoadmapNote.astro | 19 +++++++++++++++++++ src/lib/markdown.ts | 8 ++++++++ src/lib/roadmap.ts | 1 + src/pages/[roadmapId]/index.astro | 3 ++- src/roadmaps/design-system/design-system.md | 6 +++--- .../100-what-is-system-design.md | 10 +++++++++- .../101-how-to-approach-system-design.md | 14 +++++++++++++- .../content/100-introduction/index.md | 10 +++++++++- 10 files changed, 72 insertions(+), 20 deletions(-) create mode 100644 src/components/RoadmapNote.astro create mode 100644 src/lib/markdown.ts diff --git a/src/components/FAQs/FAQs.astro b/src/components/FAQs/FAQs.astro index ce97d8ec6..bb17a540c 100644 --- a/src/components/FAQs/FAQs.astro +++ b/src/components/FAQs/FAQs.astro @@ -1,10 +1,8 @@ --- -import MarkdownIt from 'markdown-it'; +import { markdownToHtml } from '../../lib/markdown'; import Answer from './Answer.astro'; import Question from './Question.astro'; -const md = new MarkdownIt(); - export type FAQType = { question: string; answer: string[]; @@ -32,8 +30,8 @@ if (faqs.length === 0) { faqs.map((faq, questionIndex) => ( - {faq.answer.map((answer, index) => ( - + {faq.answer.map((answer) => ( +

))} diff --git a/src/components/RoadmapHeader.astro b/src/components/RoadmapHeader.astro index e53468995..1c25adeab 100644 --- a/src/components/RoadmapHeader.astro +++ b/src/components/RoadmapHeader.astro @@ -1,26 +1,21 @@ --- import Icon from './Icon.astro'; import ResourcesAlert from './ResourcesAlert.astro'; +import RoadmapNote from './RoadmapNote.astro'; import TopicSearch from './TopicSearch/TopicSearch.astro'; import YouTubeAlert from './YouTubeAlert.astro'; export interface Props { title: string; description: string; + note?: string; roadmapId: string; isUpcoming?: boolean; hasSearch?: boolean; hasTopics?: boolean; } -const { - title, - description, - roadmapId, - isUpcoming = false, - hasSearch = false, - hasTopics = false, -} = Astro.props; +const { title, description, roadmapId, isUpcoming = false, hasSearch = false, note, hasTopics = false } = Astro.props; const isRoadmapReady = !isUpcoming; --- @@ -114,3 +109,5 @@ const isRoadmapReady = !isUpcoming; {hasSearch && } + +{note && } diff --git a/src/components/RoadmapNote.astro b/src/components/RoadmapNote.astro new file mode 100644 index 000000000..84854369b --- /dev/null +++ b/src/components/RoadmapNote.astro @@ -0,0 +1,19 @@ +--- +import { Debug } from 'astro/components'; +import { markdownToHtml } from '../lib/markdown'; + +export interface Props { + text: string; +} + +const { text } = Astro.props; +--- + +

+
+

+

+
diff --git a/src/lib/markdown.ts b/src/lib/markdown.ts new file mode 100644 index 000000000..e18d01a1b --- /dev/null +++ b/src/lib/markdown.ts @@ -0,0 +1,8 @@ +// @ts-ignore +import MarkdownIt from 'markdown-it'; + +export function markdownToHtml(markdown: string): string { + const md = new MarkdownIt(); + + return md.renderInline(markdown); +} diff --git a/src/lib/roadmap.ts b/src/lib/roadmap.ts index 84031d4ce..c8686e9db 100644 --- a/src/lib/roadmap.ts +++ b/src/lib/roadmap.ts @@ -12,6 +12,7 @@ export interface RoadmapFrontmatter { hasTopics: boolean; isNew: boolean; isUpcoming: boolean; + note?: string; dimensions?: { width: number; height: number; diff --git a/src/pages/[roadmapId]/index.astro b/src/pages/[roadmapId]/index.astro index 681558bab..1995f1aad 100644 --- a/src/pages/[roadmapId]/index.astro +++ b/src/pages/[roadmapId]/index.astro @@ -57,8 +57,9 @@ if (roadmapFAQs.length) { jsonLd={jsonLdSchema} >