@mdfriday/foundry
Version:
The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.
52 lines • 1.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getKindMain = getKindMain;
exports.isBranch = isBranch;
exports.isDeprecatedAndReplacedWith = isDeprecatedAndReplacedWith;
const type_1 = require("../type");
// Main kinds map - kinds that can be found in .Site.Pages
const kindMapMain = {
[type_1.PageKind.PAGE]: type_1.PageKind.PAGE,
[type_1.PageKind.HOME]: type_1.PageKind.HOME,
[type_1.PageKind.SECTION]: type_1.PageKind.SECTION,
[type_1.PageKind.TAXONOMY]: type_1.PageKind.TAXONOMY,
[type_1.PageKind.TERM]: type_1.PageKind.TERM,
[type_1.PageKind.STATUS_404]: type_1.PageKind.STATUS_404,
[type_1.PageKind.SITEMAP]: type_1.PageKind.SITEMAP,
// Legacy, pre v0.53.0.
'taxonomyterm': type_1.PageKind.TAXONOMY,
};
/**
* Gets the page kind given a string, empty if not found.
* Note that this will not return any temporary kinds (e.g. robotstxt).
*/
function getKindMain(s) {
return kindMapMain[s.toLowerCase()] || '';
}
/**
* Returns whether the given kind is a branch node.
*/
function isBranch(kind) {
switch (kind) {
case type_1.PageKind.HOME:
case type_1.PageKind.SECTION:
case type_1.PageKind.TAXONOMY:
case type_1.PageKind.TERM:
return true;
default:
return false;
}
}
/**
* Returns the new kind if the given kind is deprecated.
*/
function isDeprecatedAndReplacedWith(s) {
const lowered = s.toLowerCase();
switch (lowered) {
case 'taxonomyterm':
return type_1.PageKind.TAXONOMY;
default:
return '';
}
}
//# sourceMappingURL=kind.js.map