Return to top widget

Hi All,
Does anyone have any tips on how I could make a return to top bottom widget?

I have the below which almost works but is inconsistent on some pages and doesnt really work at all on index.


widgets = widgets or {}

function widgets.gotoTop()
  local pageName = editor.getCurrentPage()
  -- Link to line 1, column 1 (top of page)
  local link = string.format("[[%s@L1c1|Go to Top]]", pageName)
  
  return widget.new {
    markdown = link
  }
end

event.listen {
  name = "hooks:renderBottomWidgets",
  run = function(e)
    return widgets.gotoTop()
  end
}

Any help would be super appreciated. :slight_smile:

I fixed it I think, it just so happens that I have tags set on some of the pages I was testing on to hide the frontmatter so setting it to lines below this has helped :slight_smile: