Next Static Blog 采用next.js开发的一个简单静态博客

Next Static Blog 采用next.js开发的一个简单静态博客

React 其它杂项

访问GitHub主页

共107Star

详细介绍

styled with prettier

Next Static Blog

Start static then go server rendered when you need to

A simple static blog powered by next.js.

Why

  • I found other SSG (Static Site Generator) to be too much for what I need
  • I wanted to be able to transition to a dynamic site easily if need be and next.js is a great existing SSR (Server Side Render) framework.

Usage

  • yarn
  • yarn run export
  • cd out
  • now

Adding a Post

  • Create a .js file in posts.
  • Export an object that contains post content/metadata
module.exports =  {
  title: 'Title',
  slug: 'slug',
  author: 'Your Name',
  date: new Date().toString(),
  tags: [
    'tags',
    'go here'
  ],
  body: `
  ## Post
  Use markdown to _write_ your post
  Here's some code:
  \`\`\`
  const a = 'thing';
  \`\`\`
  `
};
  • Inside ./posts/index.js require your new post and add it to the exported array.
  • Re-run yarn run export to build your new site.