forked from gatsbyjs/gatsby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
experimental mdx-deck support ======================= * [kitchen-sink] Switch away from gatsby-plugin-emotion (replace it with raw gatsby-ssr/browser) so we can avoid the babel plugin and use styled-components (a dependency of mdx-deck) on the same site * Introduce the .deck-mdx extension (highly experimental but works for now? I wanted .deck.mdx but couldn't get it to work) * [kitchen-sink] pages are now namespaced by filesystem source name (posts, slides, etc) to make it easier to identify when debugging TODO: - what cool stuff can we do for default components, default themes, custom themes, etc - can we integrate the "save pdf" workflow from mdx-deck? - more examples to fully test the integration
- Loading branch information
1 parent
510df14
commit a8a8a83
Showing
2 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const { getOptions } = require("loader-utils"); | ||
const debug = require("debug")("gatsby-mdx:mdx-deck-post-loader"); | ||
|
||
const hasDefaultExport = str => /\nexport default/.test(str); | ||
|
||
module.exports = async function(content) { | ||
const callback = this.async(); | ||
const { pluginOptions: options } = getOptions(this) || {}; | ||
|
||
const code = `import { SlideDeck } from 'mdx-deck' | ||
${content.replace("export default", "export const slides =")} | ||
// TODO: replace theme with a default theme and default components options? | ||
// if no theme is defined, set to undefined | ||
try { | ||
theme | ||
} catch (e) { | ||
var theme = undefined; | ||
} | ||
// if no components are defined, set to undefined | ||
try { | ||
components | ||
} catch (e) { | ||
var components = undefined; | ||
} | ||
export default () => | ||
<SlideDeck | ||
slides={slides} | ||
theme={theme} | ||
components={components} | ||
width='100vw' | ||
height='100vh' | ||
/>`; | ||
|
||
return callback(null, code); | ||
}; |