I'm building a speaker site and hoping to let it host my slides as well as a home page. The slides will have urls like this: http://my.site.cc/slides/yyyy-mm--topic-of-my-talk/. This works with my other slides built with reveal.js. But it does not work with mdx-deck.
When I serve the deck directly, it works just as expected. But when I serve my site's root directory, it does not render any content although the JS is in place and the root is rendered with a few dummy nodes. Then when I slide with keyboard, the URL becomes .../NAN.
I looked around a little bit and find out that here it fixes to reading only the index 1 of pathname, which is possibly causing the problem in routing.
I'm wondering, would it be OK for here to use, say, the last part or the last number of pathname?
I also found this issue. I believe this issue may caused by a fact that mdx deck does not handle basepath other than /. A common fix is to use <base> attribute in html head and feed it to the underlying router component of reach router.
Thank you for the tip! Will close this :]
There is a possible solution I post in my fork here:
https://github.com/pengx17/mdx-deck/tree/feat/publich-path
and demo:
http://pengx17.github.io/mdx-deck
Note that you may need a custom 404 page to make sure github pages works like a real SPA.
e.g.:
<base href="/mdx-deck/">
Redirecting ...
<script>
location.href = '.';
</script>
I think this issue should be reopen and make it to the main branch. What do you think? @jxnblk
A better documented solution for this would be awesome. Lowering the hurdle to host mdx-decks on GitHub pages would be great.
Yeah, I think this is worth supporting, so reopening the issue
It's currently undocumented, but the CLI should now support a --basepath flag if anyone wants to check and see if that helps resolve this issue. The basepath is passed along to Reach Router, and you should be able to use it like mdx-deck build deck.mdx --basepath="/slides" – this is currently used internally in the @mdx-deck/gatsby-theme package, so I think it should work for this use-case as well
This does not work in v4.1.1. All href props in index.html contain root paths.
Most helpful comment
This does not work in v4.1.1. All
hrefprops inindex.htmlcontain root paths.