myst-frontmatter
Advanced tools
Comparing version 0.0.13 to 0.0.14
@@ -38,2 +38,3 @@ "use strict"; | ||
'math', | ||
'abbreviations', | ||
'exports', | ||
@@ -75,2 +76,3 @@ 'thebe', | ||
'affiliations', | ||
'collaborations', | ||
'twitter', | ||
@@ -235,2 +237,13 @@ 'github', | ||
} | ||
if ((0, simple_validators_1.defined)(value.collaborations)) { | ||
const collaborationsOpts = (0, simple_validators_1.incrementOptions)('collaborations', opts); | ||
let collaborations = value.collaborations; | ||
if (typeof collaborations === 'string') { | ||
collaborations = collaborations.split(';'); | ||
} | ||
output.collaborations = (0, simple_validators_1.validateList)(collaborations, collaborationsOpts, (col) => { | ||
var _a; | ||
return (_a = (0, simple_validators_1.validateString)(col, collaborationsOpts)) === null || _a === void 0 ? void 0 : _a.trim(); | ||
}); | ||
} | ||
if ((0, simple_validators_1.defined)(value.twitter)) { | ||
@@ -676,2 +689,13 @@ output.twitter = (0, simple_validators_1.validateString)(value.twitter, (0, simple_validators_1.incrementOptions)('twitter', opts)); | ||
} | ||
if ((0, simple_validators_1.defined)(value.abbreviations)) { | ||
const abbreviationsOpts = (0, simple_validators_1.incrementOptions)('abbreviations', opts); | ||
const abbreviations = (0, simple_validators_1.validateObject)(value.abbreviations, abbreviationsOpts); | ||
if (abbreviations) { | ||
const stringKeys = Object.keys(abbreviations).filter((key) => { | ||
// Filter on non-string values | ||
return (0, simple_validators_1.validateString)(abbreviations[key], (0, simple_validators_1.incrementOptions)(key, abbreviationsOpts)); | ||
}); | ||
output.abbreviations = (0, simple_validators_1.filterKeys)(abbreviations, stringKeys); | ||
} | ||
} | ||
if ((0, simple_validators_1.defined)(value.exports)) { | ||
@@ -756,3 +780,3 @@ const exports = validateExportsList(value.exports, opts); | ||
function fillPageFrontmatter(pageFrontmatter, projectFrontmatter) { | ||
var _a, _b; | ||
var _a, _b, _c, _d; | ||
const frontmatter = (0, simple_validators_1.fillMissingKeys)(pageFrontmatter, projectFrontmatter, exports.USE_PROJECT_FALLBACK); | ||
@@ -769,2 +793,6 @@ // If numbering is an object, combine page and project settings. | ||
} | ||
// Combine all abbreviation defined on page and project | ||
if (projectFrontmatter.abbreviations || pageFrontmatter.abbreviations) { | ||
frontmatter.abbreviations = Object.assign(Object.assign({}, ((_c = projectFrontmatter.abbreviations) !== null && _c !== void 0 ? _c : {})), ((_d = pageFrontmatter.abbreviations) !== null && _d !== void 0 ? _d : {})); | ||
} | ||
return frontmatter; | ||
@@ -771,0 +799,0 @@ } |
@@ -32,2 +32,3 @@ import doi from 'doi-utils'; | ||
'math', | ||
'abbreviations', | ||
'exports', | ||
@@ -69,2 +70,3 @@ 'thebe', | ||
'affiliations', | ||
'collaborations', | ||
'twitter', | ||
@@ -228,2 +230,13 @@ 'github', | ||
} | ||
if (defined(value.collaborations)) { | ||
const collaborationsOpts = incrementOptions('collaborations', opts); | ||
let collaborations = value.collaborations; | ||
if (typeof collaborations === 'string') { | ||
collaborations = collaborations.split(';'); | ||
} | ||
output.collaborations = validateList(collaborations, collaborationsOpts, (col) => { | ||
var _a; | ||
return (_a = validateString(col, collaborationsOpts)) === null || _a === void 0 ? void 0 : _a.trim(); | ||
}); | ||
} | ||
if (defined(value.twitter)) { | ||
@@ -656,2 +669,13 @@ output.twitter = validateString(value.twitter, incrementOptions('twitter', opts)); | ||
} | ||
if (defined(value.abbreviations)) { | ||
const abbreviationsOpts = incrementOptions('abbreviations', opts); | ||
const abbreviations = validateObject(value.abbreviations, abbreviationsOpts); | ||
if (abbreviations) { | ||
const stringKeys = Object.keys(abbreviations).filter((key) => { | ||
// Filter on non-string values | ||
return validateString(abbreviations[key], incrementOptions(key, abbreviationsOpts)); | ||
}); | ||
output.abbreviations = filterKeys(abbreviations, stringKeys); | ||
} | ||
} | ||
if (defined(value.exports)) { | ||
@@ -732,3 +756,3 @@ const exports = validateExportsList(value.exports, opts); | ||
export function fillPageFrontmatter(pageFrontmatter, projectFrontmatter) { | ||
var _a, _b; | ||
var _a, _b, _c, _d; | ||
const frontmatter = fillMissingKeys(pageFrontmatter, projectFrontmatter, USE_PROJECT_FALLBACK); | ||
@@ -745,2 +769,6 @@ // If numbering is an object, combine page and project settings. | ||
} | ||
// Combine all abbreviation defined on page and project | ||
if (projectFrontmatter.abbreviations || pageFrontmatter.abbreviations) { | ||
frontmatter.abbreviations = Object.assign(Object.assign({}, ((_c = projectFrontmatter.abbreviations) !== null && _c !== void 0 ? _c : {})), ((_d = pageFrontmatter.abbreviations) !== null && _d !== void 0 ? _d : {})); | ||
} | ||
return frontmatter; | ||
@@ -747,0 +775,0 @@ } |
@@ -12,2 +12,3 @@ import type { CreditRole } from 'credit-roles'; | ||
affiliations?: string[]; | ||
collaborations?: string[]; | ||
twitter?: string; | ||
@@ -133,2 +134,4 @@ github?: string; | ||
math?: Record<string, string>; | ||
/** Abbreviations used throughout the project */ | ||
abbreviations?: Record<string, string>; | ||
exports?: Export[]; | ||
@@ -135,0 +138,0 @@ thebe?: boolean | Thebe; |
{ | ||
"name": "myst-frontmatter", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"sideEffects": false, | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
177275
3479