Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions frontend/features/project/ImageBlock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Box, Img } from "@chakra-ui/react";
import { STRAPI_URL } from "@config/env";
import React from "react";
import {
Block,
BlockComponentProps,
BlocksControls,
} from "react-tinacms-inline";

export type ImageBlockData = BlockTemplateData<
"image",
{
id: string;
url: string;
alternativeText: Nullable<string>;
}
>;

interface ImageBlockProps {
url: string;
}

export function ImageBlock({ url }: ImageBlockProps) {
return (
<Box mx="auto" my="8" w={{ base: "full", md: "container.md" }}>
<Img
href={`${STRAPI_URL}${url}`}
w={{
base: "full",
md: "calc(100vw - 80px)",
xl: "container.lg",
}}
ml={{
base: "0",
md: "calc((-100vw + 780px) / 2)",
xl: "64",
}}
display="block"
my="10"
boxShadow="rgb(0 0 0 / 15%) 0px 4px 20px 0px"
></Img>
</Box>
);
}

function BlockComponent({ index, data }: BlockComponentProps) {
return (
<BlocksControls index={index} focusRing={{ offset: 0 }} insetControls>
<ImageBlock {...data} />
</BlocksControls>
);
}

export const imageBlock: Block = {
Component: BlockComponent,
template: {
label: "Image block",
defaultItem: {},
fields: [
{
name: "image",
component: "Image",
label: "Image",
},
],
},
};
3 changes: 0 additions & 3 deletions frontend/pages/[[...slug]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ const StyledInlineBlocks = chakra(InlineBlocks);

export default function DynamicPage({ data: data, preview }: DynamicPageProps) {
const { colorMode } = useColorMode();

console.log("data slug", data);

const itemProps = React.useMemo<BlockItemProps>(() => {
return {
isPreview: preview,
Expand Down
9 changes: 2 additions & 7 deletions frontend/pages/projects/[...handle].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ interface ProjectData {
projectType: Nullable<string>;
image: Nullable<ProjectImage>;
localizations?: LocalizationsData[];
blocks: string;
blocks: null;
}

interface ProjectImage {
Expand All @@ -73,7 +73,6 @@ interface DynamicPageProps {
}

export default function DynamicPage({ data: data }: DynamicPageProps) {
console.log("data", JSON.stringify(data, null, " "));
const [_, form] = useProjectPlugin(data);
const router = useRouter();

Expand Down Expand Up @@ -237,8 +236,6 @@ export const getStaticPaths: GetStaticPaths = async (context) => {
const slugArray: any =
pagePath.length > 0 ? pagePath.split("/") : undefined;

console.log("slugArray", slugArray);

return {
params: { handle: slugArray },
locale: page.locale!,
Expand All @@ -259,8 +256,6 @@ export const getStaticProps: GetStaticProps<
}
const preview = context.preview === true;

console.log("path", path);

const availableProjects = await fetchGraphQL<
GetProjectsQuery,
GetProjectsQueryVariables
Expand Down Expand Up @@ -349,7 +344,7 @@ function getProjectData(
linkPath: project.linkPath || null,
path: project.path,
locale: project.locale || null,
blocks: "aa",
blocks: null,
image: project.image
? {
id: project.image.id,
Expand Down