Distinguish historical toolbox examples from current result flow
This commit is contained in:
@@ -16,12 +16,14 @@ for(const [id,entry] of [[canonical,current],[legacy,old]]){try{await readFile(d
|
||||
const catalogue=await api('/studio/api/layouts');
|
||||
let markdown=(await readFile(new URL('../content/studio-tools/layouts-api.md',import.meta.url),'utf8')).replace('{{LAYOUTS}}',catalogue.layouts.filter(l=>l.family==='fixed').map(l=>`- [${l.id} · ${l.name}](${l.url}) · [参数](${l.api})`).join('\n'));
|
||||
const appendixMarker='## 兼容工具原说明与代码示例';
|
||||
const historicalNotice='> 以下保留历史工具示例,不代表当前 API 保存与打开流程。历史文字中关于首页、编辑器和旧结果地址的描述已过时:当前由 API 创建 ID,直接打开 `/studio/template-layout?id={UUID}`,无需选版或编辑器。当前契约以上文为准。';
|
||||
if(current.editableMarkdown.includes(appendixMarker)){
|
||||
markdown+='\n\n'+current.editableMarkdown.slice(current.editableMarkdown.indexOf(appendixMarker));
|
||||
const appendix=current.editableMarkdown.slice(current.editableMarkdown.indexOf(appendixMarker));
|
||||
markdown+='\n\n'+(appendix.includes(historicalNotice)?appendix:appendix.replace(appendixMarker,appendixMarker+'\n\n'+historicalNotice));
|
||||
}else{
|
||||
if(old.archived)throw Error('Original toolbox appendix is missing; refusing to replace it with the archived redirect');
|
||||
const legacyOriginal=JSON.parse(await readFile(dir+'/'+legacy+'-before.json','utf8')).editableMarkdown;
|
||||
markdown+='\n\n'+appendixMarker+'\n\n以下保留原工具的说明与 HTML/React/Next.js 调用示例;它们是无状态兼容接口,持久化页面请使用上文 CRUD。\n\n'+legacyOriginal;
|
||||
markdown+='\n\n'+appendixMarker+'\n\n'+historicalNotice+'\n\n以下保留原工具的说明与 HTML/React/Next.js 调用示例;它们是无状态兼容接口,持久化页面请使用上文 CRUD。\n\n'+legacyOriginal;
|
||||
}
|
||||
const tagIds=entry=>[...new Set([...(entry.systemTags||[]).map(t=>t.id),...entry.categories.map(name=>tags.find(t=>t.name===name)?.id).filter(Boolean)])];
|
||||
const body=(entry,text,title=entry.title)=>({title,description:entry.description,markdown:text,tags:tagIds(entry),assets:entry.assets,coverAssetId:entry.coverAssetId,revision:entry.revision});
|
||||
|
||||
Reference in New Issue
Block a user