diff --git a/mkdocsPublisher/githubInteraction/getFiles.ts b/mkdocsPublisher/githubInteraction/getFiles.ts index 3075169d..91c3d6ee 100644 --- a/mkdocsPublisher/githubInteraction/getFiles.ts +++ b/mkdocsPublisher/githubInteraction/getFiles.ts @@ -65,7 +65,7 @@ export class GetFiles { file.path ).frontmatter; if (frontMatter && frontMatter[shareKey] === true) { - const filepath = getReceiptFolder(file, this.settings) + const filepath = getReceiptFolder(file, this.settings, this.metadataCache); allFileWithPath.push(filepath); } } diff --git a/mkdocsPublisher/githubInteraction/upload.ts b/mkdocsPublisher/githubInteraction/upload.ts index 3d026d0e..49d896ae 100644 --- a/mkdocsPublisher/githubInteraction/upload.ts +++ b/mkdocsPublisher/githubInteraction/upload.ts @@ -37,7 +37,7 @@ export default class MkdocsPublish { async publish(file: TFile, one_file = false, ref = "main") { const shareFiles = new GetFiles(this.vault, this.metadataCache, this.settings, this.octokit); const sharedKey = this.settings.shareKey; - const frontmatter = this.metadataCache.getCache(file.path).frontmatter; + const frontmatter = this.metadataCache.getFileCache(file).frontmatter; if ( !frontmatter || !frontmatter[sharedKey] || @@ -50,9 +50,9 @@ export default class MkdocsPublish { let text = await this.vault.cachedRead(file); const linkedImage = shareFiles.getLinkedImage(file); const linkedFiles = shareFiles.getLinkedFiles(file); - text = convertLinkCitation(text, this.settings, linkedFiles) + text = convertLinkCitation(text, this.settings, linkedFiles, this.metadataCache) text = convertWikilinks(text, this.settings, linkedFiles); - const path = getReceiptFolder(file, this.settings) + const path = getReceiptFolder(file, this.settings, this.metadataCache) await this.uploadText(file.path, text, path, file.name, ref); if (linkedImage.length > 0 && this.settings.transferEmbedded) { for (const image of linkedImage) { diff --git a/mkdocsPublisher/utils/utils.ts b/mkdocsPublisher/utils/utils.ts index ba02d6e1..81dfdd85 100644 --- a/mkdocsPublisher/utils/utils.ts +++ b/mkdocsPublisher/utils/utils.ts @@ -1,4 +1,4 @@ -import {App, Notice, TFile} from 'obsidian' +import {App, Notice, TFile, MetadataCache} from 'obsidian' import {MkdocsPublicationSettings} from '../settings/interface' import MkdocsPublish from "../githubInteraction/upload"; @@ -61,12 +61,12 @@ function convertWikilinks(fileContent: string, settings: MkdocsPublicationSettin return fileContent; } -function getReceiptFolder(file: TFile, settings:MkdocsPublicationSettings) { +function getReceiptFolder(file: TFile, settings:MkdocsPublicationSettings, metadataCache: MetadataCache) { const folderDefault = settings.folderDefaultName; let path = settings.folderDefaultName.length > 0 ? settings.folderDefaultName + "/" + file.name : file.name; if (settings.downloadedFolder === "yamlFrontmatter") { - const frontmatter = this.metadataCache.getCache(file.path).frontmatter + const frontmatter = metadataCache.getCache(file.path).frontmatter let folderRoot = settings.rootFolder; if (folderRoot.length > 0) { folderRoot = folderRoot + "/"; @@ -85,12 +85,12 @@ function getReceiptFolder(file: TFile, settings:MkdocsPublicationSettings) { return path } -function convertLinkCitation(fileContent: string, settings: MkdocsPublicationSettings, linkedFiles : {linked: TFile, linkFrom: string, altText: string}[]) { +function convertLinkCitation(fileContent: string, settings: MkdocsPublicationSettings, linkedFiles : {linked: TFile, linkFrom: string, altText: string}[], metadataCache: MetadataCache) { if (!settings.convertForGithub) { return fileContent; } for (const linkedFile of linkedFiles) { - const pathInGithub = getReceiptFolder(linkedFile.linked, settings) + const pathInGithub = getReceiptFolder(linkedFile.linked, settings, metadataCache ) fileContent = fileContent.replace(linkedFile.linkFrom, pathInGithub) } return fileContent;