diff --git a/.gitignore b/.gitignore index 3b42cabb9..3ee0b7395 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ public storybook-static public/storybook .artifacts -.vercel \ No newline at end of file +.vercel +repo-metadata.json \ No newline at end of file diff --git a/gatsby-node.js b/gatsby-node.js index b6f5541cb..02d852204 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -1,6 +1,10 @@ const path = require('path') const createFields = require('./gatsby/createFields') const createMarkdownPages = require('./gatsby/createMarkdownPages') +const execSync = require('child_process').execSync + +// Write out repo metadata +execSync(`node ./scripts/write-repo-metadata > repo-metadata.json`) exports.onCreateNode = ({ node, actions, getNode }) => { createFields(node, actions, getNode) diff --git a/package.json b/package.json index 772bbe3e7..428081fe6 100644 --- a/package.json +++ b/package.json @@ -11,12 +11,13 @@ "jest": "NODE_ENV=test jest -c tests/unit/jest.config.js", "test": "npm run lint && npm run jest", "test:watch": "npm run lint && npm run jest -- --watch", - "lint": "eslint --ignore-path .gitignore --ext .js --ext .ts --ext .tsx . && npm run type-check", + "lint": "npm run write:repoMetadata && eslint --ignore-path .gitignore --ext .js --ext .ts --ext .tsx . && npm run type-check", "format": "prettier --ignore-path .gitignore './**/*.{css,yml,js,ts,tsx,json}' --write", "type-check": "tsc --noEmit", "analyze": "npm run build && source-map-explorer 'public/*.js'", "storybook": "start-storybook -p 4000 -c .storybook", - "storybook:build": "build-storybook -c .storybook -o public/storybook" + "storybook:build": "build-storybook -c .storybook -o public/storybook", + "write:repoMetadata": "node ./scripts/write-repo-metadata > repo-metadata.json" }, "dependencies": { "@coingecko/cryptoformat": "^0.4.2", diff --git a/scripts/write-repo-metadata.js b/scripts/write-repo-metadata.js new file mode 100644 index 000000000..eaf6ef088 --- /dev/null +++ b/scripts/write-repo-metadata.js @@ -0,0 +1,23 @@ +#!/usr/bin/env node +'use strict' + +const execSync = require('child_process').execSync + +// +// VERCEL_GITHUB_COMMIT_REF & VERCEL_GITHUB_COMMIT_SHA need to be added with empty +// values in Vercel environment variables, making them available to builds. +// https://vercel.com/docs/build-step#system-environment-variables +// +process.stdout.write( + JSON.stringify( + { + version: require('../package.json').version, + branch: process.env.VERCEL_GITHUB_COMMIT_REF || 'dev', + commit: + process.env.VERCEL_GITHUB_COMMIT_SHA || + execSync(`git rev-parse HEAD`).toString().trim() + }, + null, + ' ' + ) +) diff --git a/src/components/atoms/BuildId.module.css b/src/components/atoms/BuildId.module.css new file mode 100644 index 000000000..58fa3b325 --- /dev/null +++ b/src/components/atoms/BuildId.module.css @@ -0,0 +1,6 @@ +.buildId { + display: inline-block; + font-size: var(--font-size-mini); + margin-bottom: var(--spacer); + font-family: var(--font-family-monospace); +} diff --git a/src/components/atoms/BuildId.tsx b/src/components/atoms/BuildId.tsx new file mode 100644 index 000000000..2ad6661d3 --- /dev/null +++ b/src/components/atoms/BuildId.tsx @@ -0,0 +1,23 @@ +import React, { ReactElement } from 'react' +import repoMetadata from '../../../repo-metadata.json' +import styles from './BuildId.module.css' + +export default function BuildId(): ReactElement { + const commitBranch = repoMetadata.branch + const commitId = repoMetadata.commit + const isMainBranch = commitBranch === 'main' + + return ( + + {isMainBranch ? commitId.substring(0, 7) : commitBranch} + + ) +} diff --git a/src/components/molecules/MarketStats.module.css b/src/components/molecules/MarketStats.module.css index 71621dc89..1acf8ce88 100644 --- a/src/components/molecules/MarketStats.module.css +++ b/src/components/molecules/MarketStats.module.css @@ -1,16 +1,14 @@ .stats { margin-bottom: calc(var(--spacer) * 2); - font-size: var(--font-size-base); + font-size: var(--font-size-small); + line-height: 2; } .stats > div > div { display: inline-block; } -.stats > div strong { - font-size: var(--font-size-base) !important; -} - .total { color: var(--color-secondary) !important; + font-size: var(--font-size-small) !important; } diff --git a/src/components/molecules/MarketStats.tsx b/src/components/molecules/MarketStats.tsx index fa5eef861..589466b95 100644 --- a/src/components/molecules/MarketStats.tsx +++ b/src/components/molecules/MarketStats.tsx @@ -57,8 +57,8 @@ export default function MarketStats(): ReactElement { return (
- Total of {stats?.datasets.total} data sets & datatokens - published by {stats?.owners} accounts. + Total of {stats?.datasets.total} data sets & unique + datatokens published by {stats?.owners} accounts.
{' '} + and{' '} + {' '} in {stats?.datasets.pools} data set pools.
{stats?.datasets.none} data sets have no price set yet. diff --git a/src/components/organisms/Footer.module.css b/src/components/organisms/Footer.module.css index 6c551048e..f78180ac7 100644 --- a/src/components/organisms/Footer.module.css +++ b/src/components/organisms/Footer.module.css @@ -14,3 +14,12 @@ .content p { display: inline; } + +.content a { + color: inherit; +} + +.content a:hover, +.content a:focus { + color: var(--color-primary); +} diff --git a/src/components/organisms/Footer.tsx b/src/components/organisms/Footer.tsx index 71994540d..2ca574a3b 100644 --- a/src/components/organisms/Footer.tsx +++ b/src/components/organisms/Footer.tsx @@ -4,6 +4,7 @@ import Markdown from '../atoms/Markdown' import { useSiteMetadata } from '../../hooks/useSiteMetadata' import { Link } from 'gatsby' import MarketStats from '../molecules/MarketStats' +import BuildId from '../atoms/BuildId' export default function Footer(): ReactElement { const { copyright } = useSiteMetadata() @@ -12,6 +13,7 @@ export default function Footer(): ReactElement { return (