# Welcome

Slides can be markdown files, plain html files or full react components (for complex stuff).
Last active
September 24, 2015 20:01
-
-
Save sokra/1be6f6f5eee72db39664 to your computer and use it in GitHub Desktop.
bespoke + react + webpack
This file contains hidden or 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
import React from "react"; | |
import bespoke from "bespoke"; | |
import "styles.css"; | |
// use react components, markdown or plain html files in the slides folder | |
var slidesContext = require.context("./slides", true, /\.(js|md|html)$/); | |
// sort slides by name, name them like this: ./slides/3-section/7-slide.md | |
var slides = slidesContext.keys().sort().map((key) => slidesContext(key)); | |
class App extends React.Component { | |
render() { | |
return <article> | |
{slides.map((slide) => { | |
if(typeof slide === "string") { | |
return <section dangerouslySetInnerHTML={{__html: slide}} /> | |
} else { | |
return React.createElement(slide); | |
} | |
})} | |
</article> | |
} | |
} | |
var app = React.render(<App />, document.body); | |
var deck = bespoke.from("article", [ | |
// ... | |
]); |
This file contains hidden or 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
module.exports = { | |
// ... | |
module: { | |
loaders: [ | |
[ | |
{ test: /\.css$/, loader: "style-loader!css-loader?modules", include: path.resolve(__dirname, "app") }, | |
{ test: /\.css$/, loader: "style-loader!css-loader" } | |
], | |
{ test: /\.md$/, loader: "html-loader!markdown-loader" }, | |
{ test: /\.html$/, loader: "html-loader" }, | |
{ test: /\.js$/, loader: "babel-loader", include: path.resolve(__dirname, "app") }, | |
{ test: /\.(png|jpg|woff2?)$/, loader: "file-loader" } | |
] | |
}, | |
// ... | |
// useful plugins: html-webpack-plugin or static-render-webpack-plugin | |
// useful tools: gh-pages | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment