Skip to content

Instantly share code, notes, and snippets.

@HartS
Last active February 8, 2021 09:07
Show Gist options
  • Save HartS/107d4fa4c26e9a88952a919a30a26d27 to your computer and use it in GitHub Desktop.
Save HartS/107d4fa4c26e9a88952a919a30a26d27 to your computer and use it in GitHub Desktop.
nextein-guide-setup
#!/bin/bash
mkdir my-blog && cd my-blog && npm init -y
npm install --save next react react-dom nextein webpack@4
cat > next.config.js << 'EOF'
const nexteinConfig = require('nextein/config').default
module.exports = nexteinConfig({
// place your next config in here!
})
EOF
mkdir pages posts
cat > pages/index.js << 'EOF'
import React from 'react'
import withPosts from 'nextein/posts'
import { Content } from 'nextein/post'
export default withPosts(({ posts }) => {
return (
<main>
{
posts.map((post, index) => (
<article key={`post-${index}`}>
<h1>{post.data.title}</h1>
<Content {...post} />
</article>
))
}
</main>
)
})
EOF
cat > posts/my-post.md << 'EOF'
---
title: My First Post
---
This is the content of the first post. Hello there!
EOF
# Safely add .scripts.dev=nextein to package.json
wget https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 -O /usr/local/bin/jq
chmod +x /usr/local/bin/jq
echo "$(jq '.scripts.dev="nextein"' package.json)" > package.json
npm run dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment