77 lines
2.1 KiB
Python
77 lines
2.1 KiB
Python
import yaml
|
|
import os
|
|
|
|
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 model_id in configs.keys():
|
|
path = f"packages/content-models/{model_id}/model.yml"
|
|
if not os.path.exists(path): continue
|
|
|
|
with open(path, 'r') as f:
|
|
data = yaml.safe_load(f)
|
|
|
|
new_data = {
|
|
'id': data['id'],
|
|
'kind': 'content-model',
|
|
'name': data['name'],
|
|
'description': data['description'],
|
|
'semantics': {
|
|
'document': True,
|
|
'chronological': configs[model_id]['chronological'],
|
|
'searchable': True,
|
|
'indexable': True
|
|
},
|
|
'routing': {
|
|
'detail': configs[model_id]['routing']
|
|
},
|
|
'presentation': {
|
|
'default_style_config': data.get('defaultStyleConfig', 'article')
|
|
},
|
|
'capabilities': configs[model_id]['caps']
|
|
}
|
|
|
|
with open(path, 'w') as f:
|
|
yaml.dump(new_data, f, sort_keys=False)
|
|
|