Skip to content

Instantly share code, notes, and snippets.

View .babelrc
"presets": ["env"]
elmasse / index.js
Last active Jul 2, 2018
View index.js
const fetch = require('isomorphic-fetch')
const fm = require('frontmatter')
const { readFileSync, statSync } = require('fs')
const { resolve, basename, extname, relative, dirname, sep } = require('path')
const pathToRegEx = require('path-to-regexp')
const parser = require('./parser')
module.exports = {
source : async ({ extension = 'md', entriesDir = ['posts'], remark = [], rehype = [] } = {}) => {
elmasse / post-list-entry.js
Last active May 5, 2018
PostList for nextein 1.3.0-beta.4
View post-list-entry.js
import React from 'react'
import Link from 'nextein/link'
import { Content } from 'nextein/post'
const countWords = (s) => {
s = s.replace(/(^\s*)|(\s*$)/gi,"");//exclude start and end white-space
s = s.replace(/[ ]{2,}/gi," ");//2 or more space to 1
s = s.replace(/\n /,"\n"); // exclude newline with a start spacing

Keybase proof

I hereby claim:

  • I am elmasse on github.
  • I am elmasse ( on keybase.
  • I have a public key ASBwebycwQP2p7sgVTrnn8kRBI-Ec4oCraSrIxbv9u_kNQo

To claim this, I am signing this object:

elmasse / components-page-transitions.js
Created Feb 6, 2018
Exploring Next animated transitions
View components-page-transitions.js
import React, { Component } from 'react'
import Router from 'next/router'
import { parse, format } from 'url'
import raf from 'raf'
Router.ready(function() {
// monkey patching Router.router
const router = Router.router
if (!router.__patched) {
const _change = router.change
View Date.toLocaleString
new Date(, format.options)
Use toLocaleDateString();
The toLocaleDateString() method returns a string with a language-sensitive representation of the date portion of the date. The locales and options arguments let applications specify the language whose formatting conventions should be used and allow to customize the behavior of the function.
The values you can passed in options for different keys:
The representation of the day.
elmasse / next.config.js
Created Sep 23, 2017
nextein: custom routes
View next.config.js
const nexteinConfig = require('nextein/config').default
const stories = ['food', 'cars'].reduce( (prev, entry) => ({
[`/${entry}`]: { page: '/stories', query: { category: `stories/${entry}` } }
}), {})
module.exports = nexteinConfig({
exportPathMap: () => ({
'/all-posts': { page: '/all-posts' },
elmasse /
Created Jul 24, 2017 — forked from cobyism/
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

elmasse / -components-header.js
Created Jun 27, 2017
next issue with safari
View -components-header.js
import Link from 'next/link'
const Header = () => (
<Link href='/'>
<Link href='/about'>
elmasse / webtask.js
Last active Apr 13, 2017
webtaks slack bot npm stats
View webtask.js
'use latest';
const express = require('express');
const request = require('request');
const moment = require('moment');
const { fromExpress } = require('webtask-tools');
const app = express();
You can’t perform that action at this time.