Use more structured yaml for examples source path

This commit is contained in:
Maximilian Krög
2021-11-02 22:02:23 +01:00
parent 12de93b397
commit 07fa1adfe8
3 changed files with 6 additions and 6 deletions

View File

@@ -6,7 +6,7 @@ docs: >
Move a map to a seperate window.
tags: "external, window"
sources:
- resources/external-map-map.html
- path: resources/external-map-map.html
---
<div id="map" class="map"></div>
<input id="external-map-button" type="button" value="Open external map"></input>

View File

@@ -7,7 +7,8 @@ docs: >
tags: "worker, offscreencanvas, vector-tiles"
experimental: true
sources:
- offscreen-canvas.worker.js as worker.js
- path: offscreen-canvas.worker.js
as: worker.js
cloak:
- key: get_your_own_D6rA4zTHduk6KOKTXzGB
value: Get your own API key at https://www.maptiler.com/cloud/

View File

@@ -314,9 +314,8 @@ export default class ExampleBuilder {
let jsSources = jsSource;
if (data.sources) {
data.extraSources = await Promise.all(
data.sources.map(async (fileName) => {
const as = fileName.split(/ +as +/);
fileName = as[0];
data.sources.map(async (sourceConfig) => {
const fileName = sourceConfig.path;
const extraSourcePath = path.join(data.dir, fileName);
let source = await fse.readFile(extraSourcePath, readOptions);
let ext = fileName.match(/\.(\w+)$/)[1];
@@ -330,7 +329,7 @@ export default class ExampleBuilder {
source = this.cloakSource(source, data.cloak);
assets[fileName] = source;
return {
name: as[1] || fileName,
name: sourceConfig.as ?? fileName,
source: source,
type: ext,
};