starlight-obsidian 0.4.3 → 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/obsidian.ts CHANGED
@@ -46,11 +46,13 @@ export async function getVault(config: StarlightObsidianConfig): Promise<Vault>
46
46
  const vaultPath = path.resolve(config.vault)
47
47
 
48
48
  if (!(await isDirectory(vaultPath))) {
49
- throwUserError('The provided vault path is not a directory.')
49
+ throwUserError(`The provided vault path is not a directory.\n> Provided path: ${vaultPath}`)
50
50
  }
51
51
 
52
52
  if (!(await isVaultDirectory(config, vaultPath))) {
53
- throwUserError('The provided vault path is not a valid Obsidian vault directory.')
53
+ throwUserError(
54
+ `The provided vault path is not a valid Obsidian vault directory and does not include an '.obsidian/app.json' file.\n> Provided path: ${vaultPath}`,
55
+ )
54
56
  }
55
57
 
56
58
  const options = await getVaultOptions(config, vaultPath)
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.3",
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)",