While this is mostly to just fix Safari and other old browser not supporting regex lookbacks, having this code in JS was pretty disgusting anyways and people might appreciate having the versions already formatted in API returned objects.
... before we either use a different sanitization lib or figure out how to move the sanitization before the markdown renderer without destroying plain text
Previously vue would reuse the project page component when switching
between project pages as the component was not keyed.
This commit fixes this by partially modifying the project page setup.
In the current state both the project page content as well as the list
of opened project pages, used to properly configure the tree views
opened elements, are handled in the same state.
This layout however introduces a rather unfortunate flaw into the logic
which makes this fix a bit larger than a simple :key value.
The openedProjectPages `open` contains state that is expected to outlive
a simple change from one project page to another to properly show the
project page tree. This directly conflicts with the assumptions made
about the rest of the project state, which should be discarded the
displayed project page is changed as content and potential edit values
are no longer applicable.
To implement this, this commit splits the opened project pages array
into its own composable as well as the project page markdown into its
own component.
The opened project pages are then tracked by the owning route, e.g. the
prjects index route or the general page route, while the current page
markdown lives in a new component which owns its own state and is keyed
with the pages path.
This way, a change in route properly re-creates the project page
markdown component while keeping the same opened page state in the
parent component.
Up till now, the vue-router did not have any scroll behaviour, leading
to no scrolling on page changes. This becomes particularly obvious when
opening a project from bottom of the main project list, as the project
page is scrolled down to a good part of the README.md.
To fix this, this commit configures the routers scrollBehaviour
following the vuejs documentation to create the most native scrolling
behaviour possible, scrolling to any potentially saved position when
using the browsers back button or scrolling to the top of the page
otherwise.
See: https://router.vuejs.org/guide/advanced/scroll-behavior.html