Skip to content

Commit

Permalink
Merge pull request #833 from CodeForAfrica/feat/civicsignalblog_norma…
Browse files Browse the repository at this point in the history
…l_preview

@/civicsignalblog normal preview
  • Loading branch information
kilemensi authored Aug 8, 2024
2 parents 108081f + 16e6821 commit a07f44c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
3 changes: 2 additions & 1 deletion apps/civicsignalblog/.env
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion apps/civicsignalblog/contrib/dokku/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM codeforafrica/codeforafrica-ui:0.1.6
FROM codeforafrica/codeforafrica-ui:0.1.7
2 changes: 1 addition & 1 deletion apps/civicsignalblog/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "civicsignalblog",
"version": "0.1.6",
"version": "0.1.7",
"private": true,
"author": "Code for Africa <tech@codeforafrica.org>",
"description": "This is the (temporary) CivicSignal blog",
Expand Down
7 changes: 4 additions & 3 deletions apps/civicsignalblog/payload.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions apps/civicsignalblog/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions apps/civicsignalblog/src/lib/data/utils/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ export async function getPost(api, slug, primaryTag) {
authors,
title,
coverImage,
excerpt,
tags,
excerpt = null,
tags = [],
meta,
publishedOn,
...other
Expand Down
9 changes: 6 additions & 3 deletions apps/civicsignalblog/src/payload/collections/Posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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: [
Expand Down

0 comments on commit a07f44c

Please sign in to comment.