This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const blogCategoryLayout = path.resolve(`./src/layouts/blog-category.js`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react" | |
import { graphql, Link } from "gatsby" | |
const BlogPostList = ({ data, pageContext }) => { | |
const { allMarkdownRemark } = data | |
return ( | |
<> | |
{allMarkdownRemark.edges.map(({ node }) => { | |
const imageSource = node.frontmatter.image.childImageSharp.fluid.src |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const postsPerPage = 9 | |
const postsWithoutFeatured = posts.filter(({ node }) => { | |
return !node.frontmatter.featured | |
}) | |
const numPages = Math.ceil(postsWithoutFeatured.length / postsPerPage) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const blogListLayout = path.resolve(`./src/layouts/blog-list.js`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react' | |
interface IState { | |
offSet: number | |
} | |
interface IProp { | |
force?: number | |
offsetComp?: number | |
children(offSet: number): React.ReactNode |