feat: add support for templater when using default front matter
This commit is contained in:
parent
65540b5169
commit
0c9d7c54c2
1 changed files with 8 additions and 1 deletions
|
|
@ -329,7 +329,14 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
({ fileMetadata, fileContent } = await this.attachFile(fileMetadata, fileContent, options.attachFile));
|
({ fileMetadata, fileContent } = await this.attachFile(fileMetadata, fileContent, options.attachFile));
|
||||||
({ fileMetadata, fileContent } = await this.attachTemplate(fileMetadata, fileContent, template));
|
({ fileMetadata, fileContent } = await this.attachTemplate(fileMetadata, fileContent, template));
|
||||||
|
|
||||||
|
if (this.settings.enableTemplaterIntegration && hasTemplaterPlugin(this.app)) {
|
||||||
|
// Only support stringifyYaml for templater plugin
|
||||||
|
// Include the media variable in all templater commands by using a top level JavaScript execution command.
|
||||||
|
fileContent = `---\n<%* const media = ${JSON.stringify(mediaTypeModel)} %>\n${stringifyYaml(fileMetadata)}---\n${fileContent}`;
|
||||||
|
} else {
|
||||||
fileContent = `---\n${this.settings.useCustomYamlStringifier ? YAMLConverter.toYaml(fileMetadata) : stringifyYaml(fileMetadata)}---\n` + fileContent;
|
fileContent = `---\n${this.settings.useCustomYamlStringifier ? YAMLConverter.toYaml(fileMetadata) : stringifyYaml(fileMetadata)}---\n` + fileContent;
|
||||||
|
}
|
||||||
|
|
||||||
return fileContent;
|
return fileContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue