${node.content}
` - break - case 'h1': - case 'h2': - case 'h3': - case 'h4': - case 'h5': - case 'h6': - context.lastLink = node.properties?.id ?? githubSlugger.slug(node.content) - break - } - - const transformed = { - ...node, - additionalProperties: { - hash: context.lastLink - } - } - - if (raw) { - transformed.raw = raw - } - - return transformed -} - -export function defaultToSectionSchema( - node: DefaultSchemaElement, - pageRoute: string, - sectionTitle: string, - version: string -): SectionSchema { - const { content, type, properties } = node - - if (!sectionTitle) { - sectionTitle = (pageRoute.split('/').pop() ?? '') - .replace(/(-)+/g, ' ') - .split(' ') - .map((word) => word && `${word[0].toUpperCase()}${word.substring(1)}`) - .join(' ') - } - - return { - pageRoute, - hash: (properties?.hash as string) ?? '', - sectionTitle: pageRoute ? sectionTitle : 'Home', - sectionContent: content, - type, - version - } -} - -function isIndexable(doc: SectionSchema): boolean { - return ( - !!doc.sectionContent && !!doc.sectionTitle && doc.type !== 'script' && !doc.pageRoute.startsWith('/blogs/tags/') - ) -} - -async function generateDocument( - siteDir: string, - { title, version, permalink, source }: Record