Skip to content

Frontmatter does not keep track of the fields' order #672

Open
@rmenai

Description

@rmenai

🐛 Describe the bug

When I try to generate my own frontmatter, I noticed that it does not keep track of the order of the fields. I want to sort my fields based on the order of importance so I want to have

---
title: ...
date: ...
tags: []
---

But instead I get this

---
tags: []
date: ...
title: ...
---

Config

local function generate_frontmatter(note)
  local date = os.date("%Y-%m-%d %H:%M")
  local out = { title = note.title, date = date, tags = note.tags }

  if note.metadata ~= nil and not vim.tbl_isempty(note.metadata) then
    for k, v in pairs(note.metadata) do
      out[k] = v
    end
  end

  return out
end

Environment

NVIM v0.10.0
Build type: RelWithDebInfo
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

Obsidian.nvim v3.9.0 (d1ca121353681e8f7dc8a69c760b950e12bcde22)
Status:
  • buffer directory: nil
  • working directory: /home/rami/.config/nvim/lua/plugins
Workspaces:
  ✓ active workspace: Workspace(name='notes', path='/home/rami/Documents/Vaults/notes', root='/home/rami/Documents/Vaults/notes')
Dependencies:
  ✓ plenary.nvim: a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683
  ✓ nvim-cmp: d818fd0624205b34e14888358037fb6f5dc51234
Integrations:
  ✓ picker: TelescopePicker()
  ✓ completion: enabled (nvim-cmp) ✗ refs, ✗ tags, ✗ new
    all sources:
      • nvim_lsp
Tools:
  ✓ rg: ripgrep 13.0.0
Environment:
  • operating system: Wsl
Config:
  • notes_subdir: nil

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions