UNPKG

file-cms

Version:

File based Content Management System, easy to use with content stored in native file system

23 lines (22 loc) 999 B
import { __awaiter, __generator } from "tslib"; import { Config } from "./Config"; import { attributeFilter } from "./internal/attributeFilter"; import { fetchContentCached } from "./internal/fetchContentCached"; import { generateSeoTags } from "./internal/seo"; export var getContent = function (type, slug, attributes, seo) { return __awaiter(void 0, void 0, void 0, function () { var rootDir, content, filteredContent; return __generator(this, function (_a) { switch (_a.label) { case 0: rootDir = Config.getRootDir(); return [4 /*yield*/, fetchContentCached(rootDir, type, slug)]; case 1: content = _a.sent(); filteredContent = attributeFilter(content, attributes); if (seo !== undefined) { filteredContent["_seoMetaTags"] = generateSeoTags(content, seo); } return [2 /*return*/, filteredContent]; } }); }); };