Skip to content

Commit 7ff2931

Browse files
committed
began frontmatter detection integration
1 parent a2782f9 commit 7ff2931

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

@types/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ export interface Monster {
6666
columnWidth?: number;
6767
columnHeight?: number;
6868
forceColumns?: boolean;
69+
70+
note?: string;
71+
6972
[property: string]: any;
7073
}
7174

src/main.ts

+24-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {
22
addIcon,
33
MarkdownPostProcessorContext,
44
Notice,
5-
Plugin
5+
Plugin,
6+
TFile
67
} from "obsidian";
78
import domtoimage from "dom-to-image";
89

@@ -350,10 +351,31 @@ export default class StatBlockPlugin extends Plugin {
350351
"name"
351352
);
352353

354+
let additionalParams = {};
355+
if (params.note) {
356+
const note = Array.isArray(params.note)
357+
? (<string[]>params.note).flat(Infinity).pop()
358+
: params.note;
359+
const file = await this.app.metadataCache.getFirstLinkpathDest(
360+
`${note}`,
361+
ctx.sourcePath
362+
);
363+
if (file && file instanceof TFile) {
364+
const cache = await this.app.metadataCache.getFileCache(
365+
file
366+
);
367+
additionalParams = cache.frontmatter ?? {};
368+
}
369+
}
370+
console.log(
371+
"🚀 ~ file: main.ts ~ line 368 ~ additionalParams",
372+
additionalParams
373+
);
353374
const monster: Monster = Object.assign(
354375
{},
355376
this.bestiary.get(params.monster) ??
356-
this.bestiary.get(params.creature)
377+
this.bestiary.get(params.creature),
378+
additionalParams
357379
);
358380
let traits, actions, legendary_actions, reactions;
359381
if (monster) {

0 commit comments

Comments
 (0)