diff --git a/adapter/sqlite/note_dao.go b/adapter/sqlite/note_dao.go index 4e2d866..acb83f6 100644 --- a/adapter/sqlite/note_dao.go +++ b/adapter/sqlite/note_dao.go @@ -407,6 +407,11 @@ func (d *NoteDAO) expandMentionsIntoMatch(opts note.FinderOpts) (note.FinderOpts defer rows.Close() titles := []string{} + + appendTitle := func(t string) { + titles = append(titles, `"`+strings.ReplaceAll(t, `"`, "")+`"`) + } + for rows.Next() { var title, metadataJSON string err := rows.Scan(&title, &metadataJSON) @@ -414,7 +419,7 @@ func (d *NoteDAO) expandMentionsIntoMatch(opts note.FinderOpts) (note.FinderOpts return opts, err } - titles = append(titles, `"`+title+`"`) + appendTitle(title) // Support `aliases` key in the YAML frontmatter, like Obsidian: // https://publish.obsidian.md/help/How+to/Add+aliases+to+note @@ -426,10 +431,10 @@ func (d *NoteDAO) expandMentionsIntoMatch(opts note.FinderOpts) (note.FinderOpts switch aliases := aliases.(type) { case []interface{}: for _, alias := range aliases { - titles = append(titles, `"`+fmt.Sprint(alias)+`"`) + appendTitle(fmt.Sprint(alias)) } case string: - titles = append(titles, `"`+aliases+`"`) + appendTitle(aliases) } } } diff --git a/docs/note-frontmatter.md b/docs/note-frontmatter.md index 5e295f0..2d5abcd 100644 --- a/docs/note-frontmatter.md +++ b/docs/note-frontmatter.md @@ -18,5 +18,6 @@ keywords: [writing, essay, practice] | `date` | Creation date – takes precedence over the file date | | `tags` | List of tags attached to this note | | `keywords` | Alias for `tags` | +| `aliases` | Alternative titles for this note, used by `--mention` | All metadata are indexed and can be printed in `zk list` output, using the template variable `{{metadata.}}`, e.g. `{{metadata.description}}`. The keys are normalized to lower case.