Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow page index to be one later part of pathname #291

Closed
wgao19 opened this issue Mar 24, 2019 · 6 comments

Comments

Projects
None yet
4 participants
@wgao19
Copy link

commented Mar 24, 2019

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?

@pengx17

This comment has been minimized.

Copy link
Contributor

commented Mar 26, 2019

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.

@wgao19

This comment has been minimized.

Copy link
Author

commented Mar 29, 2019

Thank you for the tip! Will close this :]

@wgao19 wgao19 closed this Mar 29, 2019

@pengx17

This comment has been minimized.

Copy link
Contributor

commented Apr 1, 2019

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

@HoverBaum

This comment has been minimized.

Copy link

commented Apr 5, 2019

A better documented solution for this would be awesome. Lowering the hurdle to host mdx-decks on GitHub pages would be great.

@jxnblk

This comment has been minimized.

Copy link
Owner

commented Apr 5, 2019

Yeah, I think this is worth supporting, so reopening the issue

@jxnblk jxnblk reopened this Apr 5, 2019

@jxnblk

This comment has been minimized.

Copy link
Owner

commented Apr 14, 2019

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

@jxnblk jxnblk closed this Apr 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.