├── .babelrc
├── .eslintrc
├── .gitignore
├── README.md
├── artifacts
├── react-static-browser-plugins.js
└── react-static-templates.js
├── config.js
├── package-lock.json
├── package.json
├── public
├── robots.txt
└── thumbnail.PNG
├── src
├── App.js
├── app.css
├── components
│ └── Router.js
├── containers
│ ├── Dynamic.js
│ └── Post.js
├── index.js
└── pages
│ ├── 404.js
│ ├── about.js
│ ├── index.js
│ └── post.js
├── static.config.js
├── tmp
└── dev-server
│ └── index.html
└── yarn.lock
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["react-static/babel-preset.js"]
3 | }
4 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "react-app"
3 | }
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # React-Static + Cosmic JS
2 |
3 | 
4 |
5 | > This repo contains an example blog website that is built with [React-Static](https://react-static.js.org), and [Cosmic JS](https://www.cosmicjs.com).
6 |
7 | ### [View Demo](https://cosmicjs.com/apps/react-static-blog)
8 |
9 | ## Prerequisites
10 |
11 | - Node (I recommend using v8.2.0 or higher)
12 | - [React-Static CLI](https://react-static.js.org)
13 |
14 | ## Getting Started
15 |
16 | ``` bash
17 | git clone https://github.com/sumitkharche/react-static-cosmicjs-blog.git
18 | cd react-static-cosmicjs-blog
19 | npm install or yarn install
20 | ```
21 | ### Run
22 | ``` bash
23 | npm run start
24 | ```
25 | Open http://localhost:3000.
26 |
27 | ### Production
28 | ``` bash
29 | npm run build
30 | ```
31 |
--------------------------------------------------------------------------------
/artifacts/react-static-browser-plugins.js:
--------------------------------------------------------------------------------
1 | // Imports
2 | import plugin0 from '../node_modules/react-static-plugin-reach-router/browser.api.js'
3 |
4 | // Plugins
5 | const plugins = [{
6 | location: "../node_modules/react-static-plugin-source-filesystem",
7 | plugins: [],
8 | hooks: {}
9 | },
10 | {
11 | location: "../node_modules/react-static-plugin-reach-router",
12 | plugins: [],
13 | hooks: plugin0({})
14 | },
15 | {
16 | location: "../node_modules/react-static-plugin-sitemap/dist",
17 | plugins: [],
18 | hooks: {}
19 | },
20 | {
21 | location: "..",
22 | plugins: [],
23 | hooks: {}
24 | }]
25 |
26 | // Export em!
27 | export default plugins
--------------------------------------------------------------------------------
/artifacts/react-static-templates.js:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | // Template Map
5 | export default {
6 | '../src/pages/404.js': require('../src/pages/404.js').default,
7 | '../src/pages/about.js': require('../src/pages/about.js').default,
8 | '../src/pages/index.js': require('../src/pages/index.js').default,
9 | '../src/pages/post.js': require('../src/pages/post.js').default,
10 | '../src/pages/post': require('../src/pages/post').default
11 | }
12 |
13 | export const notFoundTemplate = '../src/pages/404.js'
14 |
15 |
--------------------------------------------------------------------------------
/config.js:
--------------------------------------------------------------------------------
1 | export default {
2 | bucket: {
3 | slug: process.env.COSMIC_BUCKET || 'coffee-blog',
4 | read_key: process.env.COSMIC_READ_KEY || '',
5 | write_key: process.env.COSMIC_WRITE_KEY || '',
6 | port: process.env.PORT || '',
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-static-cosmicjs-blog",
3 | "private": true,
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "react-static start",
7 | "stage": "react-static build --staging",
8 | "build": "react-static build",
9 | "analyze": "react-static build --analyze",
10 | "serve": "serve dist -p 3000"
11 | },
12 | "dependencies": {
13 | "@reach/router": "^1.2.1",
14 | "axios": "^0.18.0",
15 | "graphql-request": "^1.8.2",
16 | "react": "^16.8.2",
17 | "react-dom": "^16.8.2",
18 | "react-markdown": "^4.0.8",
19 | "react-static": "^7.0.0",
20 | "react-static-plugin-reach-router": "^7.0.0",
21 | "react-static-plugin-sitemap": "^7.0.0",
22 | "react-static-plugin-source-filesystem": "^7.0.0"
23 | },
24 | "devDependencies": {
25 | "babel-eslint": "9.x",
26 | "eslint": "5.x",
27 | "eslint-config-react-app": "^3.0.8",
28 | "eslint-config-react-tools": "1.x.x",
29 | "eslint-plugin-flowtype": "2.x",
30 | "eslint-plugin-import": "2.x",
31 | "eslint-plugin-jsx-a11y": "6.x",
32 | "eslint-plugin-react": "7.x",
33 | "serve": "10.1.2"
34 | },
35 | "browserslist": [
36 | "last 1 version",
37 | "> 1%",
38 | "maintained node versions",
39 | "not dead"
40 | ]
41 | }
42 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 |
--------------------------------------------------------------------------------
/public/thumbnail.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cosmicjs/react-static-blog/85280e05538aee05ca8b551811b44a385a839c2f/public/thumbnail.PNG
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import { Root, Routes, addPrefetchExcludes } from 'react-static'
3 | //
4 | import { Link, Router } from 'components/Router'
5 | import Dynamic from 'containers/Dynamic'
6 |
7 | import './app.css'
8 |
9 | // Any routes that start with 'dynamic' will be treated as non-static routes
10 | addPrefetchExcludes(['dynamic'])
11 |
12 | const isActive = ({ isCurrent }) => {
13 | return isCurrent ? { className: "active" } : { className: "header-link" };
14 | };
15 |
16 | function App() {
17 | return (
18 | React-Static & Cosmic JS blog
21 |
29 |
{post.body}
14 |React Static is a progressive static site generator for React.
6 |Cosmic JS is Headless CMS API and toolkit to build modern apps faster,together.
7 |This application uses both React-Static and Cosmic JS to bulid next generation JAMStack apps.
8 |