starlight-obsidian 0.4.4 → 0.4.5
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/libs/remark.ts +16 -4
- package/package.json +1 -1
package/libs/remark.ts
CHANGED
|
@@ -75,10 +75,7 @@ export function remarkStarlightObsidian() {
|
|
|
75
75
|
}
|
|
76
76
|
})
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
handleFrontmatter(tree, file, obsidianFrontmatter)
|
|
80
|
-
}
|
|
81
|
-
|
|
78
|
+
handleFrontmatter(tree, file, obsidianFrontmatter)
|
|
82
79
|
handleImports(tree, file)
|
|
83
80
|
}
|
|
84
81
|
}
|
|
@@ -101,6 +98,21 @@ function getObsidianFrontmatter(tree: Root) {
|
|
|
101
98
|
}
|
|
102
99
|
|
|
103
100
|
function handleFrontmatter(tree: Root, file: VFile, obsidianFrontmatter?: ObsidianFrontmatter) {
|
|
101
|
+
// Remove the existing frontmatter, if any, for embedded notes.
|
|
102
|
+
if (file.data.embedded) {
|
|
103
|
+
// The frontmatter is always at the root of the tree.
|
|
104
|
+
for (const [index, node] of tree.children.entries()) {
|
|
105
|
+
if (node.type !== 'yaml') {
|
|
106
|
+
continue
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
tree.children.splice(index, 1)
|
|
110
|
+
break
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
|
|
104
116
|
let hasFrontmatter = false
|
|
105
117
|
|
|
106
118
|
// The frontmatter is always at the root of the tree.
|