diff --git a/README.md b/README.md index 6bba268..c394cba 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ This action will trigger a modal window, where you have the option to paste your ![chess-study-modal](imgs/chess-study-modal.png) -Once you click `Submit`, Obsidian will parse the PGN, generate a new JSON file in your vault located at `.obsidian/plugins/obsidian-chess-study/storage/{id}.json`, and insert a chessStudy codeblock at the cursor's position. Here's an example of the chessStudy codeblock: +Once you click `Submit`, Obsidian Chess Study will parse the PGN, generate a new JSON file in your vault located at `.obsidian/plugins/obsidian-chess-study/storage/{id}.json`, and insert a chessStudy codeblock at the cursor's position. Here's an example of the chessStudy codeblock: ![chess-study-codeblock](imgs/chess-study-codeblock.png) @@ -91,4 +91,4 @@ If you want to have a look at FENs instead, check out these alternative Obsidian ## License -[Obsidian Chess Study](https://github.com/chrislicodes/obsidian-chess-study) is licensed under the GPL-3.0 license. Refer to [LICENSE](https://github.com/chrislicodes/obsidian-chess-study/blob/trunk/LICENSE.TXT) for more informations. +[Obsidian Chess Study](https://github.com/chrislicodes/obsidian-chess-study) is licensed under the GPL-3.0 license. Refer to [LICENSE](https://github.com/chrislicodes/obsidian-chess-study/blob/trunk/LICENSE) for more informations. diff --git a/src/utils/index.ts b/src/utils/index.ts index 0872bef..320375b 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -4,7 +4,7 @@ import { Api } from 'chessground/api'; import { Config } from 'chessground/config'; import { DrawShape } from 'chessground/draw'; import { nanoid } from 'nanoid'; -import { DataAdapter, parseYaml } from 'obsidian'; +import { DataAdapter, normalizePath, parseYaml } from 'obsidian'; import { ChessStudyPluginSettings } from 'src/components/obsidian/SettingsTab'; //Chess Logic @@ -99,7 +99,7 @@ export class ChessStudyDataAdapter { async saveFile(data: ChessStudyFileData, id?: string) { const chessStudyId = id || nanoid(); await this.adapter.write( - `${this.storagePath}/${chessStudyId}.json`, + normalizePath(`${this.storagePath}/${chessStudyId}.json`), JSON.stringify(data, null, 2), {} ); @@ -108,7 +108,9 @@ export class ChessStudyDataAdapter { } async loadFile(id: string): Promise { - const data = await this.adapter.read(`${this.storagePath}/${id}.json`); + const data = await this.adapter.read( + normalizePath(`${this.storagePath}/${id}.json`) + ); return JSON.parse(data); }