diff --git a/apps/civicsignalblog/.env b/apps/civicsignalblog/.env index 9c951a201..2b1d235e6 100644 --- a/apps/civicsignalblog/.env +++ b/apps/civicsignalblog/.env @@ -1,11 +1,12 @@ MIGRATIONS_DIR=./migrations NEXT_PUBLIC_APP_DIRECTORY="apps/civicsignal/" NEXT_PUBLIC_APP_NAME="Code for Africa" -NEXT_PUBLIC_APP_URL="https://blog.civicsignal.africa" +NEXT_PUBLIC_APP_URL="http://localhost:3000" NEXT_PUBLIC_GOOGLE_ANALYTICS_ID="G-NXX5DBEHXC" NEXT_PUBLIC_IMAGE_DOMAINS="" NEXT_PUBLIC_IMAGE_UNOPTIMIZED="true" NEXT_PUBLIC_VERCEL_URL=${VERCEL_URL} +PAYLOAD_PUBLIC_APP_URL=$NEXT_PUBLIC_APP_URL SENTRY_ENVIRONMENT=local SENTRY_ORG=code-for-africa SENTRY_PROJECT=civicsignal diff --git a/apps/civicsignalblog/contrib/dokku/Dockerfile b/apps/civicsignalblog/contrib/dokku/Dockerfile index f59a37f1f..ff2543b4e 100644 --- a/apps/civicsignalblog/contrib/dokku/Dockerfile +++ b/apps/civicsignalblog/contrib/dokku/Dockerfile @@ -1 +1 @@ -FROM codeforafrica/codeforafrica-ui:0.1.6 +FROM codeforafrica/codeforafrica-ui:0.1.7 diff --git a/apps/civicsignalblog/package.json b/apps/civicsignalblog/package.json index 99fe184bf..d1d178d25 100644 --- a/apps/civicsignalblog/package.json +++ b/apps/civicsignalblog/package.json @@ -1,6 +1,6 @@ { "name": "civicsignalblog", - "version": "0.1.6", + "version": "0.1.7", "private": true, "author": "Code for Africa ", "description": "This is the (temporary) CivicSignal blog", diff --git a/apps/civicsignalblog/payload.config.ts b/apps/civicsignalblog/payload.config.ts index 3d2b683e4..8868d1d3b 100644 --- a/apps/civicsignalblog/payload.config.ts +++ b/apps/civicsignalblog/payload.config.ts @@ -6,11 +6,11 @@ import { mongooseAdapter } from "@payloadcms/db-mongodb"; import { webpackBundler } from "@payloadcms/bundler-webpack"; import { CollectionConfig, GlobalConfig } from "payload/types"; import { cloudStorage } from "@payloadcms/plugin-cloud-storage"; -import dotenv from "dotenv"; import { sentry } from "@payloadcms/plugin-sentry"; import seo from "@payloadcms/plugin-seo"; import nestedDocs from "@payloadcms/plugin-nested-docs"; import { s3Adapter } from "@payloadcms/plugin-cloud-storage/s3"; +import { loadEnvConfig } from "@next/env"; import Authors from "./src/payload/collections/Authors"; import Media from "./src/payload/collections/Media"; @@ -22,8 +22,9 @@ import Tags from "./src/payload/collections/Tags"; import Users from "./src/payload/collections/Users"; import { defaultLocale, locales } from "./src/payload/utils/locales"; -dotenv.config(); -dotenv.config({ path: "./.env.local" }); +const dev = process.env.NODE_ENV !== "production"; +const projectDir = process.cwd(); +loadEnvConfig(projectDir, dev); const appURL = process?.env?.PAYLOAD_PUBLIC_APP_URL; diff --git a/apps/civicsignalblog/server.ts b/apps/civicsignalblog/server.ts index 063368788..3b7d8418b 100644 --- a/apps/civicsignalblog/server.ts +++ b/apps/civicsignalblog/server.ts @@ -7,10 +7,10 @@ import payload from "payload"; import { Payload } from "payload/dist/payload"; import { loadEnvConfig } from "@next/env"; +const dev = process.env.NODE_ENV !== "production"; const projectDir = process.cwd(); -loadEnvConfig(projectDir); +loadEnvConfig(projectDir, dev); -const dev = process.env.NODE_ENV !== "production"; const hostname = process.env.NEXT_HOSTNAME || "localhost"; const port = parseInt(process.env.PORT || "3000", 10); const sendGridAPIKey = process.env.SENDGRID_API_KEY; diff --git a/apps/civicsignalblog/src/lib/data/utils/posts.js b/apps/civicsignalblog/src/lib/data/utils/posts.js index 376f479c8..4b74fd74d 100644 --- a/apps/civicsignalblog/src/lib/data/utils/posts.js +++ b/apps/civicsignalblog/src/lib/data/utils/posts.js @@ -106,8 +106,8 @@ export async function getPost(api, slug, primaryTag) { authors, title, coverImage, - excerpt, - tags, + excerpt = null, + tags = [], meta, publishedOn, ...other diff --git a/apps/civicsignalblog/src/payload/collections/Posts.js b/apps/civicsignalblog/src/payload/collections/Posts.js index d8b95606b..d85ebadc7 100644 --- a/apps/civicsignalblog/src/payload/collections/Posts.js +++ b/apps/civicsignalblog/src/payload/collections/Posts.js @@ -4,6 +4,7 @@ import image from "../fields/image"; import publishedOn from "../fields/publishedOn"; import slug from "../fields/slug"; import tags from "../fields/tags"; +import formatDraftUrl from "../utils/formatDraftUrl"; const Posts = { slug: "posts", @@ -22,12 +23,14 @@ const Posts = { defaultColumns: ["title", "authors", "publishedOn"], description: "Stories", group: "Publication", + preview: (doc, options) => formatDraftUrl("posts/stories", doc, options), useAsTitle: "title", listSearchableFields: ["content", "excerpt"], livePreview: { - // Assumed that all posts appear under pots/stories - url: ({ data }) => - `${process.env.PAYLOAD_PUBLIC_APP_URL}/posts/stories/${data.slug}`, + // Assumed that all posts appear under posts/stories + url: ({ data }) => { + return `${process.env.PAYLOAD_PUBLIC_APP_URL}/posts/stories/${data.slug}`; + }, }, }, fields: [