-
Notifications
You must be signed in to change notification settings - Fork 604
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
Deploy to gh-pages #535
Comments
You should be able to use |
🤔 I'm not sure I understand...
but where should I put |
I think you'll need to use the theme directly instead of using |
Thanks so much! I was about to open the same issue and submit a PR that was probably overkill. Can you recommend a good place to add this to the docs? Not sure I would have ever discovered it on my own. Happy to submit a PR. |
Maybe add a link to DOCS list under |
@isBatak @jxnblk I think we could add a new template using my boilerplate to |
I was able to deploy my slide-deck to github pages as well! Which is published here https://fullstackzach.com/git-talk/ here's a reference to my working repo. https://github.com/fullstackzach/git-talk I thought I'd share as another setup reference. Thanks to @pengx17 for the example! |
@pengx17 I followed your starter here, https://github.com/pengx17/slides, and was able to get my site working on Github Pages, but I noticed that the Theme UI customizations I had made don't end up in the build. Would you have any thoughts on why that might be? I'm not very familiar with Gatsby. Also, thanks for pointing to the starter repo! It was really helpful. |
Hello ✋ But (there is always a “but”) there is something in the router that point always at the root (probably the webpack configuration?), have some ideas about that? BTW I've hardcoded in my bundle the broken paths and now works, |
This did lose the theme. Ref: jxnblk/mdx-deck#535 https://github.com/farbenmeer/ausguck
Edit: Both Better solution below: Workaround: Using After you've installed diff --git a/node_modules/mdx-deck/cli.js b/node_modules/mdx-deck/cli.js
index 2c3be60..e263b3e 100755
--- a/node_modules/mdx-deck/cli.js
+++ b/node_modules/mdx-deck/cli.js
@@ -76,7 +76,7 @@ const gatsby = async (...args) => {
switch (cmd) {
case 'build':
- gatsby('build').then(() => {
+ gatsby('build', '--prefix-paths').then(() => {
const public = path.join(__dirname, 'public')
const dist = path.join(process.cwd(), 'public')
if (public === dist) return
diff --git a/node_modules/mdx-deck/gatsby-config.js b/node_modules/mdx-deck/gatsby-config.js
index 60247e3..3bae469 100644
--- a/node_modules/mdx-deck/gatsby-config.js
+++ b/node_modules/mdx-deck/gatsby-config.js
@@ -4,7 +4,9 @@ const src = process.env.__SRC__
const dirname = path.dirname(src)
module.exports = {
+ assetPrefix: '__GATSBY_RELATIVE_PATH__',
plugins: [
+ 'gatsby-plugin-relative-paths',
{
resolve: '@mdx-deck/gatsby-plugin',
options: { This seems to have some problems with images, but it is the solution that works the most out of a bunch that I've tried. Oh Gatsby :( |
Ah, one more fix is to the URL - to fix the pathname when the slide deck is not in the root. I've opened a PR here: #799
After you've installed diff --git a/node_modules/@mdx-deck/gatsby-plugin/src/deck.js b/node_modules/@mdx-deck/gatsby-plugin/src/deck.js
index 863562d..ca87c55 100644
--- a/node_modules/@mdx-deck/gatsby-plugin/src/deck.js
+++ b/node_modules/@mdx-deck/gatsby-plugin/src/deck.js
@@ -38,8 +38,9 @@ export default props => {
}, [index])
React.useEffect(() => {
- if (props.location.pathname === '/print') return
- props.navigate('/#' + index, {
+ const pathname = props.location.pathname
+ if (pathname === '/print') return
+ props.navigate(`${pathname}#${index}`, {
replace: true,
})
}, [index]) |
Full Working Workaround with Create your You may need to adapt this to your needs. Currently the code below assumes that your slide decks are in a folder called After you've installed diff --git a/node_modules/mdx-deck/cli.js b/node_modules/mdx-deck/cli.js
index 2c3be60..e263b3e 100755
--- a/node_modules/mdx-deck/cli.js
+++ b/node_modules/mdx-deck/cli.js
@@ -76,7 +76,7 @@ const gatsby = async (...args) => {
switch (cmd) {
case 'build':
- gatsby('build').then(() => {
+ gatsby('build', '--prefix-paths').then(() => {
const public = path.join(__dirname, 'public')
const dist = path.join(process.cwd(), 'public')
if (public === dist) return
diff --git a/node_modules/mdx-deck/gatsby-config.js b/node_modules/mdx-deck/gatsby-config.js
index 60247e3..fcc7806 100644
--- a/node_modules/mdx-deck/gatsby-config.js
+++ b/node_modules/mdx-deck/gatsby-config.js
@@ -2,8 +2,14 @@ const path = require('path')
const src = process.env.__SRC__
const dirname = path.dirname(src)
+const pathPrefixDirectory = src.match(/slide-decks\/([^/]+)\//)[1]
+
+if (!pathPrefixDirectory) {
+ throw new Error(`Path prefix directory does not match format for path: ${src}`)
+}
module.exports = {
+ pathPrefix: `/slide-decks/${pathPrefixDirectory}`,
plugins: [
{
resolve: '@mdx-deck/gatsby-plugin', This requires that you also use the other patch from above for diff --git a/node_modules/@mdx-deck/gatsby-plugin/src/deck.js b/node_modules/@mdx-deck/gatsby-plugin/src/deck.js
index 863562d..ca87c55 100644
--- a/node_modules/@mdx-deck/gatsby-plugin/src/deck.js
+++ b/node_modules/@mdx-deck/gatsby-plugin/src/deck.js
@@ -38,8 +38,9 @@ export default props => {
}, [index])
React.useEffect(() => {
- if (props.location.pathname === '/print') return
- props.navigate('/#' + index, {
+ const pathname = props.location.pathname
+ if (pathname === '/print') return
+ props.navigate(`${pathname}#${index}`, {
replace: true,
})
}, [index]) |
mdx-deck will only deploy to gh-pages correctly with the gatsby CLI due to configuration needs. Instead, just deploy to Netlify. More info: jxnblk/mdx-deck#535
Is there a way to make it work with gh-pages branch.
problem is that links in generated
index.html
are relative from a domain (starts with/
)<link as="script" rel="preload" href="/commons-cb11f4ecc482359b7fd0.js"/>
And
gh-pages
branch served formhttps://<username>.github.io/<project-name>/
which will resolve tohttps://username.github.io/commons-cb11f4ecc482359b7fd0.js
and won't work.Path prefix form gatsby settings should solve the problem https://www.gatsbyjs.org/docs/path-prefix/
The text was updated successfully, but these errors were encountered: