From 83b4626c36251ff6cfae27d392c49644b4690d03 Mon Sep 17 00:00:00 2001 From: Ferit Date: Fri, 26 Dec 2025 23:12:13 +0000 Subject: [PATCH 1/5] chore: update Cloudflare Pages references --- README.md | 3 ++- src/components/footer.js | 2 +- src/pages/index.js | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d04f75d..a7fa7d5 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ Prove Us Wrong -[![Netlify Status](https://api.netlify.com/api/v1/badges/a791a4e1-44b5-4ba5-8703-ce89505a170f/deploy-status)](https://app.netlify.com/sites/proveuswrong/deploys) +[![Production](https://img.shields.io/website?label=production&url=https%3A%2F%2Fproveuswrong.io&logo=cloudflare&logoColor=white)](https://proveuswrong.io) +[![Develop](https://img.shields.io/website?label=develop&url=https%3A%2F%2Fdevelop.proveuswrong.io&logo=cloudflare&logoColor=white)](https://develop.proveuswrong.io) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=proveuswrong_website&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=proveuswrong_website) diff --git a/src/components/footer.js b/src/components/footer.js index 6fe0aff..b327dd1 100644 --- a/src/components/footer.js +++ b/src/components/footer.js @@ -82,7 +82,7 @@ const Footer = () => ( Copyright {new Date().getFullYear()} Prove Us Wrong - This site is powered by Netlify + This site is powered by Cloudflare Pages diff --git a/src/pages/index.js b/src/pages/index.js index 2f9d907..776e2aa 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -6,7 +6,6 @@ import Seo from "../components/seo"; import * as styles from "./index.module.scss"; const IndexPage = () => { - const isNetlify = Boolean(process.env.NETLIFY); const { site } = useStaticQuery( graphql` query { From 0b31ef737ddb1b46ef80dca567104b2abe22b459 Mon Sep 17 00:00:00 2001 From: Ferit Date: Fri, 26 Dec 2025 23:26:32 +0000 Subject: [PATCH 2/5] Add GitHub Actions workflow for Cloudflare Pages deploy Signed-off-by: Ferit --- .github/workflows/cloudflare-pages-deploy.yml | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/cloudflare-pages-deploy.yml diff --git a/.github/workflows/cloudflare-pages-deploy.yml b/.github/workflows/cloudflare-pages-deploy.yml new file mode 100644 index 0000000..f5e8efb --- /dev/null +++ b/.github/workflows/cloudflare-pages-deploy.yml @@ -0,0 +1,37 @@ +name: Deploy to Cloudflare Pages + +on: + push: + branches: + - main + - develop + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + contents: read + deployments: write + name: Deploy to Cloudflare Pages + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'yarn' + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Build + run: yarn build + + - name: Deploy to Cloudflare Pages + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy public --project-name=proveuswrong-pages --branch=${{ github.ref_name }} From 7e967bb98dfb129d800ce8f439dd742173dd7521 Mon Sep 17 00:00:00 2001 From: Ferit Date: Fri, 26 Dec 2025 23:43:49 +0000 Subject: [PATCH 3/5] Delete .github/workflows/cloudflare-pages-deploy.yml Signed-off-by: Ferit --- .github/workflows/cloudflare-pages-deploy.yml | 37 ------------------- 1 file changed, 37 deletions(-) delete mode 100644 .github/workflows/cloudflare-pages-deploy.yml diff --git a/.github/workflows/cloudflare-pages-deploy.yml b/.github/workflows/cloudflare-pages-deploy.yml deleted file mode 100644 index f5e8efb..0000000 --- a/.github/workflows/cloudflare-pages-deploy.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Deploy to Cloudflare Pages - -on: - push: - branches: - - main - - develop - -jobs: - deploy: - runs-on: ubuntu-latest - permissions: - contents: read - deployments: write - name: Deploy to Cloudflare Pages - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'yarn' - - - name: Install dependencies - run: yarn install --frozen-lockfile - - - name: Build - run: yarn build - - - name: Deploy to Cloudflare Pages - uses: cloudflare/wrangler-action@v3 - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy public --project-name=proveuswrong-pages --branch=${{ github.ref_name }} From 06c20af77890030798879c2786ff5c0da1702a54 Mon Sep 17 00:00:00 2001 From: Ferit Date: Sat, 27 Dec 2025 00:29:06 +0000 Subject: [PATCH 4/5] fix: align env metadata and seo urls --- gatsby-config.js | 53 ++++++++++++++----- src/components/seo.js | 40 ++++++++------ src/pages/404.js | 4 +- src/pages/about.js | 4 +- src/pages/index.js | 4 +- .../{MarkdownRemark.frontmatter__slug}.js | 4 +- 6 files changed, 72 insertions(+), 37 deletions(-) diff --git a/gatsby-config.js b/gatsby-config.js index 1161cd4..a1994d7 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -1,17 +1,44 @@ -const isProd = (branchName, isPullRequest) => { - if(!branchName) return false; - return branchName === 'main' - || branchName.startsWith('hotfix/') - || branchName.startsWith('release/') - || (branchName === 'develop' && isPullRequest === 'true'); +const isProductionEnv = () => { + if (process.env.CF_PAGES_ENVIRONMENT) { + return process.env.CF_PAGES_ENVIRONMENT === "production"; + } + + const branchName = + process.env.CF_PAGES_BRANCH || process.env.BRANCH || process.env.HEAD; + if (!branchName) { + return process.env.NODE_ENV === "production"; + } + + return ( + branchName === "main" || + branchName.startsWith("hotfix/") || + branchName.startsWith("release/") || + (branchName === "develop" && process.env.PULL_REQUEST === "true") + ); }; +const isProd = isProductionEnv(); require("dotenv").config({ - path: `${isProd(process.env.HEAD, process.env.PULL_REQUEST) ? ".env.production" : ".env.development"}`, + path: isProd ? ".env.production" : ".env.development", }); -const SITE_URL = "https://proveuswrong.io/" +const PROD_SITE_URL = "https://proveuswrong.io/"; +const PREVIEW_SITE_URL = "https://develop.proveuswrong.io/"; +const SITE_URL = isProd ? PROD_SITE_URL : PREVIEW_SITE_URL; + +const branchName = + process.env.CF_PAGES_BRANCH || process.env.BRANCH || process.env.HEAD; +const commitRef = process.env.CF_PAGES_COMMIT_SHA || process.env.COMMIT_REF; +const pullRequest = + process.env.PULL_REQUEST || + (process.env.CF_PAGES_ENVIRONMENT + ? process.env.CF_PAGES_ENVIRONMENT === "production" + ? "false" + : "true" + : undefined); +const reviewID = process.env.CF_PAGES_DEPLOYMENT_ID || process.env.REVIEW_ID; +const headRef = process.env.HEAD || branchName; module.exports = { siteMetadata: { @@ -19,11 +46,11 @@ module.exports = { description: `We are an organization that develops decentralized curation solutions as public goods. We build the next cool thing. Prove us wrong.`, author: `@0xferit`, siteUrl: SITE_URL, - head: process.env.HEAD, - pullRequest: process.env.PULL_REQUEST, - branch: process.env.BRANCH, - commitRef: process.env.COMMIT_REF, - reviewID: process.env.REVIEW_ID, + head: headRef, + pullRequest, + branch: branchName, + commitRef, + reviewID, }, plugins: [ { diff --git a/src/components/seo.js b/src/components/seo.js index 435dab5..fd01ddd 100644 --- a/src/components/seo.js +++ b/src/components/seo.js @@ -2,12 +2,26 @@ import * as React from "react"; import PropTypes from "prop-types"; import { Helmet } from "react-helmet"; import { useStaticQuery, graphql } from "gatsby"; -import { useEffect, useState } from "react"; -const constructUrl = (baseUrl, path) => - !baseUrl || !path ? null : `${baseUrl}${path}`; +const joinUrl = (baseUrl, path) => { + if (!baseUrl) return null; + if (!path) return baseUrl; + const normalizedBase = baseUrl.endsWith("/") + ? baseUrl.slice(0, -1) + : baseUrl; + const normalizedPath = path.startsWith("/") ? path : `/${path}`; + return `${normalizedBase}${normalizedPath}`; +}; -function Seo({ description, lang, meta, title, customImageUrl, imageAlt }) { +function Seo({ + description, + lang, + meta, + title, + customImageUrl, + imageAlt, + pathname, +}) { const { ogImageDefault, site } = useStaticQuery( graphql` query { @@ -30,14 +44,10 @@ function Seo({ description, lang, meta, title, customImageUrl, imageAlt }) { ` ); - const [actualURL, setActualURL] = useState(); - - useEffect(() => { - setActualURL(window.location.href); - }, []); // Not working - const metaDescription = description || site.siteMetadata.description; const defaultTitle = site.siteMetadata?.title; + const siteUrl = site.siteMetadata?.siteUrl; + const pageUrl = pathname ? joinUrl(siteUrl, pathname) : siteUrl; return ( ( +const NotFoundPage = ({ location }) => ( - +

404: Not Found

You just hit a route that doesn't exist... the sadness.

diff --git a/src/pages/about.js b/src/pages/about.js index f4ff721..880ade6 100644 --- a/src/pages/about.js +++ b/src/pages/about.js @@ -5,9 +5,9 @@ import Seo from "../components/seo"; import { StaticImage } from "gatsby-plugin-image"; import * as styles from "./about.module.scss"; -const About = () => ( +const About = ({ location }) => ( - +

Who We Are

diff --git a/src/pages/index.js b/src/pages/index.js index 776e2aa..bd87a59 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -5,7 +5,7 @@ import Layout from "../components/layout"; import Seo from "../components/seo"; import * as styles from "./index.module.scss"; -const IndexPage = () => { +const IndexPage = ({ location }) => { const { site } = useStaticQuery( graphql` query { @@ -43,7 +43,7 @@ const IndexPage = () => { return ( - +

In Decentralized Curation We Trust diff --git a/src/pages/{MarkdownRemark.frontmatter__slug}.js b/src/pages/{MarkdownRemark.frontmatter__slug}.js index 7937dbf..330e591 100644 --- a/src/pages/{MarkdownRemark.frontmatter__slug}.js +++ b/src/pages/{MarkdownRemark.frontmatter__slug}.js @@ -5,7 +5,7 @@ import Seo from "../components/seo"; import * as styles from "./markdownPage.module.scss"; import * as cheerio from 'cheerio'; -export default function MarkdownPage({ data }) { +export default function MarkdownPage({ data, location }) { const { markdownRemark } = data; // data.markdownRemark holds your post data const { frontmatter, html } = markdownRemark; @@ -30,7 +30,7 @@ export default function MarkdownPage({ data }) { return ( - + {!frontmatter.draft === true || process.env.ENV === "dev" ? (
From c56a2041f849219f736bd64b06b0fc8b230fc1af Mon Sep 17 00:00:00 2001 From: Ferit Date: Sat, 27 Dec 2025 00:45:42 +0000 Subject: [PATCH 5/5] fix: use CF_PAGES_URL for preview siteUrl --- gatsby-config.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gatsby-config.js b/gatsby-config.js index a1994d7..be8a066 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -23,8 +23,15 @@ require("dotenv").config({ path: isProd ? ".env.production" : ".env.development", }); -const PROD_SITE_URL = "https://proveuswrong.io/"; -const PREVIEW_SITE_URL = "https://develop.proveuswrong.io/"; +const withTrailingSlash = (url) => { + if (!url) return url; + return url.endsWith("/") ? url : `${url}/`; +}; + +const PROD_SITE_URL = withTrailingSlash("https://proveuswrong.io"); +const PREVIEW_SITE_URL = withTrailingSlash( + process.env.CF_PAGES_URL || "http://localhost:8000" +); const SITE_URL = isProd ? PROD_SITE_URL : PREVIEW_SITE_URL; const branchName =