@fullstackdatasolutions/articles 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/nextjs.cjs +14 -4
- package/dist/nextjs.cjs.map +1 -1
- package/dist/nextjs.js +14 -4
- package/dist/nextjs.js.map +1 -1
- package/dist/server.cjs +14 -4
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +14 -4
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/server-articles.test.ts +4 -3
- package/src/markdown.ts +48 -3
- package/src/server-articles.ts +1 -3
package/dist/server.js
CHANGED
|
@@ -365,7 +365,7 @@ function markdownToHtml(markdown, articleSlug, config) {
|
|
|
365
365
|
if (articleSlug) {
|
|
366
366
|
processor = processor.use(rehypeProcessImages, { articleSlug });
|
|
367
367
|
}
|
|
368
|
-
const result = yield processor.use(rehypeStringify).process(markdown);
|
|
368
|
+
const result = yield processor.use(rehypeStringify).process(stripInlineTagsFromHeadings(markdown));
|
|
369
369
|
return result.toString();
|
|
370
370
|
} catch (error) {
|
|
371
371
|
reportArticlesError({
|
|
@@ -378,8 +378,18 @@ function markdownToHtml(markdown, articleSlug, config) {
|
|
|
378
378
|
}
|
|
379
379
|
});
|
|
380
380
|
}
|
|
381
|
+
function stripInlineTagsFromHeadings(markdown) {
|
|
382
|
+
return markdown.replace(
|
|
383
|
+
/^(#{1,6}[ \t].*)$/gm,
|
|
384
|
+
(line) => line.replace(/<\/?[a-zA-Z][^<>\n]*>/g, "")
|
|
385
|
+
);
|
|
386
|
+
}
|
|
381
387
|
function nodeTextValue(c) {
|
|
382
|
-
|
|
388
|
+
if (c.type === "text") return c.value;
|
|
389
|
+
if (c.type === "element" && "children" in c) {
|
|
390
|
+
return c.children.map(nodeTextValue).join("");
|
|
391
|
+
}
|
|
392
|
+
return "";
|
|
383
393
|
}
|
|
384
394
|
function extractHeadingItem(node) {
|
|
385
395
|
var _a;
|
|
@@ -415,7 +425,7 @@ function extractToc(markdown) {
|
|
|
415
425
|
if (item) headings.push(item);
|
|
416
426
|
});
|
|
417
427
|
};
|
|
418
|
-
yield remark().use(remarkParse).use(remarkGfm).use(remarkRehype).use(rehypeSlug).use(collectHeadings).use(rehypeStringify).process(markdown);
|
|
428
|
+
yield remark().use(remarkParse).use(remarkGfm).use(remarkRehype).use(rehypeSlug).use(collectHeadings).use(rehypeStringify).process(stripInlineTagsFromHeadings(markdown));
|
|
419
429
|
return headings;
|
|
420
430
|
});
|
|
421
431
|
}
|
|
@@ -647,7 +657,7 @@ function getArticleSummary(slug, config) {
|
|
|
647
657
|
author,
|
|
648
658
|
authors,
|
|
649
659
|
authorSlug: primaryAuthorProfile == null ? void 0 : primaryAuthorProfile.slug,
|
|
650
|
-
authorAvatar: primaryAuthorProfile ? getAuthorAvatar(primaryAuthorProfile
|
|
660
|
+
authorAvatar: primaryAuthorProfile ? getAuthorAvatar(primaryAuthorProfile) : void 0,
|
|
651
661
|
category: categories[0],
|
|
652
662
|
categories,
|
|
653
663
|
readTime,
|