mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-08-12 20:24:21 +02:00
Update topic assignment
This commit is contained in:
@@ -1,19 +1,22 @@
|
|||||||
const fs = require('node:fs');
|
const fs = require('node:fs');
|
||||||
const path = require('node:path');
|
const path = require('node:path');
|
||||||
|
|
||||||
const roadmapId = 'frontend';
|
const allRoadmapDirs = fs.readdirSync(
|
||||||
|
path.join(__dirname, '../src/data/roadmaps'),
|
||||||
const roadmapDir = path.join(
|
|
||||||
__dirname,
|
|
||||||
`../src/data/roadmaps/${roadmapId}/content`,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
function getHostNameWithoutTld(hostname) {
|
allRoadmapDirs.forEach((roadmapId) => {
|
||||||
|
const roadmapDir = path.join(
|
||||||
|
__dirname,
|
||||||
|
`../src/data/roadmaps/${roadmapId}/content`,
|
||||||
|
);
|
||||||
|
|
||||||
|
function getHostNameWithoutTld(hostname) {
|
||||||
const parts = hostname.split('.');
|
const parts = hostname.split('.');
|
||||||
return parts.slice(0, parts.length - 1).join('.');
|
return parts.slice(0, parts.length - 1).join('.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function isOfficialWebsite(hostname, fileName, roadmapId) {
|
function isOfficialWebsite(hostname, fileName, roadmapId) {
|
||||||
fileName = fileName.replace('/index.md', '').replace('.md', '');
|
fileName = fileName.replace('/index.md', '').replace('.md', '');
|
||||||
|
|
||||||
const parts = fileName.split('/');
|
const parts = fileName.split('/');
|
||||||
@@ -31,18 +34,18 @@ function isOfficialWebsite(hostname, fileName, roadmapId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return !!roadmapId.includes(normalizedHostname);
|
return !!roadmapId.includes(normalizedHostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// websites are educational websites that are of following types:
|
// websites are educational websites that are of following types:
|
||||||
// - @official@
|
// - @official@
|
||||||
// - @article@
|
// - @article@
|
||||||
// - @course@
|
// - @course@
|
||||||
// - @opensource@
|
// - @opensource@
|
||||||
// - @podcast@
|
// - @podcast@
|
||||||
// - @video@
|
// - @video@
|
||||||
// - @website@
|
// - @website@
|
||||||
// content is only educational websites
|
// content is only educational websites
|
||||||
function getTypeFromHostname(hostname, fileName, roadmapId) {
|
function getTypeFromHostname(hostname, fileName, roadmapId) {
|
||||||
hostname = hostname.replace('www.', '');
|
hostname = hostname.replace('www.', '');
|
||||||
|
|
||||||
const videoHostnames = ['youtube.com', 'vimeo.com', 'youtu.be'];
|
const videoHostnames = ['youtube.com', 'vimeo.com', 'youtu.be'];
|
||||||
@@ -103,9 +106,9 @@ function getTypeFromHostname(hostname, fileName, roadmapId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 'article';
|
return 'article';
|
||||||
}
|
}
|
||||||
|
|
||||||
function readNestedMarkdownFiles(dir, files = []) {
|
function readNestedMarkdownFiles(dir, files = []) {
|
||||||
const dirEnts = fs.readdirSync(dir, { withFileTypes: true });
|
const dirEnts = fs.readdirSync(dir, { withFileTypes: true });
|
||||||
|
|
||||||
for (const dirent of dirEnts) {
|
for (const dirent of dirEnts) {
|
||||||
@@ -120,19 +123,19 @@ function readNestedMarkdownFiles(dir, files = []) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = readNestedMarkdownFiles(roadmapDir);
|
const files = readNestedMarkdownFiles(roadmapDir);
|
||||||
|
|
||||||
// for each of the files, assign the type of link to the beginning of each markdown link
|
// for each of the files, assign the type of link to the beginning of each markdown link
|
||||||
// i.e. - [@article@abc](xyz) where @article@ is the type of link. Possible types:
|
// i.e. - [@article@abc](xyz) where @article@ is the type of link. Possible types:
|
||||||
// - @article@
|
// - @article@
|
||||||
// - @course@
|
// - @course@
|
||||||
// - @opensource@
|
// - @opensource@
|
||||||
// - @podcast@
|
// - @podcast@
|
||||||
// - @video@
|
// - @video@
|
||||||
// - @website@
|
// - @website@
|
||||||
files.forEach((file) => {
|
files.forEach((file) => {
|
||||||
const content = fs.readFileSync(file, 'utf-8');
|
const content = fs.readFileSync(file, 'utf-8');
|
||||||
const lines = content.split('\n');
|
const lines = content.split('\n');
|
||||||
|
|
||||||
@@ -181,4 +184,5 @@ files.forEach((file) => {
|
|||||||
.join('\n');
|
.join('\n');
|
||||||
|
|
||||||
fs.writeFileSync(file, newContent);
|
fs.writeFileSync(file, newContent);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user