dendrite.nvim/persistence/store/vault_store.go
Kristian 0eeb588983
ref(cfg): extend init command with additional props (#42)
* feat(v_config): changed vault configuration

* ref(cfg): extend init cmd with config props
2026-05-27 21:01:58 +02:00

60 lines
1.3 KiB
Go

package store
import (
"path"
persistenceconfig "github.com/KristianJBorgwarth/dendrite.daemon/persistence/config"
)
type VaultStore struct {
Config *persistenceconfig.VaultConfig
}
var vaultStore *VaultStore
func NewVaultStore(
vaultName,
vaultPath,
templateDir string,
exludeIndexFiles []string,
overrideDefaultIgnores bool,
dailyDir string,
dailyFilenameFormat string,
dailyTemplateName string,
) *VaultStore {
if vaultStore != nil {
return vaultStore
}
vaultStore = &VaultStore{Config: persistenceconfig.NewVaultConfiguration(
vaultName,
vaultPath,
templateDir,
exludeIndexFiles,
overrideDefaultIgnores,
persistenceconfig.NewDailyNotes(dailyDir, dailyFilenameFormat, dailyTemplateName))}
return vaultStore
}
func GetVaultStore() *VaultStore {
if vaultStore == nil {
panic("VaultStore not initialized. Call NewVaultStore first.")
}
return vaultStore
}
func (vs *VaultStore) GetTemplatePath(templateName string) string {
templateName = vs.fileTypeCheck(templateName)
return path.Join(vs.Config.TemplateDirectory(), templateName)
}
func (vs *VaultStore) fileTypeCheck(templateName string) string {
fileType := path.Ext(templateName)
if fileType != ".md" {
return templateName + ".md"
}
return templateName
}
func (vs *VaultStore) GetExcludeIndexFiles() []string {
return vs.Config.ExcludeIndexFiles()
}