Move repository content images to S3-backed media references

This commit is contained in:
2026-10-29 23:03:11 +08:00
parent 906c6985cb
commit 19bba57561
630 changed files with 5666 additions and 391 deletions
+2 -1
View File
@@ -1,7 +1,8 @@
import {managedMedia} from './managed-media.mjs';
/** Package the 27 audited layers; no new Wiki document routes or copied DB. */
import {readFile,writeFile} from 'node:fs/promises';
const root=new URL('../',import.meta.url),read=p=>readFile(new URL(p,root)),raw=JSON.parse(await read('content/layout-reference/manifest.json')),ids=JSON.parse(await read('content/layout-reference/post-ids.json'));
const image=async p=>'data:image/png;base64,'+(await read('content/layout-reference/assets/'+p.replace(/^asset:/,''))).toString('base64');
const image=async p=>'/api/media/'+managedMedia['content/layout-reference/assets/'+p.replace(/^asset:/,'')].id;
const layouts=[];
for(const m of raw){const elements=[];for(const e of m.elements)elements.push({...e,raster:await image(e.asset),...(e.mask?{shape:await image(e.mask)}:{})});layouts.push({id:m.id,name:m.name,width:m.width,height:m.height,tutorialUrl:'/explore/'+ids[m.id],sourceSha256:m.source.sha256,source:await image(m.reference),background:await image(m.background),elements});}
await writeFile(new URL('apps/studio/src/content/templates/layouts.json',root),JSON.stringify(layouts));