├── .babelrc ├── .eslintignore ├── .eslintrc.yml ├── .flowconfig ├── .gitignore ├── .travis.yml ├── CODE_OF_CONDUCT.md ├── LICENSE.md ├── README.md ├── config └── index.js ├── flow-typed └── npm │ ├── next_v2.x.x.js │ └── styled-components_v2.x.x.js ├── next.config.js ├── nodemon.json ├── package.json ├── pages ├── _document.js ├── index.js ├── post.js └── tag.js ├── posts ├── HelloWorld.md ├── NextPost.md └── index.js ├── server.js ├── src ├── components │ ├── Footer │ │ ├── __snapshots__ │ │ │ └── test.js.snap │ │ ├── index.js │ │ └── test.js │ ├── Header │ │ ├── __snapshots__ │ │ │ └── test.js.snap │ │ ├── index.js │ │ └── test.js │ ├── Layout │ │ └── index.js │ └── Post │ │ ├── __snapshots__ │ │ └── test.js.snap │ │ ├── index.js │ │ └── test.js ├── layouts │ ├── centered.js │ ├── index.js │ └── none.js └── lib │ ├── generatePosts.js │ ├── getPosts.js │ ├── renderMarkup.js │ └── theme.js ├── types ├── colors.js ├── config.js ├── layout.js ├── next.js ├── post.js ├── request.js └── theme.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "es2015", 4 | "next/babel", 5 | "flow" 6 | ], 7 | "plugins": [ 8 | ["styled-components", { "ssr": true, "displayName": true, "preprocess": false } ], 9 | "transform-flow-strip-types", 10 | "transform-object-rest-spread", 11 | "transform-class-properties", 12 | "transform-runtime" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | out 2 | .next 3 | flow-typed 4 | posts 5 | src/**/**.test.js 6 | 7 | src/components/**/__snapshots__ 8 | src/components/**/test.js 9 | -------------------------------------------------------------------------------- /.eslintrc.yml: -------------------------------------------------------------------------------- 1 | parser: babel-eslint 2 | plugins: 3 | - prettier 4 | extends: 5 | - airbnb 6 | - prettier 7 | - prettier/react 8 | - prettier/flowtype 9 | env: 10 | es6: true 11 | browser: true 12 | node: true 13 | parserOptions: 14 | ecmaVersion: 6 15 | ecmaFeatures: 16 | jsx: true 17 | experimentalObjectRestSpread: true 18 | rules: 19 | prettier/prettier: 20 | - error 21 | - singleQuote: true 22 | trailingComma: es5 23 | parser: flow 24 | no-underscore-dangle: 0 25 | react/jsx-filename-extension: 0 26 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*/node_modules/mitt/.* 3 | .*/node_modules/babel-plugin-transform-react-remove-prop-types/.* 4 | .*/node_modules/styled-components/.* 5 | [libs] 6 | /types 7 | /flow-typed 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .next 3 | out 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 6 4 | install: yarn 5 | script: 6 | - yarn lint 7 | - yarn flow 8 | - yarn test -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at lherrington100@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Luke Herrington 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) 2 | [![Build Status](https://travis-ci.org/infiniteluke/next-static.svg?branch=master)](https://travis-ci.org/infiniteluke/next-static) 3 | [![David](https://img.shields.io/david/infiniteluke/next-static.svg)]() 4 | # Next Static Blog 5 | __✨ Start static then go server rendered when you need to ✨__ 6 | 7 | A simple static blog powered by [next.js](https://github.com/zeit/next.js). 8 | 9 | ## Before Using 10 | This repo could be a good starting place for your simple Next.js powered static site. That said, there are other options out there that are more extensible, well maintained, and battle tested than this repo. Check them out: https://myles.github.io/awesome-static-generators/ 11 | 12 | ## Getting Started 13 | * Fork this repo 14 | * `yarn` 15 | * Edit `config/index.js` to your liking. 16 | * Get the best experience with config by adding a plugin to your text editor that will surface flow errors. This will ensure you're providing the expected types for your config values. 17 | * `yarn dev` 18 | * Write! 📝 19 | 20 | ## Writting 21 | * Create a `.md` file in `posts`. 22 | * Add front matter separated by `---` and the body of the post in markdown below: 23 |
24 | ---
25 | title: Title
26 | slug: slug
27 | author: Your Name
28 | date: 2017-6-10 15:00 PDT
29 | tags:
30 |   - tags
31 |   - go here
32 | ---
33 | ## Post
34 | Use markdown to _write_ your post
35 | Here's some code:
36 | ```javascript
37 | const a = 'thing';
38 | ```
39 | 
40 | * While writing, run `yarn dev` to see your post live reload when saved. 41 | * Re-run `yarn export` to build your new site. 42 | 43 | ## Default Build 44 | screen shot 2017-08-25 at 2 26 18 pm 45 | 46 | ## Updating Next Static 47 | Currently Next Static is not packaged an distributed on NPM. In order to receive updates you will need to do something like this: 48 | * Inside the your fork `git remote add upstream git@github.com:infiniteluke/next-static.git` 49 | * `git merge upstream master` 50 | * To the extent that you hack Next Static, you will need to resolve merge conflicts. 51 | * I'm open to ideas on how to best package this and make the update process as simple as bumping versions. 52 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { type Config } from '../types/config'; 4 | 5 | const config: Config = { 6 | siteName: 'Next Static Blog', 7 | slogan: '✨ Start static then go server rendered when you need to ✨', 8 | layout: 'centered', 9 | theme: { 10 | colors: { 11 | main: '#24292E', 12 | dark: '#3F4448', 13 | light: '#FAFBFC', 14 | accent: '#0366D6', 15 | }, 16 | }, 17 | }; 18 | 19 | export default config; 20 | -------------------------------------------------------------------------------- /flow-typed/npm/next_v2.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 4d3fb8f2ed0c9a8ce4bc20ddec1dd85a 2 | // flow-typed version: d80d7aa0bf/next_v2.x.x/flow_>=v0.37.x 3 | 4 | declare module 'next' { 5 | declare type RequestHandler = ( 6 | req: http$IncomingMessage, 7 | res: http$ServerResponse, 8 | parsedUrl: any 9 | ) => Promise; 10 | declare type NextApp = { 11 | prepare(): Promise, 12 | getRequestHandler(): RequestHandler, 13 | render( 14 | req: http$IncomingMessage, 15 | res: http$ServerResponse, 16 | pathname: string, 17 | query: any 18 | ): any, 19 | renderToHTML( 20 | req: http$IncomingMessage, 21 | res: http$ServerResponse, 22 | pathname: string, 23 | query: string 24 | ): string, 25 | renderError( 26 | err: Error, 27 | req: http$IncomingMessage, 28 | res: http$ServerResponse, 29 | pathname: any, 30 | query: any 31 | ): any, 32 | renderErrorToHTML( 33 | err: Error, 34 | req: http$IncomingMessage, 35 | res: http$ServerResponse, 36 | pathname: string, 37 | query: any 38 | ): string, 39 | }; 40 | declare type Options = { 41 | dev?: boolean, 42 | dir?: string, 43 | quiet?: boolean, 44 | staticMarkup?: boolean, 45 | }; 46 | declare module.exports: (opts: Options) => NextApp; 47 | } 48 | 49 | declare module 'next/head' { 50 | import type { Component } from 'react'; 51 | 52 | declare export default Class> 53 | } 54 | 55 | declare module 'next/link' { 56 | import type { Component } from 'react'; 57 | 58 | declare type State = { href: string }; 59 | declare export default Class> 60 | } 61 | 62 | declare module 'next/prefetch' { 63 | import type { Component } from 'react'; 64 | 65 | declare type State = { 66 | href: string, 67 | prefetch?: boolean, 68 | }; 69 | declare export var reloadIfPrefetched: any; 70 | declare export function prefetch(url: string): any; 71 | declare export default Class> 72 | } 73 | 74 | declare module 'next/router' { 75 | declare type RouteError = Error & { cancelled: boolean }; 76 | declare type RouteCallback = (url: string) => void; 77 | declare type RouteErrorCallback = (err: RouteError, url: string) => void; 78 | 79 | declare export default { 80 | route: string, 81 | pathname: string, 82 | query: Object, 83 | onRouteChangeStart: ?RouteCallback, 84 | onRouteChangeComplete: ?RouteCallback, 85 | onRouteChangeError: ?RouteErrorCallback, 86 | push(url: string, as: ?string): Promise, 87 | replace(url: string, as: ?string): Promise, 88 | } 89 | } 90 | 91 | declare module 'next/document' { 92 | import type { Component } from 'react'; 93 | 94 | declare type Context = { 95 | pathname: string, 96 | query: any, 97 | req?: any, 98 | res?: any, 99 | xhr?: any, 100 | err?: any, 101 | }; 102 | declare export var Head: Class>; 103 | declare export var Main: Class>; 104 | declare export var NextScript: Class>; 105 | declare export default Class> & { 106 | getInitialProps: (ctx: Context) => Promise<*>, 107 | renderPage(cb: Function): void, 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /flow-typed/npm/styled-components_v2.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 5154b35922893a9a83e98c418f18be49 2 | // flow-typed version: cfaf0b496f/styled-components_v2.x.x/flow_>=v0.25.x 3 | 4 | // @flow 5 | 6 | type $npm$styledComponents$Interpolation = 7 | | ((executionContext: Object) => string) 8 | | string 9 | | number; 10 | type $npm$styledComponents$NameGenerator = (hash: number) => string; 11 | 12 | type $npm$styledComponents$StyledComponent = ( 13 | strings: Array, 14 | ...interpolations: Array<$npm$styledComponents$Interpolation> 15 | ) => ReactClass<*>; 16 | 17 | type $npm$styledComponents$Theme = { [key: string]: mixed }; 18 | type $npm$styledComponents$ThemeProviderProps = { 19 | theme: 20 | | ((outerTheme: $npm$styledComponents$Theme) => void) 21 | | $npm$styledComponents$Theme, 22 | }; 23 | type $npm$styledComponents$Component = 24 | | React$Component<*, *, *> 25 | | ((props: *) => React$Element<*>); 26 | 27 | class Npm$StyledComponents$ThemeProvider extends React$Component { 28 | props: $npm$styledComponents$ThemeProviderProps; 29 | } 30 | 31 | type $npm$styledComponents$StyleSheetManagerProps = { 32 | sheet: mixed, 33 | }; 34 | 35 | class Npm$StyledComponents$StyleSheetManager extends React$Component { 36 | props: $npm$styledComponents$StyleSheetManagerProps; 37 | } 38 | 39 | class Npm$StyledComponents$ServerStyleSheet { 40 | instance: StyleSheet; 41 | collectStyles: (children: any) => React$Element<*>; 42 | getStyleTags: () => string; 43 | getStyleElement: () => React$Element<*>; 44 | } 45 | 46 | declare module 'styled-components' { 47 | declare type Interpolation = $npm$styledComponents$Interpolation; 48 | declare type NameGenerator = $npm$styledComponents$NameGenerator; 49 | 50 | declare type StyledComponent = $npm$styledComponents$StyledComponent; 51 | 52 | declare type Theme = $npm$styledComponents$Theme; 53 | declare type ThemeProviderProps = $npm$styledComponents$ThemeProviderProps; 54 | declare type Component = $npm$styledComponents$Component; 55 | 56 | declare module.exports: { 57 | injectGlobal: ( 58 | strings: Array, 59 | ...interpolations: Array 60 | ) => void, 61 | css: ( 62 | strings: Array, 63 | ...interpolations: Array 64 | ) => Array, 65 | keyframes: ( 66 | strings: Array, 67 | ...interpolations: Array 68 | ) => string, 69 | withTheme: ( 70 | component: Component 71 | ) => React$Component<*, ThemeProviderProps, *>, 72 | ServerStyleSheet: typeof Npm$StyledComponents$ServerStyleSheet, 73 | StyleSheetManager: typeof Npm$StyledComponents$StyleSheetManager, 74 | ThemeProvider: typeof Npm$StyledComponents$ThemeProvider, 75 | (baseComponent: Component): StyledComponent, 76 | a: StyledComponent, 77 | abbr: StyledComponent, 78 | address: StyledComponent, 79 | area: StyledComponent, 80 | article: StyledComponent, 81 | aside: StyledComponent, 82 | audio: StyledComponent, 83 | b: StyledComponent, 84 | base: StyledComponent, 85 | bdi: StyledComponent, 86 | bdo: StyledComponent, 87 | big: StyledComponent, 88 | blockquote: StyledComponent, 89 | body: StyledComponent, 90 | br: StyledComponent, 91 | button: StyledComponent, 92 | canvas: StyledComponent, 93 | caption: StyledComponent, 94 | cite: StyledComponent, 95 | code: StyledComponent, 96 | col: StyledComponent, 97 | colgroup: StyledComponent, 98 | data: StyledComponent, 99 | datalist: StyledComponent, 100 | dd: StyledComponent, 101 | del: StyledComponent, 102 | details: StyledComponent, 103 | dfn: StyledComponent, 104 | dialog: StyledComponent, 105 | div: StyledComponent, 106 | dl: StyledComponent, 107 | dt: StyledComponent, 108 | em: StyledComponent, 109 | embed: StyledComponent, 110 | fieldset: StyledComponent, 111 | figcaption: StyledComponent, 112 | figure: StyledComponent, 113 | footer: StyledComponent, 114 | form: StyledComponent, 115 | h1: StyledComponent, 116 | h2: StyledComponent, 117 | h3: StyledComponent, 118 | h4: StyledComponent, 119 | h5: StyledComponent, 120 | h6: StyledComponent, 121 | head: StyledComponent, 122 | header: StyledComponent, 123 | hgroup: StyledComponent, 124 | hr: StyledComponent, 125 | html: StyledComponent, 126 | i: StyledComponent, 127 | iframe: StyledComponent, 128 | img: StyledComponent, 129 | input: StyledComponent, 130 | ins: StyledComponent, 131 | kbd: StyledComponent, 132 | keygen: StyledComponent, 133 | label: StyledComponent, 134 | legend: StyledComponent, 135 | li: StyledComponent, 136 | link: StyledComponent, 137 | main: StyledComponent, 138 | map: StyledComponent, 139 | mark: StyledComponent, 140 | menu: StyledComponent, 141 | menuitem: StyledComponent, 142 | meta: StyledComponent, 143 | meter: StyledComponent, 144 | nav: StyledComponent, 145 | noscript: StyledComponent, 146 | object: StyledComponent, 147 | ol: StyledComponent, 148 | optgroup: StyledComponent, 149 | option: StyledComponent, 150 | output: StyledComponent, 151 | p: StyledComponent, 152 | param: StyledComponent, 153 | picture: StyledComponent, 154 | pre: StyledComponent, 155 | progress: StyledComponent, 156 | q: StyledComponent, 157 | rp: StyledComponent, 158 | rt: StyledComponent, 159 | ruby: StyledComponent, 160 | s: StyledComponent, 161 | samp: StyledComponent, 162 | script: StyledComponent, 163 | section: StyledComponent, 164 | select: StyledComponent, 165 | small: StyledComponent, 166 | source: StyledComponent, 167 | span: StyledComponent, 168 | strong: StyledComponent, 169 | style: StyledComponent, 170 | sub: StyledComponent, 171 | summary: StyledComponent, 172 | sup: StyledComponent, 173 | table: StyledComponent, 174 | tbody: StyledComponent, 175 | td: StyledComponent, 176 | textarea: StyledComponent, 177 | tfoot: StyledComponent, 178 | th: StyledComponent, 179 | thead: StyledComponent, 180 | time: StyledComponent, 181 | title: StyledComponent, 182 | tr: StyledComponent, 183 | track: StyledComponent, 184 | u: StyledComponent, 185 | ul: StyledComponent, 186 | var: StyledComponent, 187 | video: StyledComponent, 188 | wbr: StyledComponent, 189 | 190 | // SVG 191 | circle: StyledComponent, 192 | clipPath: StyledComponent, 193 | defs: StyledComponent, 194 | ellipse: StyledComponent, 195 | g: StyledComponent, 196 | image: StyledComponent, 197 | line: StyledComponent, 198 | linearGradient: StyledComponent, 199 | mask: StyledComponent, 200 | path: StyledComponent, 201 | pattern: StyledComponent, 202 | polygon: StyledComponent, 203 | polyline: StyledComponent, 204 | radialGradient: StyledComponent, 205 | rect: StyledComponent, 206 | stop: StyledComponent, 207 | svg: StyledComponent, 208 | text: StyledComponent, 209 | tspan: StyledComponent, 210 | }; 211 | } 212 | 213 | declare module 'styled-components/native' { 214 | declare type Interpolation = $npm$styledComponents$Interpolation; 215 | declare type NameGenerator = $npm$styledComponents$NameGenerator; 216 | 217 | declare type StyledComponent = $npm$styledComponents$StyledComponent; 218 | 219 | declare type Theme = $npm$styledComponents$Theme; 220 | declare type ThemeProviderProps = $npm$styledComponents$ThemeProviderProps; 221 | declare type Component = $npm$styledComponents$Component; 222 | 223 | declare module.exports: { 224 | css: ( 225 | strings: Array, 226 | ...interpolations: Array 227 | ) => Array, 228 | withTheme: ( 229 | component: Component 230 | ) => React$Component<*, ThemeProviderProps, *>, 231 | keyframes: ( 232 | strings: Array, 233 | ...interpolations: Array 234 | ) => string, 235 | ThemeProvider: typeof Npm$StyledComponents$ThemeProvider, 236 | 237 | (baseComponent: Component): StyledComponent, 238 | 239 | ActivityIndicator: StyledComponent, 240 | ActivityIndicatorIOS: StyledComponent, 241 | ART: StyledComponent, 242 | Button: StyledComponent, 243 | DatePickerIOS: StyledComponent, 244 | DrawerLayoutAndroid: StyledComponent, 245 | FlatList: StyledComponent, 246 | Image: StyledComponent, 247 | ImageEditor: StyledComponent, 248 | ImageStore: StyledComponent, 249 | KeyboardAvoidingView: StyledComponent, 250 | ListView: StyledComponent, 251 | MapView: StyledComponent, 252 | Modal: StyledComponent, 253 | Navigator: StyledComponent, 254 | NavigatorIOS: StyledComponent, 255 | Picker: StyledComponent, 256 | PickerIOS: StyledComponent, 257 | ProgressBarAndroid: StyledComponent, 258 | ProgressViewIOS: StyledComponent, 259 | RecyclerViewBackedScrollView: StyledComponent, 260 | RefreshControl: StyledComponent, 261 | ScrollView: StyledComponent, 262 | SectionList: StyledComponent, 263 | SegmentedControlIOS: StyledComponent, 264 | Slider: StyledComponent, 265 | SliderIOS: StyledComponent, 266 | SnapshotViewIOS: StyledComponent, 267 | StatusBar: StyledComponent, 268 | SwipeableListView: StyledComponent, 269 | Switch: StyledComponent, 270 | SwitchAndroid: StyledComponent, 271 | SwitchIOS: StyledComponent, 272 | TabBarIOS: StyledComponent, 273 | Text: StyledComponent, 274 | TextInput: StyledComponent, 275 | ToastAndroid: StyledComponent, 276 | ToolbarAndroid: StyledComponent, 277 | Touchable: StyledComponent, 278 | TouchableHighlight: StyledComponent, 279 | TouchableNativeFeedback: StyledComponent, 280 | TouchableOpacity: StyledComponent, 281 | TouchableWithoutFeedback: StyledComponent, 282 | View: StyledComponent, 283 | ViewPagerAndroid: StyledComponent, 284 | VirtualizedList: StyledComponent, 285 | WebView: StyledComponent, 286 | }; 287 | } 288 | -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | const posts = require('./src/lib/getPosts'); 2 | 3 | const spaceReplace = string => string.replace(/\s+/g, '-').toLowerCase(); 4 | 5 | const getParams = (page, value) => ({ 6 | page: `/${page}`, 7 | query: { [page]: spaceReplace(value) }, 8 | }); 9 | 10 | const buildPagePaths = ( 11 | blogPosts, 12 | defaultRoutes = { 13 | '/': { page: '/' }, 14 | } 15 | ) => 16 | blogPosts.reduce((routes, post) => { 17 | const postRoutes = Object.assign(routes, { 18 | [`post/${post.slug}`]: getParams('post', post.slug), 19 | }); 20 | const tags = post.tags || []; 21 | return tags.reduce( 22 | (acc, tag) => 23 | Object.assign( 24 | { [`tag/${spaceReplace(tag)}`]: getParams('tag', tag) }, 25 | acc 26 | ), 27 | postRoutes 28 | ); 29 | }, defaultRoutes); 30 | 31 | exports.exportPathMap = () => buildPagePaths(posts); 32 | -------------------------------------------------------------------------------- /nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "verbose": false, 3 | "ignore": [ 4 | "node_modules" 5 | ], 6 | "env": { 7 | "NODE_ENV": "development" 8 | }, 9 | "execMap": { 10 | "js": "node" 11 | }, 12 | "ext": ".md", 13 | "watch": "./posts" 14 | } 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "next-static", 3 | "version": "1.1.2", 4 | "description": "A simple static blog powered by next.js", 5 | "main": "index.js", 6 | "repository": "git@github.com:infiniteluke/next-static.git", 7 | "author": "Luke Herrington ", 8 | "license": "MIT", 9 | "scripts": { 10 | "dev": "nodemon ./src/lib/generatePosts & next", 11 | "build": "next build", 12 | "start": "next start", 13 | "export": "next build && next export", 14 | "predeploy": "yarn export && touch out/.nojekyll && echo \"lukeherrington.com\" > out/CNAME", 15 | "deploy": "gh-pages -t -d out", 16 | "lint": "eslint . --fix", 17 | "test": "jest", 18 | "test:watch": "jest --watch", 19 | "test:update": "npm test -- -u", 20 | "flow": "flow", 21 | "precommit": "lint-staged && yarn lint && yarn flow && yarn test" 22 | }, 23 | "dependencies": { 24 | "cheerio": "^1.0.0-rc.2", 25 | "date-fns": "^1.28.5", 26 | "express": "^4.15.3", 27 | "gh-pages": "^1.0.0", 28 | "marked": "^0.3.6", 29 | "next": "beta", 30 | "prismjs": "^1.6.0", 31 | "react": "^15.5.4", 32 | "react-dom": "^15.5.4", 33 | "react-test-renderer": "^15.6.1", 34 | "styled-components": "^2.1.0", 35 | "styled-components-theme": "^1.0.5", 36 | "styled-normalize": "^2.0.0", 37 | "yaml-front-matter": "^3.4.0" 38 | }, 39 | "devDependencies": { 40 | "babel-cli": "^6.26.0", 41 | "babel-core": "^6.25.0", 42 | "babel-eslint": "^7.2.3", 43 | "babel-jest": "^20.0.3", 44 | "babel-plugin-styled-components": "^1.1.7", 45 | "babel-plugin-transform-object-rest-spread": "^6.26.0", 46 | "babel-plugin-transform-runtime": "^6.23.0", 47 | "babel-preset-es2015": "^6.24.1", 48 | "babel-preset-react": "^6.24.1", 49 | "eslint": "3.19.0", 50 | "eslint-config-airbnb": "15.0.1", 51 | "eslint-config-prettier": "2.1.1", 52 | "eslint-plugin-flowtype": "2.34.0", 53 | "eslint-plugin-import": "2.3.0", 54 | "eslint-plugin-jsx-a11y": "5.0.3", 55 | "eslint-plugin-prettier": "2.1.1", 56 | "eslint-plugin-react": "7.0.1", 57 | "flow-bin": "^0.51.1", 58 | "husky": "^0.13.4", 59 | "jest": "^20.0.4", 60 | "lint-staged": "^3.6.1", 61 | "nodemon": "^1.11.0", 62 | "prettier": "^1.4.4", 63 | "watch": "^1.0.2" 64 | }, 65 | "lint-staged": { 66 | "**/*.js": [ 67 | "prettier --single-quote --trailing-comma es5 --write", 68 | "git add" 69 | ] 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /pages/_document.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import React from 'react'; 4 | import Document, { Head, Main, NextScript } from 'next/document'; 5 | import { ServerStyleSheet } from 'styled-components'; 6 | import styledNormalize from 'styled-normalize'; 7 | 8 | export default class MyDocument extends Document { 9 | render() { 10 | const sheet = new ServerStyleSheet(); 11 | const main = sheet.collectStyles(
); 12 | const styleTags = sheet.getStyleElement(); 13 | return ( 14 | 15 | 16 | {styleTags} 17 | 20 | 24 | 25 | 26 |
27 | {main} 28 |
29 | 30 | 34 | 35 | 36 | ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /pages/index.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import React from 'react'; 4 | import Post from '../src/components/Post'; 5 | import Layout from '../src/components/Layout'; 6 | import posts from '../posts'; 7 | 8 | export default Layout( 9 | () => 10 |
11 | {posts.map(post => 12 | 21 | )} 22 |
, 23 | 'Home' 24 | ); 25 | -------------------------------------------------------------------------------- /pages/post.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import React, { type Element } from 'react'; 4 | import Link from 'next/link'; 5 | import Post from '../src/components/Post'; 6 | import posts from '../posts'; 7 | import { type Request } from '../types/request'; 8 | import Layout from '../src/components/Layout'; 9 | 10 | export default Layout(({ url: { query: { post: slug } } }: Request): Element< 11 | * 12 | > => { 13 | const post = posts.find(p => p.slug === slug); 14 | return ( 15 |
16 | 17 | Home 18 | 19 | 27 |
28 | ); 29 | }, 'Post'); 30 | -------------------------------------------------------------------------------- /pages/tag.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import React from 'react'; 4 | import Link from 'next/link'; 5 | import Post from '../src/components/Post'; 6 | import posts from '../posts'; 7 | import { type Request } from '../types/request'; 8 | import Layout from '../src/components/Layout'; 9 | 10 | export default Layout( 11 | ({ url: { query: { tag } } }: Request) => 12 |
13 | 14 | Home 15 | 16 |

17 | {tag} 18 |

19 | {posts 20 | .filter(post => post.tags && post.tags.includes(tag)) 21 | .map(post => 22 | 31 | )} 32 |
, 33 | 'Tag' 34 | ); 35 | -------------------------------------------------------------------------------- /posts/HelloWorld.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: My First Post 3 | slug: hello-world 4 | author: Luke H 5 | date: 2017-6-10 15:00 PDT 6 | tags: 7 | - blog 8 | - first post 9 | --- 10 | ## Hello 11 | This is an _example_ post that has some text that wraps. Simply use markdown to write your posts. 12 | 13 | ## How to add code to a post 14 | Make sure to escape the backticks when writing code in you posts. 15 | 16 | Here's some code: 17 | ```jsx 18 | const a = {props.dope}; 19 | ``` 20 | 21 | ## GFM Supported 22 | Anything that works in Github, works here: 23 | 24 | | First Header | Second Header | 25 | | ------------- | ------------- | 26 | | Content Cell | Content Cell | 27 | | Content Cell | Content Cell | 28 | 29 | > This is a quote. This is a quote. This is a quote. This is a quote. This is a quote. This is a quote. This is a quote. This is a quote. 30 | -------------------------------------------------------------------------------- /posts/NextPost.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: My Next Post 3 | slug: next-post 4 | author: Luke H 5 | date: 2017-6-10 15:26 PDT 6 | tags: 7 | - blog 8 | - 'dad jokes' 9 | --- 10 | ## Puns 11 | _Next_ post. Get it? _Next_? I'll let myself out... 12 | 13 | ```bash 14 | echo $PATH 15 | ``` 16 | -------------------------------------------------------------------------------- /posts/index.js: -------------------------------------------------------------------------------- 1 | export default [ 2 | { 3 | title: 'My First Post', 4 | slug: 'hello-world', 5 | author: 'Luke H', 6 | date: '2017-6-10 15:00 PDT', 7 | tags: ['blog', 'first post'], 8 | body: 9 | "\n## Hello\nThis is an _example_ post that has some text that wraps. Simply use markdown to write your posts.\n\n## How to add code to a post\nMake sure to escape the backticks when writing code in you posts.\n\nHere's some code:\n```jsx\nconst a = {props.dope};\n```\n\n## GFM Supported\nAnything that works in Github, works here:\n\n| First Header | Second Header |\n| ------------- | ------------- |\n| Content Cell | Content Cell |\n| Content Cell | Content Cell |\n\n> This is a quote. This is a quote. This is a quote. This is a quote. This is a quote. This is a quote. This is a quote. This is a quote.\n", 10 | }, 11 | { 12 | title: 'My Next Post', 13 | slug: 'next-post', 14 | author: 'Luke H', 15 | date: '2017-6-10 15:26 PDT', 16 | tags: ['blog', 'dad jokes'], 17 | body: 18 | "\n## Puns\n_Next_ post. Get it? _Next_? I'll let myself out...\n\n```bash\necho $PATH\n```\n", 19 | }, 20 | ]; 21 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const next = require('next'); 3 | 4 | const dev = process.env.NODE_ENV !== 'production'; 5 | const app = next({ dev }); 6 | const handle = app.getRequestHandler(); 7 | 8 | app.prepare().then(() => { 9 | const server = express(); 10 | 11 | // custom route for posts 12 | server.get('/post/:slug', (req, res) => 13 | app.render(req, res, '/post', { 14 | post: req.params.slug, 15 | }) 16 | ); 17 | // custom route for tags 18 | server.get('/tag/:slug', (req, res) => 19 | app.render(req, res, '/tag', { 20 | tag: req.params.slug, 21 | }) 22 | ); 23 | 24 | server.get('*', (req, res) => handle(req, res)); 25 | 26 | server.listen(3000, err => { 27 | if (err) throw err; 28 | console.log('> Ready on http://localhost:3000'); // eslint-disable-line no-console 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /src/components/Footer/__snapshots__/test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`Snapshot::