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.
Files changed (2) hide show
  1. package/libs/remark.ts +16 -4
  2. package/package.json +1 -1
package/libs/remark.ts CHANGED
@@ -75,10 +75,7 @@ export function remarkStarlightObsidian() {
75
75
  }
76
76
  })
77
77
 
78
- if (!file.data.embedded) {
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-obsidian",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "license": "MIT",
5
5
  "description": "Starlight plugin to publish Obsidian vaults.",
6
6
  "author": "HiDeoo <github@hideoo.dev> (https://hideoo.dev)",