-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #733 from CodeForAfrica/roboshield/setup-payload
Added Payload CMS Set up for Roboshield.
- Loading branch information
Showing
42 changed files
with
3,027 additions
and
355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
MIGRATIONS_DIR=./migrations | ||
|
||
PAYLOAD_PUBLIC_DEFAULT_LOCALE=en | ||
PAYLOAD_PUBLIC_LOCALES="en" | ||
|
||
SENTRY_ENVIRONMENT=local | ||
SENTRY_ORG=code-for-africa | ||
SENTRY_PROJECT=roboshield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import path from "path"; | ||
|
||
import { buildConfig } from "payload/config"; | ||
import { slateEditor } from "@payloadcms/richtext-slate"; | ||
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 Site from "./src/payload/globals/Site"; | ||
import dotenv from "dotenv"; | ||
import Media from "./src/payload/collections/Media"; | ||
import Pages from "./src/payload/collections/Pages"; | ||
import seo from "@payloadcms/plugin-seo"; | ||
import nestedDocs from "@payloadcms/plugin-nested-docs"; | ||
import { s3Adapter } from "@payloadcms/plugin-cloud-storage/s3"; | ||
import Users from "./src/payload/collections/Users"; | ||
import { defaultLocale, locales } from "./src/payload/utils/locales"; | ||
|
||
dotenv.config(); | ||
dotenv.config({ path: "./.env.local" }); | ||
|
||
const appURL = process?.env?.PAYLOAD_PUBLIC_APP_URL; | ||
|
||
const cors = | ||
process?.env?.PAYLOAD_CORS?.split(",") | ||
?.map((d) => d.trim()) | ||
?.filter(Boolean) ?? []; | ||
|
||
const csrf = | ||
process?.env?.PAYLOAD_CSRF?.split(",") | ||
?.map((d) => d.trim()) | ||
?.filter(Boolean) ?? []; | ||
|
||
const adapter = s3Adapter({ | ||
config: { | ||
region: process?.env?.S3_REGION, | ||
credentials: { | ||
accessKeyId: process?.env?.S3_ACCESS_KEY_ID, | ||
secretAccessKey: process?.env?.S3_SECRET_ACCESS_KEY, | ||
}, | ||
}, | ||
bucket: process?.env?.S3_BUCKET, | ||
} as any); | ||
|
||
export default buildConfig({ | ||
serverURL: appURL, | ||
editor: slateEditor({}), | ||
db: mongooseAdapter({ | ||
url: process.env.MONGO_URL ?? false, | ||
migrationDir: process.env.MIGRATIONS_DIR, | ||
}), | ||
collections: [Media, Pages, Users] as CollectionConfig[], | ||
globals: [Site] as GlobalConfig[], | ||
...(locales?.length | ||
? { | ||
localization: { | ||
locales, | ||
defaultLocale, | ||
fallback: true, | ||
}, | ||
} | ||
: undefined), | ||
admin: { | ||
user: Users.slug, | ||
webpack: (config) => ({ | ||
...config, | ||
resolve: { | ||
...config.resolve, | ||
fallback: { | ||
...config?.resolve?.fallback, | ||
fs: false, | ||
os: false, | ||
"process/browser": false, | ||
}, | ||
}, | ||
}), | ||
bundler: webpackBundler(), | ||
}, | ||
cors, | ||
csrf, | ||
i18n: { | ||
fallbackLng: "en", // default | ||
debug: false, // default | ||
resources: { | ||
en: { | ||
"codeforafrica.validation": { | ||
uniquePlatforms: "Please select a unique platform", | ||
}, | ||
}, | ||
}, | ||
}, | ||
plugins: [ | ||
cloudStorage({ | ||
collections: { | ||
media: { | ||
adapter, | ||
prefix: "media", | ||
}, | ||
}, | ||
}), | ||
seo({ | ||
collections: ["pages", "posts"], | ||
globals: [], | ||
uploadsCollection: "media", | ||
generateTitle: ({ doc }: any) => doc?.title?.value as string, | ||
generateURL: ({ doc }: any) => | ||
doc?.slug?.value ? `${appURL}/${doc.slug.value}` : undefined, | ||
} as any), | ||
nestedDocs({ | ||
collections: ["pages"], | ||
generateLabel: (_, doc) => doc.title as string, | ||
generateURL: (docs) => | ||
docs.reduce((url, doc) => `${url}/${doc.slug}`, ""), | ||
}), | ||
] as any[], | ||
telemetry: process?.env?.NODE_ENV !== "production", | ||
}); |
Oops, something went wrong.