Metadata Menu Documentation

repository·master·Indexed 20 days ago

https://github.com/mdelobelle/metadatamenu

An Obsidian plugin for managing note metadata, providing structured field types, autocompletion, and modification interfaces for YAML frontmatter and Dataview inline fields. It includes a comprehensive API for reading and writing fields via indexed paths, support for FileClasses to define field priorities, and integration with DataviewJS through the fieldModifier function.

Tokens
23.7K
Snippets
58
Records
123
Agent score
71%

What's inside Metadata Menu

  1. Overview of Metadata Menu

    master

    Metadata Menu is an Obsidian plugin designed to help users access and manage note metadata. It provides tools to modify both YAML frontmatter (properties) and Dataview 'inline fields' (fieldName::value) directly through the Obsidian interface.

    Key Capabilities:

    • Quick Modification: Modify metadata via context menus (right-clicking links), the command palette, dedicated buttons next to notes, or within Dataview tables.
    • Field Configuration: Define preset types and allowed values globally in plugin settings or specifically for certain files using fileClass definitions.
    • Autocompletion: Enables autocompletion for frontmatter and inline fields based on your defined preset values.
    • Data Quality: Helps maintain structured data across your Obsidian vault by enforcing field types and suggested values.
  2. Use inheritance with the `extends` field

    master

    A fileClass can inherit fields from another fileClass using the extends property in its frontmatter. This allows you to build specialized classes from a base template.

    Key Inheritance Behaviors

    • Field Addition: The child class gains all fields from the parent.
    • Field Overriding: If a child class defines a field with the same name as a parent field, the child's definition (e.g., different options) overrides the parent's.
    • Excluding Fields: Use the excludes key with an array of field names to prevent specific fields from being inherited.

    Example

    If course.md has fields teacher and grade, and physics.md extends course but defines excludes: [grade], then physics notes will have teacher but not grade.

    # physics.md
    ---
    extends: course
    excludes: [grade]
    fields:
      - name: lecture
        type: Select
        options:
          - "0": Mechanics
    ---
  3. Use the Metadata Menu button and modal

    master

    If a note has one or more fileClass or Supercharged tags defined, a button will appear next to the note reference throughout your vault.

    Clicking this button opens a modal where you can:

    • Update a field.
    • Insert a field.
    • Change field settings within the fileClass.
    • View relationships between fields and fileClasses.
    • Bulk insert missing fields (for all fileClasses or a specific one).

    Customization:

    • The button icon can be customized in the fileClass with higher priority.
    • Button visibility is managed in the plugin settings under show-extra-button-to-access-metadata-menu-form.
  4. How Lookup fields work and how to configure them

    master

    A Lookup field searches for a related field within notes identified by a DataviewJS Query. Unlike standard Dataview views, Lookup fields update the actual content of the file, making them persistent and suitable for publishing.

    Configuration Steps:

    1. Pages to look for: A dv.pages(...) query returning a data array of page objects.
    2. Name of the related field: The name of the field the plugin searches for within those pages. The plugin matches this field's value against the source note's link.
    3. Type of output:
      • Links list: Comma-separated list of links.
      • Links indented list: Bulleted list of links.
      • Built-in Summarizing function: Performs math on a Summarized field name:
        • Sum, Count, CountAll, Average, Max, Min.
      • Custom list rendering function: A JS function returning a string. The page object is available.
      • Custom indented list rendering function: Custom JS function rendered as a bullet list.
      • Custom summarizing function: A JS function that takes the pages data array and returns a value.

    Example Scenario

    If you define a students lookup field with:

    • Query: dv.pages("#student")
    • Related field: School

    And you have notes where #student notes have School:: [[Princeton]], then adding students:: to Princeton.md will automatically populate students:: [[John]], [[Anna]], [[Steve]].

    // Example of a Custom Summarizing function
    const i = 0.0;
    const sum = pages.reduce((p, c) => p + c["age"], i);
    return sum / pages.length;
  5. How Metadata Menu manages metadata fields

    master

    Metadata Menu manages metadata fields located in two primary locations within a note:

    1. Frontmatter: Using standard YAML syntax.
    2. Note Body: Using the field:: syntax (Dataview style). Note that using this syntax requires the Dataview plugin to be installed.

    To enable management for these fields, you must provide a field definition specifying its type and available options.

  6. Understand Metadata Menu Field Types

    master

    Metadata Menu assigns a specific type to every field to control how data is entered and validated. If no type is specified, the field defaults to Input.

    Available Field Types

    TypeDescription
    InputFree text (default). Accepts any value.
    BooleanAccepts true, false, or null.
    NumberAccepts a float. Can be constrained by min, max, and a step value (default 1).
    SelectAccepts a single value from a predefined list.
    MultiAccepts multiple values from a predefined list.
    CycleCycles through values from a predefined list.
    FileAccepts a link to a single file from your vault.
    MultiFileAccepts multiple links to files.
    MediaAccepts a link to a media file.
    MultiMediaAccepts multiple links to media files.
    DateAccepts a date.
    DateTimeAccepts a date and time.
    TimeAccepts a time.
    LookupAccepts a lookup query.
    CanvasUpdates with links in an Obsidian Canvas.
    Canvas GroupUpdates with groups in an Obsidian Canvas.
    Canvas Group LinkUpdates with group links in an Obsidian Canvas.
    JSONAccepts a JSON object.
    YAMLAccepts a YAML object.
    ObjectAccepts a collection of fields.
    Object ListAccepts a list of collections of fields.
  7. How to map files to a fileClass

    master

    You can associate a note with a fileClass using several methods. If multiple methods apply, the plugin resolves field conflicts using this priority order:

    1. fileClass value in the note's frontmatter
    2. Tag match (if mapWithTag is enabled)
    3. Path match (folder path)
    4. Bookmark group match
    5. fileClassQuery match
    6. Global fileClass
    7. Settings preset fields

    Mapping Methods

    1. Basic Mapping (Frontmatter)

    Explicitly name the class in the note's frontmatter. You can provide a single string or an array for multiple classes.

    fileClass: music
    fileClass:
      - company 
      - pkm

    2. Map with Tag

    If mapWithTag is set to true in the fileClass settings, any note containing a tag matching the class name will inherit its fields.

    3. Map with Folder Path

    Configure the Files Paths option in the fileClass settings. Any file located within those paths will be automatically mapped.

    4. Map with Bookmark Groups

    Configure the Bookmark group option. Files belonging to these bookmark groups will be mapped.

    5. Map with Query

    Use fileClassQuery in the plugin settings to map all files returned by a specific query to a class.

    # Basic mapping in a note
    ---
    fileClass: music
    ---
  8. Configure Field Settings and FileClass Priority

    master

    A field setting consists of a name, a type, and type-specific options. You can define these settings in two places:

    1. Metadata Menu Settings: Global definitions for all notes.
    2. FileClass: Definitions specific to certain files (defined within a fileClass note).

    Priority Rule

    If a field has a setting defined in both the global Metadata Menu settings AND in a fileClass note, the fileClass setting takes priority.

  9. Identify field locations in Markdown files

    master

    Metadata Menu can manage fields located in two primary sections of a Markdown file:

    1. Frontmatter section: Standard Obsidian properties using the <name>: <value> format.
    2. Body section (Dataview notation):
      • Full line: <name>:: <value>
      • Inline: ... (<name>:: value) ... or ... [<name>:: <value>] ...
  10. Define field settings and priority

    master

    A field setting is a definition composed of a name, a type, and type-specific options.

    You can define these settings in two places:

    1. Metadata Menu settings: Global configuration.
    2. FileClass note: Specific configuration for a class of notes.

    Priority Management

    If a field has settings defined in both the global Metadata Menu settings and a FileClass note, the FileClass setting takes priority.

  11. Understand the `indexedPath` for ObjectLists

    master

    For fields within an ObjectList, the plugin computes an indexedPath. This is required when using the postValues API method to identify a specific instance in a list.

    An indexedPath is composed of:

    1. Each parent id separated by ____.
    2. The position in the parent list enclosed in square brackets (e.g., [0]).
    3. The field's own id.

    Example Structure: If an Employees list (dx8Mth) has a second entry, and that entry has a Name field (7r1kwd), the indexedPath for that name would be dx8Mth[1]____7r1kwd.