Skip to content

feat: import zip folder hierarchy #1309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
folder-hierarchy-import: init
  • Loading branch information
fuscodev committed Jun 28, 2025
commit 57623461dce081fb6382219168c4e99fd1b955cc
37 changes: 31 additions & 6 deletions apps/server/src/integrations/import/services/file-task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,25 @@ export class FileTaskService {
const segments = filePath.split('/');
segments.pop();
let parentPage = null;
while (segments.length) {
if(segments.length > 0) {
const tryMd = segments.join('/') + '.md';
const tryHtml = segments.join('/') + '.html';
if (pagesMap.has(tryMd)) {
parentPage = pagesMap.get(tryMd)!;
break;
}
if (pagesMap.has(tryHtml)) {
} else if (pagesMap.has(tryHtml)) {
parentPage = pagesMap.get(tryHtml)!;
break;
} else {
pagesMap.set(tryMd, {
id: v7(),
slugId: generateSlugId(),
name: segments[segments.length - 1],
content: null,
parentPageId: null,
fileExtension: null,
filePath: null,
});
parentPage = pagesMap.get(tryMd)!;
}
segments.pop();
}
if (parentPage) page.parentPageId = parentPage.id;
});
Expand Down Expand Up @@ -256,6 +263,24 @@ export class FileTaskService {

const pageResults = await Promise.all(
Array.from(pagesMap.values()).map(async (page) => {
if( page.filePath === null ) {
const insertablePage: InsertablePage = {
id: page.id,
slugId: page.slugId,
title: page.name,
content: null,
textContent: null,
ydoc: null,
position: page.position!,
spaceId: fileTask.spaceId,
workspaceId: fileTask.workspaceId,
creatorId: fileTask.creatorId,
lastUpdatedById: fileTask.creatorId,
parentPageId: page.parentPageId,
};
return { insertablePage, backlinks: [] };
}

const htmlContent =
await this.importAttachmentService.processAttachments({
html: page.content,
Expand Down