[website] use demo ghost for blog in dev (#428)

* use demo ghost in dev

* union

* u ci.yml
This commit is contained in:
Felicio Mununga 2023-06-28 17:41:35 +01:00 committed by GitHub
parent 86ef94af34
commit 8a3cf6ce48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 5 deletions

View File

@ -7,6 +7,7 @@ on:
types: [opened, synchronize] types: [opened, synchronize]
env: env:
NEXT_PUBLIC_GHOST_API_URL: ''
NEXT_PUBLIC_GHOST_API_KEY: '' NEXT_PUBLIC_GHOST_API_KEY: ''
INFURA_API_KEY: '' INFURA_API_KEY: ''
TAMAGUI_TARGET: 'web' TAMAGUI_TARGET: 'web'

View File

@ -1,3 +1,15 @@
# .env, .env.development, and .env.production files should be included in your repository as they define defaults.
# .env*.local should be added to .gitignore, as those files are intended to be ignored.
# .env.local is where secrets can be stored.
#
# https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#default-environment-variables
# The vercel env pull sub-command will export development environment variables to a local .env file or a different file of your choice.
#
# `vercel env pull ./apps/website/.env.development.local`
#
# https://vercel.com/docs/cli/env#exporting-development-environment-variables
IGNORE_TS_CONFIG_PATHS=true IGNORE_TS_CONFIG_PATHS=true
TAMAGUI_TARGET=web TAMAGUI_TARGET=web
TAMAGUI_DISABLE_WARN_DYNAMIC_LOAD=1 TAMAGUI_DISABLE_WARN_DYNAMIC_LOAD=1

View File

@ -0,0 +1,14 @@
# .env, .env.development, and .env.production files should be included in your repository as they define defaults.
# .env*.local should be added to .gitignore, as those files are intended to be ignored.
# .env.local is where secrets can be stored.
#
# https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#default-environment-variables
# The vercel env pull sub-command will export development environment variables to a local .env file or a different file of your choice.
#
# `vercel env pull ./apps/website/.env.development.local`
#
# https://vercel.com/docs/cli/env#exporting-development-environment-variables
NEXT_PUBLIC_GHOST_API_URL=https://demo.ghost.io
NEXT_PUBLIC_GHOST_API_KEY=22444f78447824223cefc48062

View File

@ -1,9 +1,19 @@
import { z } from 'zod' import { z } from 'zod'
export const envSchema = z.object({ export const envSchema = z.object({
NEXT_PUBLIC_VERCEL_ENV: z
.union([
z.literal('production'),
z.literal('preview'),
z.literal('development'),
])
.optional(),
NEXT_PUBLIC_GHOST_API_URL: z.string(),
NEXT_PUBLIC_GHOST_API_KEY: z.string(), NEXT_PUBLIC_GHOST_API_KEY: z.string(),
}) })
export const clientEnv = envSchema.parse({ export const clientEnv = envSchema.parse({
NEXT_PUBLIC_VERCEL_ENV: process.env.NEXT_PUBLIC_VERCEL_ENV,
NEXT_PUBLIC_GHOST_API_URL: process.env.NEXT_PUBLIC_GHOST_API_URL,
NEXT_PUBLIC_GHOST_API_KEY: process.env.NEXT_PUBLIC_GHOST_API_KEY, NEXT_PUBLIC_GHOST_API_KEY: process.env.NEXT_PUBLIC_GHOST_API_KEY,
}) })

View File

@ -7,6 +7,13 @@ if (typeof window !== 'undefined') {
} }
export const envSchema = z.object({ export const envSchema = z.object({
VERCEL_ENV: z
.union([
z.literal('production'),
z.literal('preview'),
z.literal('development'),
])
.optional(),
INFURA_API_KEY: z.string(), INFURA_API_KEY: z.string(),
TAMAGUI_TARGET: z.literal('web'), TAMAGUI_TARGET: z.literal('web'),
NEXT_PUBLIC_GHOST_API_KEY: z.string(), NEXT_PUBLIC_GHOST_API_KEY: z.string(),

View File

@ -4,7 +4,7 @@ import { clientEnv } from '@/config/env.client.mjs'
/** @see https://ghost.org/docs/content-api# */ /** @see https://ghost.org/docs/content-api# */
const ghost = new GhostContentAPI({ const ghost = new GhostContentAPI({
url: 'https://our.status.im', url: clientEnv.NEXT_PUBLIC_GHOST_API_URL,
key: clientEnv.NEXT_PUBLIC_GHOST_API_KEY, key: clientEnv.NEXT_PUBLIC_GHOST_API_KEY,
version: 'v5.0', version: 'v5.0',
}) })
@ -62,7 +62,7 @@ export const getPostsByAuthorSlug = async (slug: string, page = 1) => {
export const getPostSlugs = async (): Promise<string[]> => { export const getPostSlugs = async (): Promise<string[]> => {
const posts = await ghost.posts.browse({ const posts = await ghost.posts.browse({
limit: '7', limit: 7,
fields: 'slug', fields: 'slug',
filter: 'visibility:public', filter: 'visibility:public',
}) })
@ -72,7 +72,7 @@ export const getPostSlugs = async (): Promise<string[]> => {
export const getTags = async () => { export const getTags = async () => {
return await ghost.tags.browse({ return await ghost.tags.browse({
limit: 'all', limit: clientEnv.NEXT_PUBLIC_VERCEL_ENV === 'production' ? 'all' : 6,
fields: 'name,slug', fields: 'name,slug',
filter: 'visibility:public', filter: 'visibility:public',
}) })
@ -80,7 +80,7 @@ export const getTags = async () => {
export const getTagSlugs = async (): Promise<string[]> => { export const getTagSlugs = async (): Promise<string[]> => {
const tags = await ghost.tags.browse({ const tags = await ghost.tags.browse({
limit: 'all', limit: clientEnv.NEXT_PUBLIC_VERCEL_ENV === 'production' ? 'all' : 6,
fields: 'slug', fields: 'slug',
filter: 'visibility:public', filter: 'visibility:public',
}) })
@ -90,7 +90,7 @@ export const getTagSlugs = async (): Promise<string[]> => {
export const getAuthorSlugs = async (): Promise<string[]> => { export const getAuthorSlugs = async (): Promise<string[]> => {
const authors = await ghost.authors.browse({ const authors = await ghost.authors.browse({
limit: 'all', limit: clientEnv.NEXT_PUBLIC_VERCEL_ENV === 'production' ? 'all' : 6,
fields: 'slug', fields: 'slug',
filter: 'visibility:public', filter: 'visibility:public',
}) })