Skip to content

Commit

Permalink
use disclosure to handler each files
Browse files Browse the repository at this point in the history
  • Loading branch information
sunwei committed Nov 26, 2024
1 parent 9b6beef commit d14a7a9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "mdfriday",
"name": "Friday",
"version": "0.1.5",
"version": "0.1.6",
"minAppVersion": "0.15.0",
"description": "Notes to Website. Friday helps you turn Markdown documents into websites in minutes.",
"author": "sunwei",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-friday-plugin",
"version": "0.1.5",
"version": "0.1.6",
"description": "Friday is an Obsidian plugin that empowers users to focus on content creation by writing Markdown files, while we handle the distribution. From creating websites to content deployment, Friday serves as a creative output assistant, helping users turn their work into publishable sites with ease.",
"main": "main.js",
"scripts": {
Expand Down
60 changes: 31 additions & 29 deletions src/hugoverse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,36 +142,38 @@ export class Hugoverse {
// 遍历文件夹中的所有 Markdown 文件并处理
const filePromises = [];
Vault.recurseChildren(folder, (file) => {
if (file instanceof TFile) {
if (file.extension === "md") {
const fileProcessing = (async () => {
const postId = await this.createPost(file);
if (postId === "") return;

const sitePostId = await this.createSitePost(siteId, postId, file);
if (sitePostId === "") return;

// 处理完每个文件后,更新进度
processedFiles++;
const progress = 45 + 50 * (processedFiles / totalFiles); // 根据文件数量调整进度
callback(progress);
})();
filePromises.push(fileProcessing);
} else if (supportedImageExtensions.includes(file.extension)) {
const imageProcessing = (async () => {
const resourceId = await this.createResource(file);
if (resourceId === "") return;

const sitePostId = await this.createSiteResource(siteId, resourceId, file);
if (sitePostId === "") return;

processedFiles++;
const progress = 45 + 50 * (processedFiles / totalFiles); // 根据文件数量调整进度
callback(progress);
})();
filePromises.push(imageProcessing);
`` (async (currentFile) => {

Check failure on line 145 in src/hugoverse.ts

View workflow job for this annotation

GitHub Actions / build

This expression is not callable.
if (currentFile instanceof TFile) {
if (currentFile.extension === "md") {
const fileProcessing = (async () => {
const postId = await this.createPost(currentFile);
if (postId === "") return;

const sitePostId = await this.createSitePost(siteId, postId, currentFile);
if (sitePostId === "") return;

// 处理完每个文件后,更新进度
processedFiles++;
const progress = 45 + 50 * (processedFiles / totalFiles); // 根据文件数量调整进度
callback(progress);
})();
filePromises.push(fileProcessing);
} else if (supportedImageExtensions.includes(currentFile.extension)) {
const imageProcessing = (async () => {
const resourceId = await this.createResource(currentFile);
if (resourceId === "") return;

const sitePostId = await this.createSiteResource(siteId, resourceId, currentFile);
if (sitePostId === "") return;

processedFiles++;
const progress = 45 + 50 * (processedFiles / totalFiles); // 根据文件数量调整进度
callback(progress);
})();
filePromises.push(imageProcessing);
}
}
}
})(file);
});

// 等待所有文件的处理完成
Expand Down
5 changes: 3 additions & 2 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"0.1.5": "0.15.0"
}
"0.1.5": "0.15.0",
"0.1.6": "0.15.0"
}

0 comments on commit d14a7a9

Please sign in to comment.