Import Labyricorn Control Plane
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
import fs from 'fs';
|
||||
import yaml from 'yaml';
|
||||
|
||||
const configs = {
|
||||
'article': {
|
||||
routing: '/articles/{slug}/',
|
||||
chronological: true,
|
||||
caps: ['detail-page', 'index-page', 'rss', 'search']
|
||||
},
|
||||
'devlog': {
|
||||
routing: '/devlogs/{slug}/',
|
||||
chronological: true,
|
||||
caps: ['detail-page', 'index-page', 'rss', 'search']
|
||||
},
|
||||
'discussion': {
|
||||
routing: '/discussions/{slug}/',
|
||||
chronological: true,
|
||||
caps: ['detail-page', 'index-page', 'rss', 'search']
|
||||
},
|
||||
'documentation': {
|
||||
routing: '/docs/{slug}/',
|
||||
chronological: false,
|
||||
caps: ['detail-page', 'index-page', 'search']
|
||||
},
|
||||
'page': {
|
||||
routing: '/{slug}/',
|
||||
chronological: false,
|
||||
caps: ['detail-page', 'search']
|
||||
},
|
||||
'project': {
|
||||
routing: '/projects/{slug}/',
|
||||
chronological: false,
|
||||
caps: ['detail-page', 'index-page', 'search']
|
||||
},
|
||||
'release': {
|
||||
routing: '/releases/{slug}/',
|
||||
chronological: true,
|
||||
caps: ['detail-page', 'index-page', 'rss', 'search']
|
||||
},
|
||||
'wiki': {
|
||||
routing: '/wiki/{slug}/',
|
||||
chronological: false,
|
||||
caps: ['detail-page', 'index-page', 'search']
|
||||
}
|
||||
};
|
||||
|
||||
for (const modelId of Object.keys(configs)) {
|
||||
const p = `packages/content-models/${modelId}/model.yml`;
|
||||
if (!fs.existsSync(p)) continue;
|
||||
|
||||
const file = fs.readFileSync(p, 'utf8');
|
||||
const data = yaml.parse(file);
|
||||
|
||||
const conf = configs[modelId];
|
||||
const newData = {
|
||||
id: data.id,
|
||||
kind: 'content-model',
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
semantics: {
|
||||
document: true,
|
||||
chronological: conf.chronological,
|
||||
searchable: true,
|
||||
indexable: true
|
||||
},
|
||||
routing: {
|
||||
detail: conf.routing
|
||||
},
|
||||
presentation: {
|
||||
default_style_config: data.defaultStyleConfig || 'article'
|
||||
},
|
||||
capabilities: conf.caps
|
||||
};
|
||||
|
||||
fs.writeFileSync(p, yaml.stringify(newData));
|
||||
}
|
||||
Reference in New Issue
Block a user