diff --git a/.drone.yml b/.drone.yml index 5eac4d9..4a41070 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,8 +1,10 @@ kind: pipeline type: docker -name: default +name: Build Main trigger: + event: + - push branch: - main @@ -25,7 +27,7 @@ steps: - yarn install - yarn build - du -sh public - + - name: rsync image: drillster/drone-rsync settings: @@ -37,11 +39,11 @@ steps: exclude: - node_modules - .git* - args: -r source: ./public/ target: ~/www/personal-website delete: true - secrets: [ rsync_key ] + recursive: true + secrets: [rsync_key] - name: rebuild-cache image: drillster/drone-volume-cache @@ -59,3 +61,59 @@ volumes: - name: cache host: path: /mnt/user/dronecache + +--- +kind: pipeline +type: docker +name: Preview PR + +trigger: + event: + - pull_request + +steps: + - name: restore-cache + image: drillster/drone-volume-cache + settings: + restore: true + mount: + - ./node_modules + - ./.cache + - ./public + volumes: + - name: cache + path: /cache + + - name: build + image: node + commands: + - yarn install + - PATH_PREFIX=/${DRONE_PULL_REQUEST} yarn build --prefix-paths + - du -sh public + + - name: rsync + image: drillster/drone-rsync + settings: + user: ci + key: + from_secret: rsync_key + hosts: + - droplet.chuckdries.com + exclude: + - node_modules + - .git* + source: ./public/ + target: ~/www/personal-website-preview/${DRONE_PULL_REQUEST} + prescript: cp -r ~/www/personal-website ~/www/personal-website-preview/${DRONE_PULL_REQUEST} + delete: true + recursive: true + secrets: [rsync_key] + + - name: comment + image: jmccann/drone-github-comment:1 + settings: + message: preview of ${DRONE_COMMIT} deployed to https://preview.chuckdries.com/${DRONE_PULL_REQUEST} + update: true + api_key: + from_secret: github_key +# note: we intentionally do not rebuild-cache for PRs diff --git a/gatsby-config.js b/gatsby-config.js index 7ffcfdd..e74837f 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -1,4 +1,5 @@ module.exports = { + pathPrefix: process.env.PATH_PREFIX, siteMetadata: { title: "Chuck Dries", siteUrl: "https://chuckdries.com", diff --git a/src/components/GalleryImage/GalleryImage.js b/src/components/GalleryImage/GalleryImage.js index 57fae77..1181ad8 100644 --- a/src/components/GalleryImage/GalleryImage.js +++ b/src/components/GalleryImage/GalleryImage.js @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import { graphql, navigate, Link } from "gatsby"; import { GatsbyImage, getImage } from "gatsby-plugin-image"; import { Helmet } from "react-helmet"; @@ -26,6 +26,7 @@ import { getGalleryPageUrl, } from "../../utils"; import MetadataItem from "./MetadataItem"; +import Nav from "../Nav"; const logKeyShortcut = (keyCode) => { try { @@ -53,6 +54,9 @@ const GalleryImage = ({ const ar = getAspectRatio(image); const [zoom, setZoom] = useState(false); + const [isClient, setIsClient] = useState(true); + + useEffect(() => {setIsClient(true)}, []) const nextIndex = sortedImageList && currentIndex < sortedImageList.length @@ -149,30 +153,13 @@ const GalleryImage = ({ />
- +