dmy / elm-doc-preview

Elm offline documentation previewer
https://www.npmjs.com/package/elm-doc-preview
Other
126 stars 15 forks source link

Use same URL scheme as package.elm-lang.org? #1

Closed ianmackenzie closed 6 years ago

ianmackenzie commented 6 years ago

Would it be possible to change the previewer to use the same URL scheme as package.elm-lang.org? For example, currently a module Nested.Module will have the path #/Nested.Module in the previewer where the official package site would use Nested-Module.

Making this change would presumably also allow putting anchors on individual types/functions/values, also to match the official package site (so that Nested.Module.foo would have the path Nested-Module#foo). Having both would mean that Markdown links to other functions/values/types in the same package would work the same way in the previewer as on the official package site, which would be very useful to be able to check.

rlefevre commented 6 years ago

I started like this but the problem is that I don't think that it's possible to put default routes with github pages. So refreshing the page from any module would lead to a 404. I think this would be quite annoying (for example when restoring the browser tabs). On the other hand, I would like to add anchors so I would like to find a solution that solves both issues. Any idea?

Edit: it seems possible to use a custom 404 page, I'm looking into it.

rlefevre commented 6 years ago

Using the URL scheme of the official site is not enough to make markdown links work because they trigger a full page refresh.

I will think more about it, but right now I don't see an easy fix.

rlefevre commented 6 years ago

The same URL scheme as package.elm-lang.org is now used and previews are stored in local storage to be able to re-open them at the correct anchor after a page reload. This could be removed once https://github.com/elm-explorations/markdown/issues/1 is fixed.

rlefevre commented 5 years ago

For the record, markdown links are now intercepted from javascript to avoid page refreshes and add repos query parameters when needed. It's unfortunately still very hacky though...

Local storage is still used for local documentations as I believe that it helps navigating back from external links when testing a documentation.