FHIR, API, datamodel
This commit is contained in:
@@ -137,3 +137,95 @@ export async function getCategoryMetadata(): Promise<IndexData> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate slug from heading text (must match the slugify function in mdx-components.tsx)
|
||||
*/
|
||||
function slugify(text: string): string {
|
||||
return text
|
||||
.toString()
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/\s+/g, '-')
|
||||
.replace(/[^\w\-]+/g, '')
|
||||
.replace(/\-\-+/g, '-')
|
||||
}
|
||||
|
||||
/**
|
||||
* Table of Contents item
|
||||
*/
|
||||
export interface TocItem {
|
||||
id: string
|
||||
text: string
|
||||
level: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract headings from MDX content for Table of Contents
|
||||
* Extracts h1, h2, and h3 headings, filtered for main sections
|
||||
*/
|
||||
export function extractHeadings(content: string): TocItem[] {
|
||||
const headingRegex = /^(#{1,3})\s+(.+)$/gm
|
||||
const headings: TocItem[] = []
|
||||
let match
|
||||
|
||||
// Main sections to include in TOC (h2 level)
|
||||
const includedH2Sections = [
|
||||
'overview',
|
||||
'standaard-compliance',
|
||||
'geimplementeerde-resources',
|
||||
'relaties-tussen-resources',
|
||||
'privacy-beveiliging',
|
||||
'roadmap',
|
||||
'patient-api',
|
||||
'practitioner-api',
|
||||
'encounter-api',
|
||||
'condition-api',
|
||||
'observation-api',
|
||||
'careplan-api',
|
||||
'authenticatie-autorisatie',
|
||||
'error-handling',
|
||||
]
|
||||
|
||||
// Resource subsections to include (h3 level)
|
||||
const includedH3Sections = [
|
||||
'1-practitioners-behandelaren',
|
||||
'2-organizations-instellingen',
|
||||
'3-patients-patientenclienten',
|
||||
'4-encounters-contactmomenten',
|
||||
'5-conditions-diagnoses',
|
||||
'6-observations-metingen-en-observaties',
|
||||
'7-careplans-behandelplannen',
|
||||
]
|
||||
|
||||
while ((match = headingRegex.exec(content)) !== null) {
|
||||
const level = match[1].length
|
||||
const text = match[2]
|
||||
.replace(/\[([^\]]+)\]\([^\)]+\)/g, '$1') // Remove markdown links
|
||||
.replace(/`([^`]+)`/g, '$1') // Remove inline code
|
||||
.replace(/\*\*([^*]+)\*\*/g, '$1') // Remove bold
|
||||
.replace(/\*([^*]+)\*/g, '$1') // Remove italic
|
||||
.trim()
|
||||
|
||||
const id = slugify(text)
|
||||
|
||||
// Include h2 headings from the main sections list
|
||||
if (level === 2 && includedH2Sections.includes(id)) {
|
||||
headings.push({
|
||||
id,
|
||||
text,
|
||||
level,
|
||||
})
|
||||
}
|
||||
// Include h3 headings from the resource sections list
|
||||
else if (level === 3 && includedH3Sections.includes(id)) {
|
||||
headings.push({
|
||||
id,
|
||||
text,
|
||||
level,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return headings
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user