-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
93 changed files
with
371 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// This file is not going through babel transformation. | ||
// So, we write it in vanilla JS | ||
// (But you could use ES2015 features supported by your Node.js version) | ||
|
||
module.exports = { | ||
webpack: (config, { dev }) => { | ||
// Perform customizations to config | ||
config = Object.assign( | ||
config, | ||
{ | ||
target: "node" | ||
} | ||
) | ||
|
||
// Important: return the modified config | ||
return config | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"scripts": { | ||
"dev": "node server.js", | ||
"build": "next build", | ||
"start": "NODE_ENV=production node server.js" | ||
}, | ||
"dependencies": { | ||
"autoprefixer": "^6.7.2", | ||
"front-matter": "^2.1.2", | ||
"katex": "^0.7.1", | ||
"markdown-it": "^8.2.2", | ||
"markdown-it-highlightjs": "^2.0.0", | ||
"markdown-it-katex": "^2.0.3", | ||
"next": "^2.0.0-beta", | ||
"path-match": "1.2.4", | ||
"postcss-cssnext": "^2.9.0", | ||
"react-katex": "^1.0.1", | ||
"styled-jsx-postcss": "^0.1.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react' | ||
import Link from 'next/link' | ||
import fs from 'fs' | ||
import frontMatter from 'front-matter' | ||
|
||
import { getArticles } from '../utils/utils' | ||
|
||
export default class extends React.Component { | ||
static async getInitialProps () { | ||
|
||
return getArticles('./static/articles/').then((articles) => { | ||
const linkParams = articles.nameList.map((articleName, i) => { | ||
const content = fs.readFileSync(articles.pathList[i], 'utf-8') | ||
const meta = frontMatter(content) | ||
return { | ||
name: articleName, | ||
title: meta.attributes.title, | ||
date: meta.attributes.date, | ||
} | ||
}) | ||
return { | ||
linkParams: linkParams | ||
} | ||
}) | ||
} | ||
|
||
render () { | ||
return ( | ||
<div> | ||
|
||
<ul className='articles'> | ||
{ | ||
this.props.linkParams.map((el, i) => { | ||
return <li className='article-list'> | ||
<Link href={'/article?name='+el.name} as={'/article/'+el.name}><a> | ||
<p className='article-title'>{el.title}</p> | ||
<p className='article-date'>{el.date}</p> | ||
</a></Link> | ||
</li> | ||
}) | ||
} | ||
</ul> | ||
|
||
</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import Head from 'next/head' | ||
import Link from 'next/link' | ||
import React from 'react' | ||
import fs from 'fs' | ||
import frontMatter from 'front-matter' | ||
const md = require('markdown-it')({ | ||
html: true | ||
}) | ||
.use(require('markdown-it-highlightjs')) | ||
.use(require('markdown-it-katex')) | ||
|
||
export default class extends React.Component { | ||
static async getInitialProps ({ query: { fname } }) { | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(fname, 'utf-8', (error, content) => { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
resolve(content) | ||
} | ||
}) | ||
}).then((content) => { | ||
const meta = frontMatter(content) | ||
// const body = md.render(meta.body) | ||
|
||
return { | ||
title: meta.attributes.title, | ||
bodytxt: meta.body | ||
} | ||
}) | ||
} | ||
|
||
render () { | ||
|
||
return <div> | ||
<Head> | ||
<title>{this.props.title}</title> | ||
<link rel="stylesheet" type="text/css" href="/static/css/paraiso-light.css" media="screen" /> | ||
<link rel="stylesheet" type="text/css" href="/static/css/katex.min.css" media="screen" /> | ||
</Head> | ||
|
||
<main> | ||
<div dangerouslySetInnerHTML={{__html: md.render(this.props.bodytxt)}} /> | ||
</main> | ||
|
||
</div> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Link from 'next/link' | ||
|
||
export default () => ( | ||
<ul> | ||
<li><Link href='/'><a>Home</a></Link></li> | ||
<li><Link href='/article'><a>Articles</a></Link></li> | ||
</ul> | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = () => ({ | ||
plugins: { | ||
'postcss-cssnext': {}, | ||
require('autoprefixer') | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const { createServer } = require('http') | ||
const { parse } = require('url') | ||
const next = require('next') | ||
const pathMatch = require('path-match') | ||
|
||
const fs = require('fs') | ||
|
||
const dev = process.env.NODE_ENV !== 'production' | ||
const app = next({ dev }) | ||
const handle = app.getRequestHandler() | ||
const route = pathMatch() | ||
const match = route('/article/:name') | ||
|
||
const files = fs.readdirSync('./static/articles').reverse() | ||
const articleList = files.map( el => './static/articles/' + el ) | ||
const articleNameList = files.map( el => el.slice(4, -3) ) | ||
|
||
app.prepare() | ||
.then(() => { | ||
createServer((req, res) => { | ||
const { pathname } = parse(req.url) | ||
const params = match(pathname) | ||
|
||
// /article を /article-root につけかえ | ||
if ( route('/article')(pathname) ) { | ||
app.render(req, res, '/article-root') | ||
return | ||
} | ||
|
||
// 通常のレンダリング | ||
if (params === false) { | ||
handle(req, res) | ||
return | ||
} | ||
|
||
const articleIndex = articleNameList.indexOf(params.name) | ||
|
||
// ファイルが見つからない場合は 404 | ||
if (articleIndex === -1) { | ||
app.render(req, res, '/404') | ||
return | ||
} | ||
|
||
// /article のレンダリング | ||
const fname = articleList[articleIndex] | ||
app.render(req, res, '/article', { fname }) | ||
}) | ||
.listen(3000, (err) => { | ||
if (err) throw err | ||
console.log('> Ready on http://localhost:3000') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
title: ブログサンプル | ||
date: 2017.02.11 | ||
--- | ||
|
||
Markdownレンダリング用サンプルファイル。 | ||
|
||
### 数式 | ||
|
||
$$ | ||
f(x) = \int_{-\infty}^\infty \hat{f} (\xi)\,e^{2 \pi i \xi x} \,d\xi | ||
$$ | ||
|
||
### コード | ||
|
||
```js | ||
function $initHighlight(block, cls) { | ||
try { | ||
if (cls.search(/\bno\-highlight\b/) != -1) | ||
return process(block, true, 0x0F) + | ||
` class="${cls}"`; | ||
} catch (e) { | ||
/* handle exception */ | ||
} | ||
for (var i = 0 / 2; i < classes.length; i++) { | ||
if (checkCondition(classes[i]) === undefined) | ||
console.log('undefined'); | ||
} | ||
} | ||
|
||
export $initHighlight; | ||
``` | ||
|
||
### はてなブログカード | ||
|
||
<iframe class="hatenablogcard" style="width:100%;height:155px;margin:15px 0;max-width:500px;" title="はてなブログカードのような美しい外部リンクをクリック一発で作成する方法" src="https://hatenablog-parts.com/embed?url=https://nelog.jp/hatenablogcard" frameborder="0" scrolling="no"></iframe> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* Tomorrow Night Eighties Theme */ | ||
/* Original theme - https://github.com/chriskempson/tomorrow-theme */ | ||
/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ | ||
.tomorrow-comment, pre .comment, pre .title { | ||
color: #999999; | ||
} | ||
|
||
.tomorrow-red, pre .variable, pre .attribute, pre .tag, pre .regexp, pre .ruby .constant, pre .xml .tag .title, pre .xml .pi, pre .xml .doctype, pre .html .doctype, pre .css .id, pre .css .class, pre .css .pseudo { | ||
color: #f2777a; | ||
} | ||
|
||
.tomorrow-orange, pre .number, pre .preprocessor, pre .built_in, pre .literal, pre .params, pre .constant { | ||
color: #f99157; | ||
} | ||
|
||
.tomorrow-yellow, pre .class, pre .ruby .class .title, pre .css .rules .attribute { | ||
color: #ffcc66; | ||
} | ||
|
||
.tomorrow-green, pre .string, pre .value, pre .inheritance, pre .header, pre .ruby .symbol, pre .xml .cdata { | ||
color: #99cc99; | ||
} | ||
|
||
.tomorrow-aqua, pre .css .hexcolor { | ||
color: #66cccc; | ||
} | ||
|
||
.tomorrow-blue, pre .function, pre .python .decorator, pre .python .title, pre .ruby .function .title, pre .ruby .title .keyword, pre .perl .sub, pre .javascript .title, pre .coffeescript .title { | ||
color: #6699cc; | ||
} | ||
|
||
.tomorrow-purple, pre .keyword, pre .javascript .function { | ||
color: #cc99cc; | ||
} | ||
|
||
pre code { | ||
display: block; | ||
background: #2d2d2d; | ||
color: #cccccc; | ||
font-family: Menlo, Monaco, Consolas, monospace; | ||
line-height: 1.5; | ||
border: 1px solid #ccc; | ||
padding: 10px; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
Paraíso (light) | ||
Created by Jan T. Sott (http://github.com/idleberg) | ||
Inspired by the art of Rubens LP (http://www.rubenslp.com.br) | ||
*/ | ||
|
||
/* Paraíso Comment */ | ||
.hljs-comment, | ||
.hljs-quote { | ||
color: #776e71; | ||
} | ||
|
||
/* Paraíso Red */ | ||
.hljs-variable, | ||
.hljs-template-variable, | ||
.hljs-tag, | ||
.hljs-name, | ||
.hljs-selector-id, | ||
.hljs-selector-class, | ||
.hljs-regexp, | ||
.hljs-link, | ||
.hljs-meta { | ||
color: #ef6155; | ||
} | ||
|
||
/* Paraíso Orange */ | ||
.hljs-number, | ||
.hljs-built_in, | ||
.hljs-builtin-name, | ||
.hljs-literal, | ||
.hljs-type, | ||
.hljs-params, | ||
.hljs-deletion { | ||
color: #f99b15; | ||
} | ||
|
||
/* Paraíso Yellow */ | ||
.hljs-title, | ||
.hljs-section, | ||
.hljs-attribute { | ||
color: #fec418; | ||
} | ||
|
||
/* Paraíso Green */ | ||
.hljs-string, | ||
.hljs-symbol, | ||
.hljs-bullet, | ||
.hljs-addition { | ||
color: #48b685; | ||
} | ||
|
||
/* Paraíso Purple */ | ||
.hljs-keyword, | ||
.hljs-selector-tag { | ||
color: #815ba4; | ||
} | ||
|
||
.hljs { | ||
display: block; | ||
overflow-x: auto; | ||
background: #e7e9db; | ||
color: #4f424c; | ||
padding: 0.5em; | ||
} | ||
|
||
.hljs-emphasis { | ||
font-style: italic; | ||
} | ||
|
||
.hljs-strong { | ||
font-weight: bold; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import yaml from 'js-yaml' | ||
|
||
export async function getArticles (dirname) { | ||
return new Promise((resolve, reject) => { | ||
fs.readdir(dirname, (error, files) => { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
files.reverse() | ||
resolve({ | ||
pathList: files.map( el => dirname + el ), | ||
nameList: files.map( el => el.slice(4, -3) ) | ||
}) | ||
} | ||
}) | ||
}) | ||
} |