-
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 #767 from CodeForAfrica/bugfix/roboshield-payload-…
…configurations @/Roboshield Payload configurations. #760
- Loading branch information
Showing
26 changed files
with
101 additions
and
21 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
6 changes: 3 additions & 3 deletions
6
apps/roboshield/src/components/LongFormExternalEmbed/LongFormExternalEmbed.tsx
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,28 @@ | ||
import { NextApiRequest, NextApiResponse } from "next"; | ||
|
||
type User = object; | ||
|
||
interface CustomNextApiRequest extends NextApiRequest { | ||
user: User; | ||
query: { | ||
slug: string; | ||
[key: string]: string | string[]; | ||
}; | ||
} | ||
|
||
export default async function handler( | ||
req: CustomNextApiRequest, | ||
res: NextApiResponse, | ||
) { | ||
if (!req.user) { | ||
return res.status(401).json({ message: "UNAUTHORIZED_USER" }); | ||
} | ||
const { slug = "/" } = req.query; | ||
res.setDraftMode({ enable: true }); | ||
const appUrl = new URL(process.env.NEXT_PUBLIC_APP_URL ?? ""); | ||
const requestedUrl = new URL(slug, appUrl); | ||
if (requestedUrl.origin !== appUrl.origin) { | ||
return res.status(401).json({ message: "UNAUTHORIZED_REDIRECT" }); | ||
} | ||
return res.redirect(requestedUrl.pathname); | ||
} |
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,19 +1,21 @@ | ||
import { Block } from "payload/types"; | ||
import { RichText } from "./RichText"; | ||
import { MediaBlock } from "./MediaBlock"; | ||
import { ExternalEmbedd } from "./ExternalEmbedd"; | ||
import { ExternalEmbed } from "./ExternalEmbed"; | ||
|
||
export const Content: Block = { | ||
slug: "content", | ||
labels: { | ||
singular: "Content", | ||
plural: "Content", | ||
}, | ||
imageURL: "/images/cms/blocks/blog.png", | ||
imageAltText: "Used in About page. Allows addition of blog like content", | ||
fields: [ | ||
{ | ||
type: "blocks", | ||
name: "content", | ||
blocks: [RichText, MediaBlock, ExternalEmbedd], | ||
blocks: [RichText, MediaBlock, ExternalEmbed], | ||
}, | ||
], | ||
}; |
10 changes: 5 additions & 5 deletions
10
...ield/src/payload/blocks/ExternalEmbedd.ts → ...hield/src/payload/blocks/ExternalEmbed.ts
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
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
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,17 @@ | ||
import formatPagePath from "./formatPagePath"; | ||
import { Document } from "payload/types"; | ||
|
||
const payloadUrl = | ||
process.env.PAYLOAD_PUBLIC_APP_URL || process.env.NEXT_PUBLIC_APP_URL; | ||
|
||
function formatDraftUrl(collection: string, doc: Document) { | ||
const pagePath = formatPagePath(collection, doc); | ||
if (pagePath) { | ||
const slug = pagePath; | ||
const url = new URL(`/api/draft?slug=${slug}`, payloadUrl); | ||
return url.href; | ||
} | ||
return null; | ||
} | ||
|
||
export default formatDraftUrl; |