platers / obsidian-linter

An Obsidian plugin that formats and styles your notes with a focus on configurability and extensibility.
https://platers.github.io/obsidian-linter/
MIT License
1.24k stars 82 forks source link

FR: Copy title to aliases #1005

Open chmac opened 9 months ago

chmac commented 9 months ago

Is Your Feature Request Related to a Problem? Please Describe.

I use the title YAML field to publish notes. But in Obsidian, only aliases are searchable. So I need to manually copy title into aliases (as I don't have a leading h1 which has my title).

Describe the Solution You'd Like

It would be great to have an option for the "YAML Title Alias" section which sources the title from the title frontmatter key.

Please include an example where applicable:

Example filename: foo.md

---
title: Bar
---
---
title: Bar
aliases:
  - Bar
---

Describe Alternatives You've Considered

I'm not aware of any alternative strategy to achieve this, but I'd be happy to hear suggestions if there is a viable workaround. :-)

Additional Context

Thanks for Linter. Took me a while to figure out what this plugin could do as I assumed it was mostly linting, but it's incredibly powerful, and super useful coming from dendron into obsidian. 🧡

hkcomori commented 5 months ago

I want this feature very much too.

If we only write H1, it will work fine. Then, "YAML Title" creates title frontmatter key and "YAML Title Alias" adds same value to aliases frontmatter key.

But this alternative cannot be used if H1 gets in the way in the post-process.

pjkaufman commented 5 months ago

Hey @chmac , @hkcomori , YAML Title currently has a mode that determines how it functions (see https://platers.github.io/obsidian-linter/settings/yaml-rules/#yaml-title). Would it make sense to just add a mode to YAML Title Alias to allow for this functionality where you can specify that you want the title alias to come from either the H1, the filename, or how it currently works? That seems the simplest change to me which would make it easier to maintain (hopefully) and get this added faster.

What do y'all think?

hkcomori commented 5 months ago

@pjkaufman Yes, it would be great if the option could be one of Title key, First H1, Filename, Title key or First H1 if Title key is missing or Filename if H1 is missing for YAML Title Alias. The Title Key means the value specified in YAML Title. I think variable would match more use cases than the fixed key name title.