parent
b0a4130229
commit
dec5e58063
48 changed files with 16259 additions and 48 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,19 +0,0 @@ |
|||||||
const fs = require('node:fs'); |
|
||||||
const path = require('node:path'); |
|
||||||
|
|
||||||
const jsonsDir = path.join(process.cwd(), 'public/jsons'); |
|
||||||
const childJsonDirs = fs.readdirSync(jsonsDir); |
|
||||||
|
|
||||||
childJsonDirs.forEach((childJsonDir) => { |
|
||||||
const fullChildJsonDirPath = path.join(jsonsDir, childJsonDir); |
|
||||||
const jsonFiles = fs.readdirSync(fullChildJsonDirPath); |
|
||||||
|
|
||||||
jsonFiles.forEach((jsonFileName) => { |
|
||||||
console.log(`Compressing ${jsonFileName}...`); |
|
||||||
|
|
||||||
const jsonFilePath = path.join(fullChildJsonDirPath, jsonFileName); |
|
||||||
const json = require(jsonFilePath); |
|
||||||
|
|
||||||
fs.writeFileSync(jsonFilePath, JSON.stringify(json)); |
|
||||||
}); |
|
||||||
}); |
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,27 @@ |
|||||||
|
import type { APIRoute } from 'astro'; |
||||||
|
|
||||||
|
export async function getStaticPaths() { |
||||||
|
const roadmapJsons = await import.meta.glob('/src/data/roadmaps/**/*.json', { |
||||||
|
eager: true, |
||||||
|
}); |
||||||
|
|
||||||
|
return Object.keys(roadmapJsons).map((filePath) => { |
||||||
|
const roadmapId = filePath.split('/').pop()?.replace('.json', ''); |
||||||
|
const roadmapJson = roadmapJsons[filePath] as Record<string, any>; |
||||||
|
|
||||||
|
return { |
||||||
|
params: { |
||||||
|
roadmapId, |
||||||
|
}, |
||||||
|
props: { |
||||||
|
roadmapJson: roadmapJson, |
||||||
|
}, |
||||||
|
}; |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
export const get: APIRoute = async function ({ params, request, props }) { |
||||||
|
return { |
||||||
|
body: JSON.stringify(props.roadmapJson), |
||||||
|
}; |
||||||
|
}; |
@ -0,0 +1,30 @@ |
|||||||
|
import type { APIRoute } from 'astro'; |
||||||
|
|
||||||
|
export async function getStaticPaths() { |
||||||
|
const bestPracticeJsons = await import.meta.glob( |
||||||
|
'/src/data/best-practices/**/*.json', |
||||||
|
{ |
||||||
|
eager: true, |
||||||
|
} |
||||||
|
); |
||||||
|
|
||||||
|
return Object.keys(bestPracticeJsons).map((filePath) => { |
||||||
|
const bestPracticeId = filePath.split('/').pop()?.replace('.json', ''); |
||||||
|
const bestPracticeJson = bestPracticeJsons[filePath] as Record<string, any>; |
||||||
|
|
||||||
|
return { |
||||||
|
params: { |
||||||
|
bestPracticeId, |
||||||
|
}, |
||||||
|
props: { |
||||||
|
bestPracticeJson: bestPracticeJson, |
||||||
|
}, |
||||||
|
}; |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
export const get: APIRoute = async function ({ params, request, props }) { |
||||||
|
return { |
||||||
|
body: JSON.stringify(props.bestPracticeJson), |
||||||
|
}; |
||||||
|
}; |
Loading…
Reference in new issue