FlorianWoelki / obsidian-iconize

Simply add icons to anything you want in Obsidian.
https://florianwoelki.github.io/obsidian-iconize/
MIT License
777 stars 53 forks source link

Custom Icon Rule based on a custom Frontmatter Field /w regex #321

Open juicybox opened 7 months ago

juicybox commented 7 months ago

Is your feature request related to a problem? Please describe.

It is great to have the ability to use the icon Property on a file-based setting, but..

UseCase 1: Ability to configure an own Property for filebased Icons

But I might see some issue or side effects within an existing vault and notes:

  1. If you're already using the icon-Property for other purposes or own UseCases.
    1. Like using the icon Property for your own purpose.
    2. The property is already claimed by a plugin like "metadatamenu"
    3. Or I would like to use a different property for that UseCase, like image or iconImage, etc..

Take a look at other plugins like obsidian-banners Plugin, where you can set up a custom Property or a prefix for the banner Icon.

Screenshot - 2023-12-06 22 26 26

Related:

  1. https://github.com/FlorianWoelki/obsidian-iconize/issues/38
  2. https://github.com/noatpad/obsidian-banners
  3. https://github.com/mdelobelle/metadatamenu

UseCase 2: Using Custom Icon Rules on own defined Frontmatter Fields or Tags

Like @ReedWriter mentioned, I think this is still an issue to have less work with defined icons on files.

Like with the already possible option to define regex or string patterns on files or paths.

The Problem I see:

  1. If you would like to change an Icon for a specific type, you might need to change all files, and replace the value of the icon frontmatter field.
  2. It is not always possible to group the same types of files in a folder (inherited icons on folder)

I consider the regex or string match by the Custom Icon Role setting is still the ideal solution, but would be great to be enhanced on fromatter fileds.

Take a look at Auto Note Mover Plugin, it uses a similar strategy.

Screenshot - 2023-12-06 22 52 54

Related:

  1. https://github.com/FlorianWoelki/obsidian-iconize/issues/38#issue-1127805466
  2. https://github.com/farux/obsidian-auto-note-mover

Describe the solution you'd like

UseCase 1

Ideally, you can set up the property filed name by your own, which fits in your own naming convention in the settings dialog.

Screenshot - 2023-12-06 22 23 26

Use Case 2

The ability to choise between:

  1. File or Path (like implemented)
  2. An own frontmatter filed with regex or string
  3. A tag with regex or string (like first match in tag list, or ideally you're using only one tag per note)

Screenshot - 2023-12-06 22 45 39

Sidenote: My current workflow is, as you might see in the screenshot, is using Wikipedia like file naming.

Describe alternatives you've considered

Related:

  1. https://github.com/mdelobelle/obsidian_supercharged_links
ngsilverman commented 6 months ago

I just opened a PR (https://github.com/FlorianWoelki/obsidian-iconize/pull/353) that would make it possible to write rules based on file properties (aka. Frontmatter) or tags (among other things).

So for example, looking at your use case 2, you could write the following rules:

If the icon file property matches a given regex

regextest("your regex", this.icon)

If a tag in the file matches a given regex

this.file.tags and any(this.file.tags, (t) => regextest("your regex", t))