Skip to content

Instantly share code, notes, and snippets.

🚀
Making things happen

Stoyan Merdzhanov SMerdzhanov

  • Konstanz, Germany
View GitHub Profile
@SMerdzhanov
SMerdzhanov / index.js
Last active Sep 14, 2018
Q: How to pass down the `seoImage` from page to seo component avoiding Gatsby's automatic to-data-URI conversion for images < 10kb?
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 = () => (
<Layout>
@SMerdzhanov
SMerdzhanov / notes_030217.md
Created Feb 6, 2017
Notes for meeting 03.02.17, including "Exercise 3: Solution"
View notes_030217.md

Prototype

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);
You can’t perform that action at this time.