import { CHAPTER_SEPARATOR, PARAGRAPH_BREAK } from "#configuration/constants/chapter.constants"; import { DETAILS_CLOSE, DETAILS_OPEN, HEADING_THREE, SUMMARY_CLOSE, SUMMARY_OPEN, } from "#configuration/constants/readme.constants"; import { FAQ_TITLE } from "#configuration/strings/readme.strings"; import { LINE_END } from "#configuration/constants/inventory.constants"; import type { ReadmePage } from "#types/readme.types"; import { section } from "#core/renderers/markdown.renderer"; const question = function question(title: string, content: string | null): string { const rule = CHAPTER_SEPARATOR.trim(); return [ DETAILS_OPEN, SUMMARY_OPEN + title + SUMMARY_CLOSE, "", rule, "", content ?? "", "", rule, "", DETAILS_CLOSE, ].join(LINE_END); }; export const renderFaq = function renderFaq(page: ReadmePage): string { const groups = page.tabs .flatMap((tab) => tab.sections) .map((held) => [HEADING_THREE + held.title, ...held.subsections.map((sub) => question(sub.title, sub.content))].join( PARAGRAPH_BREAK, ), ); return section(FAQ_TITLE, ...groups); };