From cb3edb0b2bdea87cd29559e4a9df2e7c062a4df7 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 17 Aug 2022 22:02:37 -0300 Subject: read static pages from directory --- src/data/yaml.js | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/data') diff --git a/src/data/yaml.js b/src/data/yaml.js index 367876be..2c3c988d 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -62,9 +62,9 @@ export const FLASH_DATA_FILE = 'flashes.yaml'; export const NEWS_DATA_FILE = 'news.yaml'; export const ART_TAG_DATA_FILE = 'tags.yaml'; export const GROUP_DATA_FILE = 'groups.yaml'; -export const STATIC_PAGE_DATA_FILE = 'static-pages.yaml'; export const DATA_ALBUM_DIRECTORY = 'album'; +export const DATA_STATIC_PAGE_DIRECTORY = 'static-page'; // --> Document processing functions @@ -670,10 +670,10 @@ export const dataSteps = [ files: async (dataPath) => ( await findFiles(path.join(dataPath, DATA_ALBUM_DIRECTORY), { - filter: (f) => path.extname(f) === '.yaml', + filter: f => path.extname(f) === '.yaml', joinParentDirectory: false, }) - ).map((file) => path.join(DATA_ALBUM_DIRECTORY, file)), + ).map(file => path.join(DATA_ALBUM_DIRECTORY, file)), documentMode: documentModes.headerAndEntries, processHeaderDocument: processAlbumDocument, @@ -913,10 +913,16 @@ export const dataSteps = [ }, { - title: `Process static pages file`, - file: STATIC_PAGE_DATA_FILE, + title: `Process static page files`, + files: async (dataPath) => + ( + await findFiles(path.join(dataPath, DATA_STATIC_PAGE_DIRECTORY), { + filter: f => path.extname(f) === '.yaml', + joinParentDirectory: false, + }) + ).map(file => path.join(DATA_STATIC_PAGE_DIRECTORY, file)), - documentMode: documentModes.allInOne, + documentMode: documentModes.onePerFile, processDocument: processStaticPageDocument, save(staticPageData) { @@ -1021,11 +1027,17 @@ export async function loadAndProcessDataDocuments({dataPath}) { ); } - const files = ( + let files = ( typeof dataStep.files === 'function' ? await callAsync(dataStep.files, dataPath) : dataStep.files - ).map((file) => path.join(dataPath, file)); + ) + + if (!files) { + return; + } + + files = files.map((file) => path.join(dataPath, file)); const readResults = await mapAsync( files, -- cgit 1.3.0-6-gf8a5