mirror of
https://github.com/BillyOutlast/posthog.com.git
synced 2026-02-04 03:11:21 +01:00
Co-authored-by: Cory Watilo <corywatilo@gmail.com> Co-authored-by: Eli Kinsey <eli@ekinsey.dev> Co-authored-by: Lucas Faria <12522524+lucasheriques@users.noreply.github.com> Co-authored-by: Ben White <ben@posthog.com> Co-authored-by: Juraj Majerik <juro.majerik@gmail.com> Co-authored-by: Rafael Audibert <32079912+rafaeelaudibert@users.noreply.github.com>
99 lines
3.4 KiB
TypeScript
99 lines
3.4 KiB
TypeScript
import path from 'path'
|
|
import fs from 'fs/promises'
|
|
import { GatsbyNode } from 'gatsby'
|
|
const axios = require('axios')
|
|
|
|
export { createPages } from './gatsby/createPages'
|
|
export { onCreateNode, onPreInit } from './gatsby/onCreateNode'
|
|
export { createSchemaCustomization } from './gatsby/createSchemaCustomization'
|
|
export { sourceNodes } from './gatsby/sourceNodes'
|
|
export { onPostBuild } from './gatsby/onPostBuild'
|
|
export { createResolvers } from './gatsby/createResolvers'
|
|
export { onPreBootstrap } from './gatsby/onPreBootstrap'
|
|
|
|
// Implement the Gatsby API “onCreatePage”. This is
|
|
// called after every page is created.
|
|
export const onCreatePage: GatsbyNode['onCreatePage'] = async ({ page, actions }) => {
|
|
const { createPage, deletePage } = actions
|
|
|
|
// Add build time to credits page using environment variable
|
|
if (page.path === '/credits/') {
|
|
// Use Vercel's VERCEL_ENV variable or current time as fallback
|
|
const buildDate = process.env.VERCEL_GIT_COMMIT_SHA
|
|
? new Date() // This will be the actual build time when deployed
|
|
: new Date()
|
|
|
|
const options: Intl.DateTimeFormatOptions = {
|
|
month: 'short',
|
|
day: 'numeric',
|
|
year: 'numeric',
|
|
hour: 'numeric',
|
|
minute: '2-digit',
|
|
hour12: true,
|
|
timeZone: 'America/Los_Angeles'
|
|
}
|
|
const buildTime = buildDate.toLocaleString('en-US', options)
|
|
|
|
deletePage(page)
|
|
createPage({
|
|
...page,
|
|
context: {
|
|
...page.context,
|
|
buildTime,
|
|
// Also pass the commit SHA if available for debugging
|
|
commitSha: process.env.VERCEL_GIT_COMMIT_SHA?.substring(0, 7) || 'local',
|
|
},
|
|
})
|
|
}
|
|
|
|
if (page.path.match(/^\/community\/profiles/)) {
|
|
page.matchPath = '/community/profiles/*'
|
|
createPage(page)
|
|
}
|
|
if (page.path.match(/^\/next\-steps/)) {
|
|
page.matchPath = '/next-steps/*'
|
|
createPage(page)
|
|
}
|
|
}
|
|
|
|
export const onCreateWebpackConfig: GatsbyNode['onCreateWebpackConfig'] = ({ stage, actions }) => {
|
|
actions.setWebpackConfig({
|
|
cache: process.env.NODE_ENV === 'development' || {
|
|
compression: 'gzip',
|
|
},
|
|
resolve: {
|
|
extensions: ['.js', '.ts', '.tsx'],
|
|
alias: {
|
|
'~': path.resolve(__dirname, 'src'),
|
|
lib: path.resolve(__dirname, 'src', 'lib'),
|
|
types: path.resolve(__dirname, 'src', 'types'),
|
|
images: path.resolve(__dirname, 'src', 'images'),
|
|
components: path.resolve(__dirname, 'src', 'components'),
|
|
logic: path.resolve(__dirname, 'src', 'logic'),
|
|
hooks: path.resolve(__dirname, 'src', 'hooks'),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
exports.createPages = async ({ actions }) => {
|
|
const { createPage } = actions
|
|
|
|
try {
|
|
const response = await axios.get('https://jobs.ashbyhq.com/supabase')
|
|
const jobData = JSON.parse(response.data)
|
|
const jobs = jobData?.jobBoard?.jobPostings || []
|
|
|
|
// Create the jobs page with the data
|
|
createPage({
|
|
path: '/jobs',
|
|
component: require.resolve('./src/templates/jobs.tsx'),
|
|
context: {
|
|
jobs: jobs,
|
|
},
|
|
})
|
|
} catch (error) {
|
|
console.error('Error fetching jobs:', error)
|
|
}
|
|
}
|