Skip to content

Commit

Permalink
add RawHTML block
Browse files Browse the repository at this point in the history
  • Loading branch information
linobino1 committed Sep 27, 2024
1 parent f7c5a3f commit b46be01
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/components/Blocks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ export const Block: React.FC<BlockProps> = ({ block, ...props }) => {
</Gutter>
);

case "rawHTML":
return (
<Gutter>
<div
dangerouslySetInnerHTML={{
__html: block.html,
}}
/>
</Gutter>
);

default:
case "outlet":
return children as React.ReactElement;
Expand Down
20 changes: 20 additions & 0 deletions cms/blocks/RawHTML.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Block } from "payload/types";
import { t } from "../i18n";

export const RawHTML: Block = {
slug: "rawHTML",
labels: {
singular: t("HTML"),
plural: t("HTML"),
},
fields: [
{
name: "html",
label: t("Content"),
type: "code",
required: true,
},
],
};

export default RawHTML;
2 changes: 2 additions & 0 deletions cms/fields/pageLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Heading } from "../blocks/Heading";
import { Image } from "../blocks/Image";
import { Gallery } from "../blocks/Gallery";
import { Video } from "../blocks/Video";
import { RawHTML } from "../blocks/RawHTML";
import { t } from "../i18n";
import Events from "../blocks/Events";

Expand Down Expand Up @@ -38,6 +39,7 @@ export const pageLayout = (props?: Props): Field => {
Gallery,
Video,
Events,
RawHTML,
],
defaultValue: defaultLayout,
},
Expand Down

0 comments on commit b46be01

Please sign in to comment.