🎨 Improve importing Markdown https://github.com/siyuan-note/siyuan/issues/13149
This commit is contained in:
parent
e164e88dc4
commit
9681fe6d80
1 changed files with 12 additions and 1 deletions
|
@ -752,7 +752,12 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
|
|||
|
||||
targetPath = strings.ReplaceAll(targetPath, ".sy/", "/")
|
||||
targetPath += ".sy"
|
||||
targetPaths[curRelPath] = targetPath
|
||||
if _, ok := targetPaths[curRelPath]; !ok {
|
||||
targetPaths[curRelPath] = targetPath
|
||||
} else {
|
||||
targetPath = targetPaths[curRelPath]
|
||||
id = strings.TrimSuffix(path.Base(targetPath), ".sy")
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
if subMdFiles := util.GetFilePathsByExts(currentPath, []string{".md", ".markdown"}); 1 > len(subMdFiles) {
|
||||
|
@ -760,6 +765,12 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
|
|||
return nil
|
||||
}
|
||||
|
||||
// 如果当前文件夹路径下包含同名的 Markdown 文件,则不创建空文档 https://github.com/siyuan-note/siyuan/issues/13149
|
||||
if gulu.File.IsExist(currentPath+".md") || gulu.File.IsExist(currentPath+".markdown") {
|
||||
targetPaths[curRelPath+".md"] = targetPath
|
||||
return nil
|
||||
}
|
||||
|
||||
tree = treenode.NewTree(boxID, targetPath, hPath, title)
|
||||
importTrees = append(importTrees, tree)
|
||||
return nil
|
||||
|
|
Loading…
Add table
Reference in a new issue