Refactor the topic loading

pull/3356/head
Kamran Ahmed 2 years ago
parent 8a24b3e695
commit badb2c029d
  1. 9
      src/components/FrameRenderer/FrameRenderer.astro
  2. 5
      src/components/FrameRenderer/renderer.js
  3. 2
      src/components/TopicOverlay/TopicOverlay.astro
  4. 4
      src/components/TopicOverlay/topic.js
  5. 12
      src/pages/[roadmapId]/index.astro
  6. 4
      src/pages/best-practices/[bestPracticeId].astro

@ -1,12 +1,10 @@
--- ---
import Loader from '../Loader.astro'; import Loader from '../Loader.astro';
import ShareIcons from '../ShareIcons/ShareIcons.astro'; import TopicOverlay from '../TopicOverlay/TopicOverlay.astro';
import TopicOverlay from './TopicOverlay.astro';
import './FrameRenderer.css'; import './FrameRenderer.css';
export interface Props { export interface Props {
roadmapId: string; roadmapId: string;
description: string;
jsonUrl: string; jsonUrl: string;
dimensions?: { dimensions?: {
width: number; width: number;
@ -14,12 +12,9 @@ export interface Props {
}; };
} }
const { roadmapId, jsonUrl, dimensions = null, description } = Astro.props; const { roadmapId, jsonUrl, dimensions = null } = Astro.props;
--- ---
<link rel='preload' href='/fonts/balsamiq.woff2' as='font' type='font/woff2' crossorigin slot='after-header' />
<TopicOverlay roadmapId={roadmapId} />
<div <div
id='roadmap-svg' id='roadmap-svg'
style={dimensions ? `--aspect-ratio:${dimensions.width}/${dimensions.height}` : null} style={dimensions ? `--aspect-ratio:${dimensions.width}/${dimensions.height}` : null}

@ -1,5 +1,4 @@
import { wireframeJSONToSVG } from 'roadmap-renderer'; import { wireframeJSONToSVG } from 'roadmap-renderer';
import { Topic } from './topic';
/** /**
* @typedef {{ roadmapId: string, jsonUrl: string }} RoadmapConfig * @typedef {{ roadmapId: string, jsonUrl: string }} RoadmapConfig
@ -99,7 +98,3 @@ export class Renderer {
const renderer = new Renderer(); const renderer = new Renderer();
renderer.init(); renderer.init();
// Initialize the topic loader
const topic = new Topic();
topic.init();

@ -67,3 +67,5 @@ const githubLink = `https://github.com/kamranahmedse/developer-roadmap/tree/mast
<div class='bg-gray-900 bg-opacity-50 dark:bg-opacity-80 fixed inset-0 z-30'> <div class='bg-gray-900 bg-opacity-50 dark:bg-opacity-80 fixed inset-0 z-30'>
</div> </div>
</div> </div>
<script src="./topic.js" />

@ -230,3 +230,7 @@ export class Topic {
}); });
} }
} }
// Initialize the topic loader
const topic = new Topic();
topic.init();

@ -5,6 +5,7 @@ import FrameRenderer from '../../components/FrameRenderer/FrameRenderer.astro';
import MarkdownFile from '../../components/MarkdownFile.astro'; import MarkdownFile from '../../components/MarkdownFile.astro';
import RoadmapHeader from '../../components/RoadmapHeader.astro'; import RoadmapHeader from '../../components/RoadmapHeader.astro';
import ShareIcons from '../../components/ShareIcons/ShareIcons.astro'; import ShareIcons from '../../components/ShareIcons/ShareIcons.astro';
import TopicOverlay from '../../components/TopicOverlay/TopicOverlay.astro';
import UpcomingForm from '../../components/UpcomingForm.astro'; import UpcomingForm from '../../components/UpcomingForm.astro';
import BaseLayout from '../../layouts/BaseLayout.astro'; import BaseLayout from '../../layouts/BaseLayout.astro';
import { generateArticleSchema, generateFAQSchema } from '../../lib/jsonld-schema'; import { generateArticleSchema, generateFAQSchema } from '../../lib/jsonld-schema';
@ -57,6 +58,9 @@ if (roadmapFAQs.length) {
noIndex={roadmapData.isUpcoming} noIndex={roadmapData.isUpcoming}
jsonLd={jsonLdSchema} jsonLd={jsonLdSchema}
> >
<!-- Preload the font being used in the renderer -->
<link rel='preload' href='/fonts/balsamiq.woff2' as='font' type='font/woff2' crossorigin slot='after-header' />
<RoadmapHeader <RoadmapHeader
title={roadmapData.title} title={roadmapData.title}
description={roadmapData.description} description={roadmapData.description}
@ -71,13 +75,9 @@ if (roadmapFAQs.length) {
!roadmapData.isUpcoming && roadmapData.jsonUrl && ( !roadmapData.isUpcoming && roadmapData.jsonUrl && (
<div class='max-w-[1000px] container relative'> <div class='max-w-[1000px] container relative'>
<ShareIcons description={roadmapData.featuredDescription} pageUrl={`https://roadmap.sh/${roadmapId}`} /> <ShareIcons description={roadmapData.featuredDescription} pageUrl={`https://roadmap.sh/${roadmapId}`} />
<TopicOverlay roadmapId={roadmapId} />
<FrameRenderer <FrameRenderer roadmapId={roadmapId} jsonUrl={roadmapData.jsonUrl} dimensions={roadmapData.dimensions} />
roadmapId={roadmapId}
description={roadmapData.description}
jsonUrl={roadmapData.jsonUrl}
dimensions={roadmapData.dimensions}
/>
</div> </div>
) )
} }

@ -51,6 +51,9 @@ if (bestPracticeData.schema) {
noIndex={bestPracticeData.isUpcoming} noIndex={bestPracticeData.isUpcoming}
jsonLd={jsonLdSchema} jsonLd={jsonLdSchema}
> >
<!-- Preload the font being used in the renderer -->
<link rel='preload' href='/fonts/balsamiq.woff2' as='font' type='font/woff2' crossorigin slot='after-header' />
<BestPracticeHeader <BestPracticeHeader
title={bestPracticeData.title} title={bestPracticeData.title}
description={bestPracticeData.description} description={bestPracticeData.description}
@ -69,7 +72,6 @@ if (bestPracticeData.schema) {
<FrameRenderer <FrameRenderer
roadmapId={bestPracticeId} roadmapId={bestPracticeId}
description={bestPracticeData.description}
jsonUrl={bestPracticeData.jsonUrl} jsonUrl={bestPracticeData.jsonUrl}
dimensions={bestPracticeData.dimensions} dimensions={bestPracticeData.dimensions}
/> />

Loading…
Cancel
Save