A blog starter based on React and Next.js.
/sitemap.xml/rss.xmlrobots.txt auto-generated, available at /robots.txt/pages: Next.js pages (by default / and /posts/:slug)/components: React components/posts: Markdown posts/images: Images that will be optimized (compression + responsive)/static: Resources that will be copied without any treatmentnpx degit soywod/nextjs-blog-starter my-blog
cd my-blog
yarn installyarn startyarn exportThe static build will be available in /out.
Images are optimized by next-optimized-images.
For example, to optimized and resize JPEG images:
import React from 'react';
const oneSize = require('./images/my-image.jpg?resize&size=300');
const multipleSizes = require('./images/my-image.jpg?resize&sizes[]=300&sizes[]=600&sizes[]=1000');
export default () => (
<div>
{/* Single image: */}
<img src={oneSize.src} />
{/* Source set with multiple sizes: */}
<img srcSet={multipleSizes.srcSet} src={multipleSizes.src} />
</div>
);yarn add -D @zeit/next-cssEdit next.config.js:
const withCSS = require('@zeit/next-css')
const plugins = [..., withCSS]yarn add -D @zeit/next-sass node-sassEdit next.config.js:
const withSASS = require('@zeit/next-sass')
const plugins = [..., withSASS]yarn add -D @zeit/next-less lessEdit next.config.js:
const withLESS = require('@zeit/next-less')
const plugins = [..., withLESS]yarn add react-gaEdit pages/_app.jsx:
import ReactGA from 'react-ga'
class MyApp extends App {
...
componentDidMount() {
ReactGA.initialize('UA-00000000-1')
ReactGA.pageview(window.location.pathname + window.location.search)
}
}yarn add disqus-reactEdit components/Post.jsx:
import {DiscussionEmbed} from 'disqus-react'
function Post(props) {
...
const disqusShortname = 'your-disqus-shortname'
const disqusConfig = {identifier: slug, title}
return (
<Fragment>
...
<DiscussionEmbed shortname={disqusShortname} config={disqusConfig} />
</Fragment>
)