UNPKG

@jmuchovej/paperpile-notion

Version:
43 lines (42 loc) 1.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Author = exports.prepareAuthorsForNotion = exports.AuthorToNotion = exports.getFrontmatter = void 0; const notion_api_1 = require("@jitl/notion-api"); const notion_cms_1 = require("../notion-cms"); const getFrontmatter = (page) => { // const blocks = await getChildBlocks(Notion, page.id) const name = (0, notion_api_1.getPageTitle)(page); // TODO this needs to be changed based on whether there's an Author's database const aliases = (0, notion_api_1.getPropertyValue)(page, { name: `Aliases`, type: `rich_text` }); const papers = (0, notion_api_1.getPropertyValue)(page, { name: `Papers`, type: `relation` }); const plain = { Name: (0, notion_api_1.richTextAsPlainText)(name).trim(), Aliases: (0, notion_api_1.richTextAsPlainText)(aliases), }; const aliasesList = [ plain.Name, ...plain.Aliases.split(`;`), ].map(a => a.trim()).filter(a => a); // TODO gather child block lengths return { plain, name, aliases, aliasesList, pageID: page.id, papers }; }; exports.getFrontmatter = getFrontmatter; const AuthorToNotion = (author) => { const Name = (0, notion_cms_1.makeTitle)(author.name.trim()); if (!Name) return; return { Name }; }; exports.AuthorToNotion = AuthorToNotion; const prepareAuthorsForNotion = (author) => { const entry = { name: author.trim(), }; return entry; }; exports.prepareAuthorsForNotion = prepareAuthorsForNotion; var Author; (function (Author) { const toNotion = exports.AuthorToNotion; const prepare = exports.prepareAuthorsForNotion; })(Author = exports.Author || (exports.Author = {}));