diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-01-29 08:10:30 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-01-30 07:59:40 -0400 |
commit | eb8b316bb9af7d34720de1fa8f8dbd4b81513b32 (patch) | |
tree | 22d435e702b89344304928b7a860a5326357f192 /src/data/things/static-page.js | |
parent | b30585187480a270826767eaf97e1acc66126072 (diff) |
data, yaml: store data step info on Thing constructors
Diffstat (limited to 'src/data/things/static-page.js')
-rw-r--r-- | src/data/things/static-page.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/data/things/static-page.js b/src/data/things/static-page.js index 2da7312b..1e8cb7c6 100644 --- a/src/data/things/static-page.js +++ b/src/data/things/static-page.js @@ -1,5 +1,11 @@ +export const DATA_STATIC_PAGE_DIRECTORY = 'static-page'; + +import * as path from 'node:path'; + +import {traverse} from '#node-utils'; import Thing from '#thing'; import {isName} from '#validators'; +import {sortAlphabetically} from '#wiki-data'; import {contentString, directory, name, simpleString} from '#composite/wiki-properties'; @@ -42,4 +48,26 @@ export class StaticPage extends Thing { 'Review Points': {ignore: true}, }, }; + + static [Thing.getYamlLoadingSpec] = ({ + documentModes: {onePerFile}, + thingConstructors: {StaticPage}, + }) => ({ + title: `Process static page files`, + + files: dataPath => + traverse(path.join(dataPath, DATA_STATIC_PAGE_DIRECTORY), { + filterFile: name => path.extname(name) === '.yaml', + prefixPath: DATA_STATIC_PAGE_DIRECTORY, + }), + + documentMode: onePerFile, + documentThing: StaticPage, + + save(staticPageData) { + sortAlphabetically(staticPageData); + + return {staticPageData}; + }, + }); } |