Instantly share code, notes, and snippets.

View index.js
// Page component index.js
import React from 'react';
import Layout from '../components/layout/layout';
import Seo from '../components/seo/seo';
import seoImage from '../images/social.png'; // because this image is < 10kb it gets converted to data:base64... which doesn't work for <meta> tags
const IndexPage = () => (


Every single "object" is built by a constructor function (constructor call)

A constructor makes an object linked to its own prototype (it's linked not "based", because "based" sounds a bit like inheritance or classes which is not the case in JS)

// Foo will be called as constructor -> Foo has a property '.prototype' -> .prototype is an object
Foo -> Foo.prototype -> prototype {}
View course.js
// Add the dependencies as function params
exports = module.exports = function(bookshelf, CourseSeo) {
var Course = bookshelf.Model.extend({
tableName: 'courses',
seo_keywords: function() {
return this.hasMany(CourseSeo, 'course_id')
initialize: function() {
this.on('saving', this.handleLectures, this);
this.on('saving', this.handleSeo, this);