add .md suffix implicit for files
This commit is contained in:
@@ -42,7 +42,11 @@ type FsNode struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (n *FsNode) FileName() string {
|
func (n *FsNode) FileName() string {
|
||||||
return filepath.Base(n.path)
|
name := filepath.Base(n.path)
|
||||||
|
if n.nodeType == FileNode {
|
||||||
|
return strings.TrimSuffix(name, ".md")
|
||||||
|
}
|
||||||
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== messages ===================
|
// ================== messages ===================
|
||||||
@@ -425,6 +429,10 @@ func (t *FsTree) CreateNode(folder *FsNode, name string, nodeType FsNodeType) er
|
|||||||
return errors.New("node name cannot be empty")
|
return errors.New("node name cannot be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if nodeType == FileNode && !strings.HasSuffix(name, ".md") {
|
||||||
|
name += ".md"
|
||||||
|
}
|
||||||
|
|
||||||
path := filepath.Join(folder.path, name)
|
path := filepath.Join(folder.path, name)
|
||||||
// materialise it first
|
// materialise it first
|
||||||
switch nodeType {
|
switch nodeType {
|
||||||
|
|||||||
Reference in New Issue
Block a user