/** Copyright 2021 Forestry.io Holdings, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import React from "react"; import format from "date-fns/format"; import { TinaMarkdown } from "tinacms/dist/rich-text"; import { Prism } from "tinacms/dist/rich-text/prism"; import type { TinaMarkdownContent, Components } from "tinacms/dist/rich-text"; const components: Components<{ BlockQuote: { children: TinaMarkdownContent; }; DateTime: { format?: string; }; NewsletterSignup: { placeholder: string; buttonText: string; children: TinaMarkdownContent; disclaimer?: TinaMarkdownContent; }; }> = { code_block: (props) => , BlockQuote: (props: { children: TinaMarkdownContent; }) => { return (
); }, DateTime: (props) => { const dt = React.useMemo(() => { return new Date(); }, []); switch (props.format) { case "iso": return {dt.toISOString()}; case "utc": return {dt.toUTCString()}; case "local": return {dt.toLocaleDateString()}; default: return {dt.toLocaleDateString()}; } }, NewsletterSignup: (props) => { return (
{props.disclaimer && }
); }, img: (props) => (
{props.alt}
), }; export const Post = (props) => { const titleColorClasses = { blue: "from-blue-400 to-blue-600 dark:from-blue-300 dark:to-blue-500", teal: "from-teal-400 to-teal-600 dark:from-teal-300 dark:to-teal-500", green: "from-green-400 to-green-600", red: "from-red-400 to-red-600", pink: "from-pink-300 to-pink-500", purple: "from-purple-400 to-purple-600 dark:from-purple-300 dark:to-purple-500", orange: "from-orange-300 to-orange-600 dark:from-orange-200 dark:to-orange-500", yellow: "from-yellow-400 to-yellow-500 dark:from-yellow-300 dark:to-yellow-500", }; const date = new Date(props.date); let formattedDate = ""; if (!isNaN(date.getTime())) { formattedDate = format(date, "MMM dd, yyyy"); } return (

{props.title}

{props.heroImg && (
)}
); };