How do I remove the TOC widget from pages without using frontmatter?

In v1 there was a simple setting you could add to configure this but I can’t figure out how to do this except for manually adding the pageDecoration to frontmatter of each page?

I have a page “Library/my/Widgets/TOC” with this text:

#meta

Table of contents

-- priority: 9 -- overwrites the default one
widgets = widgets or {}

function widgets.toc(options) -- sovrascive quella di default
  -- overwrites the default one
end

Linked mentions

-- priority: 9 -- overwrites the default one
widgets = widgets or {}

function widgets.linkedMentions(pageName)
-- overwrites the default one
end

Thanks @Marco10x15! I modified the code so I could restrict it per page without needing to add a pageDecorator in the frontmatter:

local oldtoc = widgets.toc
function widgets.toc(options)
  local pageName = editor.getCurrentPage()
  if string.startsWith(pageName, "Dashboard") then
    return
  elseif string.startsWith(pageName, "Journal/") then
    return
  elseif string.startsWith(pageName, "Templates/") then
    return
  else
    return oldtoc()
  end
end
3 Likes

As of 2.1.5 there is now a configuration for it:

1 Like