Skip to content

Instantly share code, notes, and snippets.

View danilowoz's full-sized avatar

Danilo Woznica danilowoz

View GitHub Profile
Schrödinger’s commit. 50% chance we fixed the bug
i tried my best
Please don't tell anyone I did this
Check the changes for yourself
Works on my machine
@danilowoz
danilowoz / git alias
Last active December 13, 2018 12:18
Alias gist
# .gitconfig
[user]
email = danilowoz@gmail.com
[alias]
st = status
ci = commit
br = branch
co = checkout
up = "!git remote update -p; git merge --ff-only @{u}"
emenda = commit --amend --no-edit
import * as React from 'react'
interface IState {
offSet: number
}
interface IProp {
force?: number
offsetComp?: number
children(offSet: number): React.ReactNode
import React, { Component } from "react"
import VisibilitySensor from "react-visibility-sensor"
const optsVisibily = {
minTopValue: 400,
partialVisibility: true,
scrollDelay: 100
}
const WithScroll = WrapComponent =>
.container {
display: flex;
flex-flow: column wrap;
align-content: space-between;
/* Your container needs a fixed height, and it
* needs to be taller than your tallest column. */
height: 600px;
}
.item {
@danilowoz
danilowoz / 1-gatsby-node.js
Last active April 28, 2019 19:10
Creating the pages programmatically
const { createFilePath } = require(`gatsby-source-filesystem`)
exports.onCreateNode = ({ node, actions, getNode }) => {
const { createNodeField } = actions
if (node.internal.type === `MarkdownRemark`) {
const value = createFilePath({ node, getNode })
const [month, day, year] = new Date(node.frontmatter.date)
.toLocaleDateString("en-EN", {
year: "numeric",
@danilowoz
danilowoz / 1.1-gatsby-node.js
Created April 28, 2019 19:12
Creating the pages programmatically
const path = require(`path`)
// 1. This is called once the data layer is bootstrapped to let plugins create pages from data.
exports.createPages = ({ graphql, actions }) => {
// 1.1 Getting the method to create pages
const { createPage } = actions
// 1.2 Tell which layout Gatsby should use to thse pages
const blogLayout = path.resolve(`./src/layouts/blog-post.js`)
// 2 Return the method with the query
@danilowoz
danilowoz / 2-blog-post.js
Created April 28, 2019 19:13
Creating programmatically the pages
import React from "react"
import { graphql } from "gatsby"
const BlogPost = ({ data }) => {
const { markdownRemark } = data
const imageSource = markdownRemark.frontmatter.image.childImageSharp.fluid.src
return (
<>
<img src={imageSource} alt={markdownRemark.frontmatter.title} />
@danilowoz
danilowoz / 2.2-gatsby-node.js
Last active April 28, 2019 19:19
Creating a blog post list page
Array.from({ length: numPages }).forEach((_, i) => {
createPage({
path: i === 0 ? `/blog` : `/blog/page/${i + 1}`,
component: blogListLayout,
context: {
limit: postsPerPage,
skip: i * postsPerPage,
currentPage: i + 1,
numPages,
},
@danilowoz
danilowoz / 2.1-gatsby-node.js
Last active April 28, 2019 19:19
Creating a blog post list page
const postsPerPage = 9
const postsWithoutFeatured = posts.filter(({ node }) => {
return !node.frontmatter.featured
})
const numPages = Math.ceil(postsWithoutFeatured.length / postsPerPage)