Skip to content

Commit

Permalink
fix: Only load CSS that exists for obsidian styles
Browse files Browse the repository at this point in the history
  • Loading branch information
andymac4182 committed May 10, 2023
1 parent 1c74a50 commit c825559
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/obsidian/src/main.ts
Expand Up @@ -113,20 +113,30 @@ export default class ConfluencePlugin extends Plugin {
// @ts-expect-error
const cssTheme = this.app.vault?.getConfig("cssTheme") as string;
if (cssTheme) {
const themeCss = await this.app.vault.adapter.read(
const fileExists = await this.app.vault.adapter.exists(
`.obsidian/themes/${cssTheme}/theme.css`
);
extraStyles.push(themeCss);
if (fileExists) {
const themeCss = await this.app.vault.adapter.read(
`.obsidian/themes/${cssTheme}/theme.css`
);
extraStyles.push(themeCss);
}
}

const cssSnippets =
// @ts-expect-error
(this.app.vault?.getConfig("enabledCssSnippets") as string[]) ?? [];
for (const snippet of cssSnippets) {
const themeCss = await this.app.vault.adapter.read(
const fileExists = await this.app.vault.adapter.exists(
`.obsidian/snippets/${snippet}.css`
);
extraStyles.push(themeCss);
if (fileExists) {
const themeCss = await this.app.vault.adapter.read(
`.obsidian/snippets/${snippet}.css`
);
extraStyles.push(themeCss);
}
}

return {
Expand Down

0 comments on commit c825559

Please sign in to comment.