import React from "react"; import Head from "next/head"; import { renderHTML } from "@agility/nextjs"; import { AgilityImage } from "@agility/nextjs"; import truncate from "truncate-html"; import Link from "next/link"; import Image from "next/image" const PostDetails = ({ dynamicPageItem }: any) => { // post fields const post = dynamicPageItem.fields; const productJSON = post.product const product = JSON.parse(productJSON) // format date const dateStr = new Date(post.date).toLocaleDateString(); const description = truncate(post.content, { length: 160, decodeEntities: true, stripTags: true, reserveLastWord: true, }); let imageSrc = post.image?.url || null; // post image alt let imageAlt = post.image?.label || null; let ogImageSrc = `${imageSrc}?w=1600&h=900` let imageHeight = 900 let imageWidth = 1600 return ( <>
{product.name}
{product.name}
{dateStr}

{post.title}

); }; PostDetails.getCustomInitialProps = async () => { return { cloud_name: process.env.CLOUDINARY_CLOUD_NAME } } export default PostDetails;