Skip to content

Instantly share code, notes, and snippets.

View elmasse's full-sized avatar

Masse Fierro elmasse

View GitHub Profile
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
@elmasse
elmasse / .babelrc
Created July 10, 2018 17:48
build-test
{
"presets": ["env"]
}
@elmasse
elmasse / index.js
Last active July 2, 2018 22:22
nextein-plugin-markdown-from-git
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
elmasse / post-list-entry.js
Last active May 5, 2018 00:09
PostList for nextein 1.3.0-beta.4
//nextein-example/components/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
@elmasse
elmasse / Keybase.md
Created April 27, 2018 23:46
Keybase.md

Keybase proof

I hereby claim:

  • I am elmasse on github.
  • I am elmasse (https://keybase.io/elmasse) on keybase.
  • I have a public key ASBwebycwQP2p7sgVTrnn8kRBI-Ec4oCraSrIxbv9u_kNQo

To claim this, I am signing this object:

@elmasse
elmasse / components-page-transitions.js
Created February 6, 2018 12:32
Exploring Next animated transitions
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
new Date(post.data.date).toLocaleString(format.locale, 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:
day:
The representation of the day.
@elmasse
elmasse / next.config.js
Created September 23, 2017 01:57
nextein: custom routes
const nexteinConfig = require('nextein/config').default
const stories = ['food', 'cars'].reduce( (prev, entry) => ({
...prev,
[`/${entry}`]: { page: '/stories', query: { category: `stories/${entry}` } }
}), {})
module.exports = nexteinConfig({
exportPathMap: () => ({
'/all-posts': { page: '/all-posts' },
@elmasse
elmasse / gh-pages-deploy.md
Created July 24, 2017 15:07 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

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
elmasse / -components-header.js
Created June 27, 2017 22:05
next issue with safari
import Link from 'next/link'
const Header = () => (
<div>
<Link href='/'>
<a>Home</a>
</Link>
<Link href='/about'>
<a>About</a>
</Link>