use correct name, fixes #77

This commit is contained in:
Bastian Ike
2021-05-28 10:39:21 +02:00
parent 4bde00debf
commit 630e03a92d
2 changed files with 6 additions and 20 deletions

View File

@@ -35,14 +35,6 @@ const checkAttributes = (fileName: string, attributes: FMAttributes) => {
throw new Error(`Error: ${fileName} has an illegal value for 'quadrant' - must be one of ${quadrants}`);
}
if (!attributes.quadrant || attributes.quadrant === '') {
// throw new Error(`Error: ${fileName} has no 'quadrant' set`);
}
if (!attributes.title || attributes.title === '') {
attributes.title = path.basename(fileName);
}
return attributes
};
@@ -76,9 +68,9 @@ const createRevisionsFromFiles = (fileNames: string[]) =>
);
const itemInfoFromFilename = (fileName: string) => {
const [release, nameWithSuffix] = fileName.split(path.sep).slice(-2);
const [release, name] = fileName.split(path.sep).slice(-2);
return {
name: nameWithSuffix.substr(0, nameWithSuffix.length - 3),
name: path.basename(name, '.md'),
release,
};
};
@@ -101,7 +93,7 @@ const createItems = (revisions: Revision[]) => {
};
}, {});
return Object.values(itemMap).sort((x, y) => (x.name > y.name ? 1 : -1));
return Object.values(itemMap).map(item => ({...item, ['title']: item.title || item.name})).sort((x, y) => (x.name > y.name ? 1 : -1));
};
const ignoreEmptyRevisionBody = (revision: Revision, item: Item) => {