UNPKG

changelog-guru

Version:
37 lines (36 loc) 1.38 kB
const MIN_HEADER_LEVEL = 1; const MAX_HEADER_LEVEL = 6; export const capitalize = (text) => text.charAt(0).toUpperCase() + text.slice(1); export const code = (text, lang = '') => `\`\`\`${lang} ${text} \`\`\``; export const commit = (text, url) => link(wrap(text), url); export const contributors = (links) => [line(), title('Contributors'), links.join(' ')].join('\n'); export const details = (text) => `<details>\n${text}\n</details>\n`; export const header = (level) => '#'.padStart(headerLevel(level), '#'); export const headerLevel = (level) => Math.min(MAX_HEADER_LEVEL, Math.max(MIN_HEADER_LEVEL, level)); export const image = (text, img, url) => link(`![${text}](${img})`, url); export const license = (type) => link(type, `https://spdx.org/licenses/${type}.html`); export const line = () => '---\n'; export const link = (text, url) => `[${text}](${url})`; export const list = (text) => `- ${capitalize(text)}`; export const strong = (text) => `**${text}**`; export const summary = (text) => `<summary>${text}</summary>\n`; export const title = (text, level = 1) => `${header(level)} ${capitalize(text)}\n`; export const wrap = (text) => `\`${text}\``; export default { capitalize, code, commit, contributors, details, header, headerLevel, image, license, line, link, list, strong, summary, title, wrap, };