Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Commit

Permalink
💥
Browse files Browse the repository at this point in the history
  • Loading branch information
MoOx committed Sep 3, 2015
0 parents commit 82b5ca6
Show file tree
Hide file tree
Showing 49 changed files with 1,783 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stage": 0
}
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# editorconfig.org
root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.md]
# Allow <br/> from Markdown
trim_trailing_whitespace = false
78 changes: 78 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
root: true
extends: eslint:recommended

# babel-eslint support more syntax stuff than eslint for now
parser: babel-eslint

ecmaFeatures:
modules: true
jsx: true

env:
es6: true
browser: true
node: true

globals:
__DEV__: true
__DEVTOOLS__: true
__DEVSERVER__: true
__PROD__: true
__SERVER_PROTOCOL__: true
__SERVER_HOSTNAME__: true
__SERVER_PORT__: true
__SERVER_HOST__: true
__SERVER_URL__: true

plugins:
- react

# 0: off, 1: warning, 2: error
rules:
no-console: 0

indent: [2, 2] # 2 spaces indentation
max-len: [2, 80, 4]
quotes: [2, "double"]
semi: [2, "never"]
no-multiple-empty-lines: [2, {"max": 1}]

brace-style: [2, "stroustrup"]
comma-dangle: [2, "always-multiline"]
comma-style: [2, "last"]
dot-location: [2, "property"]

one-var: [2, "never"]
no-var: [2]
prefer-const: [2]
no-bitwise: [2]

object-curly-spacing: [2, "always"]
array-bracket-spacing: [2, "always"]
#computed-property-spacing: [2, "always"]

space-unary-ops: [2, {"words": true, "nonwords": false}]
space-after-keywords: [2, "always"]
space-before-blocks: [2, "always"]
space-before-function-paren: [2, "never"]
space-in-parens: [2, "never"]
spaced-comment: [2, "always"]

# eslint-plugin-react rules
react/jsx-boolean-value: 2
react/jsx-no-undef: 2
react/jsx-quotes: 2
#react/jsx-sort-prop-types: 2
#react/jsx-sort-props: 2
react/jsx-uses-react: 2
react/jsx-uses-vars: 2
react/no-did-mount-set-state: 2
react/no-did-update-set-state: 2
react/no-multi-comp: 2
react/no-unknown-property: 2
react/prop-types: 2
react/react-in-jsx-scope: 2
react/self-closing-comp: 2
react/sort-comp: 2
react/wrap-multilines: 2
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# build
lib

# demo build
dist
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: nodejs
nodejs:
- iojs
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 0.0.0

No release has been made yet. Everything is highly subject to changes.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Maxime Thirouin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# statinamic

> A static website generator that create dynamic website using React components.
![Travis Build Badge](https://img.shields.io/travis/MoOx/statinamic/master.svg)

## Install

```console
$ npm install MoOx/statinamic
```

## Usage

See [demo](demo) for now.

```console
$ npm install

# static build
$ npm test

# live demo
$ npm run demo
```

---

## Contributing

* ⇄ Pull requests and ★ stars are always welcome.
* For bugs and feature requests, please create an issue.
* Pull requests that modifies code must be accompanied with automated tests.
* Run `$ npm test` before making a pull request.

## [CHANGELOG](CHANGELOG.md)

## [LICENSE](LICENSE)
168 changes: 168 additions & 0 deletions demo/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
import path from "path"
import webpack from "webpack"
import ExtractTextPlugin from "extract-text-webpack-plugin"

import markdownIt from "markdown-it"
import markdownItTocAndAnchor from "markdown-it-toc-and-anchor"
import hljs from "highlight.js"

import pkg from "./package.json"

import routes from "app/routes"
// import * as reducers from "app/ducks"
import * as pageComponents from "app/pageComponents"
// instead of using the collection.json that has been made in during build
// we directly use the module cache responsible of the build, since it's still
// in memory. This avoid us a fs read + handling some potential async issues
// (since the collection.json is made by a plugin _after_ the build)
import collection from "statinamic/lib/json-collection-loader/cache"

import build from "statinamic/lib/build"
import configurator from "statinamic/lib/configurator"
import jsonCollectionPlugin from
"statinamic/lib/json-collection-loader/plugin"

const config = configurator(pkg)

const root = path.join(__dirname)
const source = path.join(root, "content")
const dest = path.join(root, "dist")

build({
config,
source,
dest,

exports: {
routes,
initialState: {
pageComponents,
collection,
},
},

webpack: {
entry: {
index: [
path.join(__dirname, "client"),
],
},

output: {
path: dest,
filename: "[name].js",
publicPath: "/",
},

resolve: {
extensions: [
// node default extensions
".js",
".json",
// for all other extensions specified directly
"",
],
},

module: {
// ! \\ note that loaders are executed from bottom to top !
loaders: [
//
// statinamic requirement
//
{
test: /\.md$/,
loaders: [
`file?name=[path][name]/index.json&context=${ source }`,
"statinamic/lib/json-collection-loader",
"statinamic/lib/markdown-as-json-loader",
],
},
{
test: /\.json$/,
loaders: [
"json",
],
},

// your loaders
{
test: /\.js$/,
loaders: [
...config.__DEV__ && [ "react-hot" ],
"babel",
...config.__DEV__ && [ "eslint" ],
],
exclude: /node_modules/,
},
],
},

plugins: [
//
// statinamic requirement
//
jsonCollectionPlugin({
filename: "collection.json",
}),

// your plugins
new webpack.DefinePlugin(
// transform string as "string" so hardcoded replacements are
// syntaxically correct
Object.keys(config).reduce((obj, constName) => {
const value = config[constName]
return {
...obj,
[constName]: (
typeof value === "string" ? JSON.stringify(value) : value
),
}
}, {})
),
new ExtractTextPlugin("[name].css", { disable: !config.__PROD__ }),
...config.__PROD__ && [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
}),
],
],

node: {
// https://github.com/webpack/webpack/issues/451
// run tape test with webpack
fs: "empty",
},

markdownIt: (
markdownIt({
html: true,
linkify: true,
typographer: true,
highlight: (code, lang) => {
code = code.trim()
// language is recognized by highlight.js
if (lang && hljs.getLanguage(lang)) {
return hljs.highlight(lang, code).value
}
// ...or fallback to auto
return hljs.highlightAuto(code).value
},
})
.use(markdownItTocAndAnchor, {
tocFirstLevel: 2,
})
),

jsonCollection: {
urlify: (url) => url
// .replace(/^content\//, "")
.replace(/^demo\/content\//, "")
.replace(/\.md$/, "")
,
},
},
})
22 changes: 22 additions & 0 deletions demo/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import statinamic from "statinamic/lib/client"

import routes from "app/routes"
// import * as reducers from "app/ducks"
import * as pageComponents from "app/pageComponents"

// dev index
if (__DEV__) {
require("!!file?name=index.html!statinamic/lib/dev-index.html")
}

// all md files as JSON + generate collections
require.context("./content", true, /\.md$/)

statinamic({
routes,
// reducers,
initialState: {
...window.__INITIAL_STATE__,
pageComponents,
},
})
6 changes: 6 additions & 0 deletions demo/content/blog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Blog
layout: Collection
---

Here is a list of posts. Below are other pages.
7 changes: 7 additions & 0 deletions demo/content/blog/react.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: React blog post
layout: Post
date: 2015-08-20
---

That's cool yo.
11 changes: 11 additions & 0 deletions demo/content/blog/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: TeStInG
layout: Post
date: 2015-01-02
---

This is a **post**.

## Hell yeah

You feel the nice platform, do you?
5 changes: 5 additions & 0 deletions demo/content/contact.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Contact
---

Mail yo.
Loading

0 comments on commit 82b5ca6

Please sign in to comment.