From 4e6994c98c4d7a7f72334fca424889763a328f67 Mon Sep 17 00:00:00 2001 From: tree Date: Fri, 20 Oct 2023 05:02:35 +0200 Subject: [PATCH] update gen --- utils/w3pdata.js | 55 +++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/utils/w3pdata.js b/utils/w3pdata.js index 6a8ca87c..243af3c0 100644 --- a/utils/w3pdata.js +++ b/utils/w3pdata.js @@ -20,36 +20,33 @@ export class W3PData { if (f.isDirectory && f.name === "projects") { out.projects = []; const projectsDir = `${dataDir}/${f.name}`; - for await (const pcd of Deno.readDir(projectsDir)) { - const catName = pcd.name; - const catDir = `${projectsDir}/${pcd.name}`; - for await (const pd of Deno.readDir(catDir)) { - if (!pd.isDirectory) { - continue; - } - const pDir = `${catDir}/${pd.name}`; - const indexFn = `${pDir}/index.yaml`; - - const index = Object.assign({ id: pd.name }, yaml.load( - await Deno.readTextFile(indexFn), - )) - - index._path = pDir - - // read attachments - const logos = [] - for await (const pa of Deno.readDir(pDir)) { - const pam = pa.name.match(/^(logo)\.(.+)$/) - if (pam && pam[1] === 'logo') { - logos.push({ file: pam[0], ext: pam[2], url: `${DATA_URL}/assets/projects/${index.id}/${pam[0]}` }) - } - } - if (logos.length > 0) { - index.logos = logos - } - - out.projects.push(index); + for await (const pd of Deno.readDir(projectsDir)) { + + if (!pd.isDirectory) { + continue; } + const pDir = `${dataDir}/${f.name}/${pd.name}`; + const indexFn = `${pDir}/index.yaml`; + + const index = Object.assign({ id: pd.name }, yaml.load( + await Deno.readTextFile(indexFn), + )) + + index._path = pDir + + // read attachments + const logos = [] + for await (const pa of Deno.readDir(pDir)) { + const pam = pa.name.match(/^(logo)\.(.+)$/) + if (pam && pam[1] === 'logo') { + logos.push({ file: pam[0], ext: pam[2], url: `${DATA_URL}/assets/projects/${index.id}/${pam[0]}` }) + } + } + if (logos.length > 0) { + index.logos = logos + } + + out.projects.push(index); } } }