Update doc metadata to use file name as id fallback and id as title fallback

This commit is contained in:
Frank Li 2017-08-10 14:51:34 -07:00
parent db7a7394b3
commit 964e9e2108
5 changed files with 56 additions and 27 deletions

View file

@ -60,6 +60,10 @@ function splitHeader(content) {
function extractMetadata(content) {
const metadata = {};
const both = splitHeader(content);
// if no content returned, then that means there was no header, and both.header is the content
if (!both.content) {
return { metadata, rawContent: both.header };
}
const lines = both.header.split("\n");
for (let i = 0; i < lines.length - 1; ++i) {
const keyvalue = lines[i].split(":");
@ -265,8 +269,9 @@ function diffLatestSidebar() {
return true;
}
const currentSidebar = CWD + "/sidebars.json";
// if no current sidebar file, return false so no sidebar file gets copied
if (!fs.existsSync(currentSidebar)) {
// TO DO: error message
return false;
}
// compare for equality between latest version sidebar with version prefixes