sheets
This commit is contained in:
@@ -56,18 +56,9 @@ function normalizeExcelKey(value: string): string {
|
||||
.replace(/[^A-Z0-9]+/g, '');
|
||||
}
|
||||
|
||||
function extractDescriptionHtmlFromMdxBody(body: string): string {
|
||||
const content = String(body || '').trim();
|
||||
if (!content) return '';
|
||||
|
||||
// MDX product files are wrapped like:
|
||||
// <ProductTabs technicalData={...}>
|
||||
// <section>...</section>
|
||||
// </ProductTabs>
|
||||
// For PDF, we only want the inner description content.
|
||||
const withoutOpen = content.replace(/^\s*<ProductTabs[\s\S]*?>\s*/i, '');
|
||||
const withoutClose = withoutOpen.replace(/\s*<\/ProductTabs>\s*$/i, '');
|
||||
return withoutClose.trim();
|
||||
function extractDescriptionFromMdxFrontmatter(data: any): string {
|
||||
const description = normalizeValue(String(data?.description || ''));
|
||||
return description;
|
||||
}
|
||||
|
||||
function buildMdxIndex(locale: 'en' | 'de'): MdxIndex {
|
||||
@@ -93,7 +84,7 @@ function buildMdxIndex(locale: 'en' | 'de'): MdxIndex {
|
||||
const categories = Array.isArray(data.categories) ? data.categories.map((c: any) => normalizeValue(String(c))).filter(Boolean) : [];
|
||||
const images = Array.isArray(data.images) ? data.images.map((i: any) => normalizeValue(String(i))).filter(Boolean) : [];
|
||||
|
||||
const descriptionHtml = extractDescriptionHtmlFromMdxBody(parsed.content);
|
||||
const descriptionHtml = extractDescriptionFromMdxFrontmatter(data);
|
||||
|
||||
const slug = path.basename(file, '.mdx');
|
||||
idx.set(normalizeExcelKey(title), { slug, title, sku, categories, images, descriptionHtml });
|
||||
|
||||
Reference in New Issue
Block a user