generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: adding noticeMessage for workflow
- Loading branch information
Showing
1 changed file
with
30 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } |