Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Config struct {
Light string `yaml:"light"`
Dark string `yaml:"dark"`
} `yaml:"theme"`
CreateEmpty bool `yaml:"create_empty"`
}

type Dimensions struct {
Expand Down Expand Up @@ -102,6 +103,7 @@ func DefaultConfig() *Config {
Light: "default",
Dark: "default",
},
CreateEmpty: false,
}
}

Expand Down
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,13 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

timestamp := time.Now().Format("2006-01-02-150405")
filename := filepath.Join(currentDir, fmt.Sprintf("note-%s.md", timestamp))
content := ""

content := fmt.Sprintf("# New Note\n\nCreated: %s\n",
time.Now().Format("2006-01-02 15:04:05"))
// If CreateEmpty is falsey, create a default content
if !m.config.CreateEmpty {
content = fmt.Sprintf("# New Note\n\nCreated: %s\n",
time.Now().Format("2006-01-02 15:04:05"))
}

if err := os.WriteFile(filename, []byte(content), 0644); err == nil {
m.updateNotes()
Expand Down