Skip to content

Commit

Permalink
Merge pull request #56 from A-F-V/51-darwin-gpt35
Browse files Browse the repository at this point in the history
Darwin Improvments
  • Loading branch information
A-F-V authored Jul 5, 2023
2 parents 6954fcc + dd9bd53 commit 65d8ce8
Show file tree
Hide file tree
Showing 3 changed files with 263 additions and 110 deletions.
33 changes: 3 additions & 30 deletions src/include/FrontMatterManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,7 @@ export default class FrontMatterManager {
constructor(arcana: ArcanaPlugin) {
this.arcana = arcana;
}
// TODO: give type: (Map=>void)
async processFrontMatter(file: TFile, transformation: any): Promise<void> {
await this.arcana.app.fileManager.processFrontMatter(file, frontMatter => {
// Get the current front matter, defaulting to empty if it doesn't exist
let arcanaFrontMatter = new Map();
if (frontMatter.arcana !== undefined) {
arcanaFrontMatter = new Map(Object.entries(frontMatter.arcana));
}
// Apply the transformation
transformation(arcanaFrontMatter);
// Save the result
frontMatter.arcana = Object.fromEntries(arcanaFrontMatter.entries());
});
}
/*
async getArcana(file: TFile, key: string): Promise<any | null> {
let result = null;
await this.processFrontMatter(file, (arcanaData: any) => {
result = arcanaData.get(key);
});
return result;
}

async setArcana(file: TFile, key: string, value: any): Promise<void> {
await this.processFrontMatter(file, (arcanaData: any) => {
arcanaData.set(key, value);
});
}
*/
async set(file: TFile, key: string, value: any): Promise<void> {
await this.arcana.app.fileManager.processFrontMatter(file, frontMatter => {
frontMatter[key] = value;
Expand All @@ -59,8 +31,9 @@ export default class FrontMatterManager {

await this.arcana.app.fileManager
.processFrontMatter(file, frontmatter => {
console.log(frontmatter);
//tags = parseFrontMatterTags(frontmatter);
tags =
parseFrontMatterTags(frontmatter)?.map(tag => tag.replace('#', '')) ??
null;
})
.catch(e => {});

Expand Down
Loading

0 comments on commit 65d8ce8

Please sign in to comment.