mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-26 23:49:51 +00:00
Fix empty extracted paragraphs in remark-structure
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'next-docs-zeta': patch
|
||||
---
|
||||
|
||||
Fix empty extracted paragraphs in `remark-structure`
|
||||
@@ -116,7 +116,7 @@ const CommandItem = React.forwardRef<
|
||||
<CommandPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'nd-cursor-pointer nd-select-none nd-rounded-lg nd-text-sm aria-selected:nd-bg-accent data-[disabled]:nd-pointer-events-none data-[disabled]:nd-opacity-50 [&_svg]:nd-h-4 [&_svg]:nd-w-4',
|
||||
'nd-select-none nd-rounded-lg nd-text-sm aria-selected:nd-bg-accent aria-selected:nd-text-accent-foreground data-[disabled]:nd-pointer-events-none data-[disabled]:nd-opacity-50 [&_svg]:nd-h-4 [&_svg]:nd-w-4',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -27,9 +27,7 @@ export type StructuredData = {
|
||||
|
||||
type Options = {
|
||||
/**
|
||||
* Types to be scanned
|
||||
*
|
||||
* @default ["heading", "blockquote", "paragraph"]
|
||||
* Types to be scanned, default: `["heading", "blockquote", "paragraph"]`
|
||||
*/
|
||||
types?: string[]
|
||||
}
|
||||
@@ -48,23 +46,25 @@ export function remarkStructure({
|
||||
let lastHeading: string | undefined = ''
|
||||
|
||||
visit(node, types, (element: MdastContent) => {
|
||||
const content = flattenNode(element).trim()
|
||||
if (element.type === 'heading') {
|
||||
const heading = flattenNode(element)
|
||||
const slug = slugger.slug(heading)
|
||||
const slug = slugger.slug(content)
|
||||
|
||||
data.headings.push({
|
||||
id: slug,
|
||||
content: heading
|
||||
content
|
||||
})
|
||||
|
||||
lastHeading = slug
|
||||
return 'skip'
|
||||
}
|
||||
|
||||
data.contents.push({
|
||||
heading: lastHeading,
|
||||
content: flattenNode(element)
|
||||
})
|
||||
if (content.length > 0) {
|
||||
data.contents.push({
|
||||
heading: lastHeading,
|
||||
content
|
||||
})
|
||||
}
|
||||
|
||||
return 'skip'
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user