Skip to content

Commit

Permalink
feat: Updated src/jekyll/chirpy.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Oct 1, 2023
1 parent 9158da3 commit c70afc1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/jekyll/chirpy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,17 @@ async function validateSettings(plugin: O2Plugin) {
}
}

function getFilesInReady(plugin: O2Plugin): TFile[] {
function getFilesToPublish(plugin: O2Plugin): TFile[] {
const frontMatterConverter = new FrontMatterConverter();
return plugin.app.vault.getMarkdownFiles()
.filter((file: TFile) => file.path.startsWith(plugin.settings.readyFolder));
.filter((file: TFile) => {
const frontMatter = frontMatterConverter.getFrontMatter(file);
return frontMatter.publish === true;
});
}

async function backupOriginalNotes(plugin: O2Plugin) {
const readyFiles = getFilesInReady.call(this, plugin);
const readyFiles = getFilesToPublish.call(this, plugin);
const backupFolder = plugin.settings.backupFolder;
const readyFolder = plugin.settings.readyFolder;
readyFiles.forEach((file: TFile) => {
Expand All @@ -115,7 +119,7 @@ async function backupOriginalNotes(plugin: O2Plugin) {
// FIXME: SRP, renameMarkdownFile(file: TFile): string
async function renameMarkdownFile(plugin: O2Plugin): Promise<TFile[]> {
const dateString = Temporal.Now.plainDateISO().toString();
const markdownFiles = getFilesInReady.call(this, plugin);
const markdownFiles = getFilesToPublish.call(this, plugin);
for (const file of markdownFiles) {
const newFileName = dateString + '-' + file.name;
const newFilePath = file.path
Expand Down

0 comments on commit c70afc1

Please sign in to comment.