From a88aecb93f505af84b78a0c412ad93b9e6f7240b Mon Sep 17 00:00:00 2001 From: benjaminramey Date: Wed, 30 Sep 2020 20:56:39 -0500 Subject: [PATCH] title and archive page --- gatsby-config.js | 1 + gatsby-node.js | 13 ++++++++++ package-lock.json | 31 ++++++++++++++++++++++ package.json | 4 ++- src/components/layout.js | 4 +++ src/components/nav.js | 10 +++---- src/pages/archive.js | 56 ++++++++++++++++++++++++++++++++++++++++ src/pages/index.js | 4 --- src/templates/post.js | 8 +++--- 9 files changed, 116 insertions(+), 15 deletions(-) create mode 100644 src/pages/archive.js diff --git a/gatsby-config.js b/gatsby-config.js index eaf4046..9faac0b 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -11,6 +11,7 @@ module.exports = { tagline: `Scripture, programming problems, solutions and stories.` }, plugins: [ + `gatsby-plugin-react-helmet`, `gatsby-plugin-sass`, { resolve: `gatsby-source-filesystem`, diff --git a/gatsby-node.js b/gatsby-node.js index c1b57ee..bfcbebc 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -6,11 +6,24 @@ exports.onCreateNode = ({ node, getNode, actions }) => { if (node.internal.type === `MarkdownRemark`) { var slug = createFilePath({ node, getNode, basePath: `pages` }); + var date = new Date(node.frontmatter.date); + var year = date.getFullYear(); + var month = date.getMonth(); createNodeField({ node, name: `slug`, value: slug, }); + createNodeField({ + node, + name: `year`, + value: year, + }); + createNodeField({ + node, + name: `month`, + value: month, + }); } }; diff --git a/package-lock.json b/package-lock.json index 48414d4..826a624 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8644,6 +8644,14 @@ } } }, + "gatsby-plugin-react-helmet": { + "version": "3.3.12", + "resolved": "https://registry.npmjs.org/gatsby-plugin-react-helmet/-/gatsby-plugin-react-helmet-3.3.12.tgz", + "integrity": "sha512-dRIi2RLUhO+R1OaG7TrI9k1xOPf0xDQZHx1tMIcwXEm3LWS+zwv0uX+RpyQ2lQE0L/NNhjfm253CAlcEBVN4ww==", + "requires": { + "@babel/runtime": "^7.11.2" + } + }, "gatsby-plugin-sass": { "version": "2.3.13", "resolved": "https://registry.npmjs.org/gatsby-plugin-sass/-/gatsby-plugin-sass-2.3.13.tgz", @@ -15379,6 +15387,24 @@ "use-sidecar": "^1.0.1" } }, + "react-helmet": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/react-helmet/-/react-helmet-6.1.0.tgz", + "integrity": "sha512-4uMzEY9nlDlgxr61NL3XbKRy1hEkXmKNXhjbAIOVw5vcFrsdYbH2FEwcNyWvWinl103nXgzYNlns9ca+8kFiWw==", + "requires": { + "object-assign": "^4.1.1", + "prop-types": "^15.7.2", + "react-fast-compare": "^3.1.1", + "react-side-effect": "^2.1.0" + }, + "dependencies": { + "react-fast-compare": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.0.tgz", + "integrity": "sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA==" + } + } + }, "react-hot-loader": { "version": "4.12.21", "resolved": "https://registry.npmjs.org/react-hot-loader/-/react-hot-loader-4.12.21.tgz", @@ -15456,6 +15482,11 @@ "tslib": "^1.0.0" } }, + "react-side-effect": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/react-side-effect/-/react-side-effect-2.1.0.tgz", + "integrity": "sha512-IgmcegOSi5SNX+2Snh1vqmF0Vg/CbkycU9XZbOHJlZ6kMzTmi3yc254oB1WCkgA7OQtIAoLmcSFuHTc/tlcqXg==" + }, "react-style-singleton": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/react-style-singleton/-/react-style-singleton-2.1.0.tgz", diff --git a/package.json b/package.json index 551e162..2d2b6d8 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "disqus-react": "^1.0.10", "gatsby": "^2.24.61", "gatsby-image": "^2.4.19", + "gatsby-plugin-react-helmet": "^3.3.12", "gatsby-plugin-sass": "^2.3.13", "gatsby-plugin-sharp": "^2.6.36", "gatsby-remark-images": "^3.3.30", @@ -27,7 +28,8 @@ "node-sass": "^4.14.1", "prismjs": "^1.21.0", "react": "^16.12.0", - "react-dom": "^16.12.0" + "react-dom": "^16.12.0", + "react-helmet": "^6.1.0" }, "devDependencies": { "bootstrap": "^4.5.2", diff --git a/src/components/layout.js b/src/components/layout.js index 4875ddd..0ad9ae6 100644 --- a/src/components/layout.js +++ b/src/components/layout.js @@ -1,4 +1,5 @@ import React from "react"; +import { Helmet } from "react-helmet"; import Header from './header'; import Footer from './footer'; import Nav from './nav'; @@ -6,6 +7,9 @@ import Nav from './nav'; export default function Layout({ title, tagline, children }) { return (
+ + {title} - {tagline} +