From 636e1d8a7687a34ef7285960b64122ef0f5e1bfa Mon Sep 17 00:00:00 2001 From: tree Date: Mon, 3 Jan 2022 08:54:10 +0100 Subject: [PATCH] global index --- utils/utxo.lib.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/utils/utxo.lib.js b/utils/utxo.lib.js index 311c6e6..a0d5772 100644 --- a/utils/utxo.lib.js +++ b/utils/utxo.lib.js @@ -2,6 +2,8 @@ import { emptyDir } from "https://deno.land/std@0.119.0/fs/mod.ts" import { copy } from "https://deno.land/std@0.119.0/fs/copy.ts" import { load } from 'https://deno.land/x/js_yaml_port/js-yaml.js' +const baseUrl = 'https://spec.utxo.cz' + const banner = ` ██╗░░░██╗████████╗██╗░░██╗░█████╗░ ██║░░░██║╚══██╔══╝╚██╗██╔╝██╔══██╗ @@ -48,6 +50,7 @@ export class UTXO { async build (outputDir) { await emptyDir(outputDir) + const entriesIndex = [] for (const entryId of Object.keys(this.entries)) { if (!this.options.silent) { @@ -61,7 +64,7 @@ export class UTXO { const specEndpoints = {} for (const specName of Object.keys(entry.specs)) { await this._jsonWrite([ entryDir, `${specName}.json` ], entry.specs[specName]) - specEndpoints[specName] = `https://spec.utxo.cz/${entryId}/${specName}.json` + specEndpoints[specName] = `${baseUrl}/${entryId}/${specName}.json` } // write index @@ -88,8 +91,17 @@ export class UTXO { console.log(`copying photos to ${outputPhotosDir}`) } await copy([ this.srcDir, entryId, 'photos'].join('/'), outputPhotosDir, { overwrite: true }) + + entriesIndex.push({ + id: `utxo${entryId}`, + entryId, + url: `${baseUrl}/${entryId}` + }) } + // write global index + await this._jsonWrite([ outputDir, 'index.json' ], entriesIndex) + if (!this.options.silent) { console.log('\nBuild done') }