diff --git a/mkdocsPublisher/utils/utils.ts b/mkdocsPublisher/utils/utils.ts index 290f5d08..08aa2e45 100644 --- a/mkdocsPublisher/utils/utils.ts +++ b/mkdocsPublisher/utils/utils.ts @@ -1,24 +1,38 @@ import { - App, - TFile + App, + TFile, + Notice } from 'obsidian' import { MkdocsPublicationSettings } from '../settings' +import MkdocsPublish from "./publication"; function disablePublish (app: App, settings: MkdocsPublicationSettings, file:TFile) { - const fileCache = app.metadataCache.getFileCache(file) - const meta = fileCache?.frontmatter - const folderList = settings.ExcludedFolder.split(',').filter(x => x!=='') - if (meta === undefined) { - return false - } else if (folderList.length > 0) { - for (let i = 0; i < folderList.length; i++) { - if (file.path.contains(folderList[i].trim())) { - return false - } - } - } - return meta[settings.shareKey] + const fileCache = app.metadataCache.getFileCache(file) + const meta = fileCache?.frontmatter + const folderList = settings.ExcludedFolder.split(',').filter(x => x!=='') + if (meta === undefined) { + return false + } else if (folderList.length > 0) { + for (let i = 0; i < folderList.length; i++) { + if (file.path.contains(folderList[i].trim())) { + return false + } + } + } + return meta[settings.shareKey] } -export {disablePublish } +async function noticeMessage(publish: MkdocsPublish, file: TFile | string, settings: MkdocsPublicationSettings) { + const noticeValue = (file instanceof TFile) ? '"' + file.basename + '"' : file + const msg = settings.workflowName.length>0? '.\nNow, waiting for the workflow to be completed...':'.' + new Notice('Send ' + noticeValue + ' to ' + settings.githubRepo + msg); + const successWorkflow = await publish.workflowGestion(); + if (successWorkflow) { + new Notice( + "Successfully published " + noticeValue + " to " + settings.githubRepo + "." + ); + } +} + +export {disablePublish, noticeMessage }