From faf70f6e3559abb17c048cb5ec00496fca00d819 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Fri, 29 Nov 2024 11:22:26 +0500 Subject: [PATCH] Add frontend technologies guide --- scripts/extract-guide-images.cjs | 44 +++ src/data/guides/frontend-technologies.md | 420 +++++++++++++++++++++++ src/data/roadmaps/frontend/frontend.md | 2 +- src/pages/frontend/technologies.astro | 32 ++ 4 files changed, 497 insertions(+), 1 deletion(-) create mode 100644 scripts/extract-guide-images.cjs create mode 100644 src/data/guides/frontend-technologies.md create mode 100644 src/pages/frontend/technologies.astro diff --git a/scripts/extract-guide-images.cjs b/scripts/extract-guide-images.cjs new file mode 100644 index 000000000..22e411768 --- /dev/null +++ b/scripts/extract-guide-images.cjs @@ -0,0 +1,44 @@ +// get all the base64 encoded images and save them to a file from the given markdown file + +const fs = require('fs'); +const path = require('path'); +const matter = require('gray-matter'); + +const guidePath = path.join(process.cwd(), 'src/data/guides'); +const tempDir = path.join(process.cwd(), '.temp'); + +const guideId = process.argv[2]; +if (!guideId) { + console.error('Guide ID is required'); + process.exit(1); +} + +const guideContent = fs.readFileSync( + path.join(guidePath, `${guideId}.md`), + 'utf8', +); + +// Create temp directory if it doesn't exist +const guideTempDir = path.join(tempDir, guideId); +if (!fs.existsSync(guideTempDir)) { + fs.mkdirSync(guideTempDir, { recursive: true }); +} + +const { data, content } = matter(guideContent); + +// Find all base64 image references in the content +const images = content.match(/\[(.+?)\]:\s+? { + const imageName = image.match(/\[(.+?)\]/)[1]; + const imageExtension = image.match(/ null); +if (!guide) { + return Astro.redirect('/404'); +} + +const { frontmatter: guideData } = guide!; + +const ogImageUrl = + guideData.seo.ogImageUrl || + getOpenGraphImageUrl({ + group: 'guide', + resourceId: guideId, + }); +--- + + + +
+