From ac65e6c1b28231bbdf0061b35c2a0670b813931c Mon Sep 17 00:00:00 2001 From: panzerstadt Date: Thu, 23 Feb 2023 19:48:18 +0900 Subject: [PATCH 1/2] add disqus as an opt-in plugin for theme users --- README.md | 8 ++++++++ packages/gatsby-theme-pitayan/gatsby-config.js | 13 +++++++++++++ packages/gatsby-theme-pitayan/package.json | 1 + .../src/templates/post/index.tsx | 12 ++++++++++++ packages/www/package.json | 1 + 5 files changed, 35 insertions(+) diff --git a/README.md b/README.md index d28aa3b..9fe8dd3 100644 --- a/README.md +++ b/README.md @@ -422,6 +422,14 @@ This theme introduces some custom events to allow 3rd party scripts (or your own Making sure all functions across different browsers is a hard-work. For now, it only supports the latest version of the major browsers. Do consider open an issue or provide a PR relating to browser compatibility. +## DISQUS + +adding disqus to your website is easy through this plugin. here are the steps: + +- if you haven't already, create an `.env.` file for the environments you need. for example, on local development environment, create a file called `.env.development` +- add a variable `DISQUS_SHORTNAME=` to the .env file +- start your gatsby website. + # Contribute This project is a [Monorepo](https://en.wikipedia.org/wiki/Monorepo). Which uses `npm` as package manager. As long as the Node supports npm workspaces then it should fit the contributing prerequisites. diff --git a/packages/gatsby-theme-pitayan/gatsby-config.js b/packages/gatsby-theme-pitayan/gatsby-config.js index 9e43f5f..25dc587 100644 --- a/packages/gatsby-theme-pitayan/gatsby-config.js +++ b/packages/gatsby-theme-pitayan/gatsby-config.js @@ -1,3 +1,7 @@ +require("dotenv").config({ + path: `.env.${process.env.NODE_ENV}`, +}) + const path = require("path") const fs = require("fs") @@ -111,6 +115,15 @@ module.exports = ({ }) } + if (process.env.DISQUS_SHORTNAME) { + defaultPlugins.push({ + resolve: `gatsby-plugin-disqus`, + options: { + shortname: process.env.DISQUS_SHORTNAME, + }, + }) + } + return defaultPlugins.concat({ resolve: `gatsby-plugin-mdx`, options: { diff --git a/packages/gatsby-theme-pitayan/package.json b/packages/gatsby-theme-pitayan/package.json index b0b4886..6b36d01 100644 --- a/packages/gatsby-theme-pitayan/package.json +++ b/packages/gatsby-theme-pitayan/package.json @@ -7,6 +7,7 @@ "@mdx-js/mdx": "^2.2.1", "@mdx-js/react": "^2.2.1", "autoprefixer": "^10.4.13", + "dotenv": "^16.0.3", "gatsby": "^5.3.2", "gatsby-plugin-catch-links": "^5.3.0", "gatsby-plugin-image": "^3.3.2", diff --git a/packages/gatsby-theme-pitayan/src/templates/post/index.tsx b/packages/gatsby-theme-pitayan/src/templates/post/index.tsx index 24e6fa3..7c01ebb 100644 --- a/packages/gatsby-theme-pitayan/src/templates/post/index.tsx +++ b/packages/gatsby-theme-pitayan/src/templates/post/index.tsx @@ -3,6 +3,7 @@ import { graphql, Link } from "gatsby" import { MDXProvider } from "@mdx-js/react" import { RiArrowLeftLine, RiArrowRightLine } from "react-icons/ri" import { GatsbyImage, getImage, ImageDataLike } from "gatsby-plugin-image" +import { Disqus } from "gatsby-plugin-disqus" import { useLocation } from "@reach/router" import DefaultLayout from "@pitayan/gatsby-theme-pitayan/src/layouts/Default" @@ -237,6 +238,17 @@ const Post: React.FC = ({ })} + +
Related Posts
Date: Sun, 12 Mar 2023 16:10:34 +0900 Subject: [PATCH 2/2] move component to right after article, match article width --- .../src/templates/post/index.tsx | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/gatsby-theme-pitayan/src/templates/post/index.tsx b/packages/gatsby-theme-pitayan/src/templates/post/index.tsx index 7c01ebb..c7ace10 100644 --- a/packages/gatsby-theme-pitayan/src/templates/post/index.tsx +++ b/packages/gatsby-theme-pitayan/src/templates/post/index.tsx @@ -185,6 +185,16 @@ const Post: React.FC = ({ />
+
+ +
+
@@ -238,17 +248,6 @@ const Post: React.FC = ({ })}
- -
Related Posts