// Dependencies import { nsMerge, capitalize, cloudflareImageUrl, yyyymmdd } from 'shared/utils.mjs' // Hooks import { useState, useEffect } from 'react' import { useAccount } from 'shared/hooks/use-account.mjs' import { useBackend } from 'shared/hooks/use-backend.mjs' import { useToast } from 'shared/hooks/use-toast.mjs' import { useTranslation } from 'next-i18next' // Components import { Popout } from 'shared/components/popout/index.mjs' import { AuthWrapper, ns as authNs } from 'shared/components/wrappers/auth/index.mjs' import { DesignPicker } from './design-picker.mjs' import { TitleInput, SlugInput, ImageInput, CaptionInput, IntroInput, BodyInput, } from './inputs.mjs' import { Collapse } from 'shared/components/collapse.mjs' import { Tab } from 'shared/components/account/bio.mjs' import { CodeBox } from 'shared/components/code-box.mjs' import { PostArticle } from 'site/components/mdx/posts/article.mjs' export const ns = nsMerge('account', authNs) const Title = ({ children }) => (

{children}

) const Tip = ({ children }) =>

{children}

const Item = ({ title, children }) => (
{title}
{children}
) export const CreateShowcasePost = ({ noTitle = false }) => { const { account } = useAccount() const backend = useBackend() const toast = useToast() const { t } = useTranslation(ns) const [designs, setDesigns] = useState([]) const [title, setTitle] = useState('') const [slug, setSlug] = useState(false) const [img, setImg] = useState(false) const [caption, setCaption] = useState('') const [intro, setIntro] = useState('') const [body, setBody] = useState('') const [extraImages, setExtraImages] = useState({}) const [activeTab, setActiveTab] = useState('create') // Shared props for tabs const tabProps = { activeTab, setActiveTab, t } const addImage = () => { const id = Object.keys(extraImages).length + 1 const newImages = { ...extraImages } newImages[id] = null setExtraImages(newImages) } const setExtraImg = (key, img) => { console.log('setting extra', { key, img }) const newImages = { ...extraImages } newImages[key] = img setExtraImages(newImages) } return (
{!noTitle &&

{t('showcaseNew')}

} {t('showcaseNewInfo')}
{activeTab === 'create' ? ( <> Designs:{' '} {designs.map((d) => capitalize(d)).join(', ')} } > Pick one or more designs that are featured in this post. Title: {title} } > Give your post a title. A good title is more than just a few words. Slug: {slug} } > The slug is the part of the URL that uniquely identifies the post. We can generate one based on the title, but you can also customize it. Main Image: {img} } > The main image will be shown at the top of the post, and as the only image on the showcase index page. Main Image Caption: {caption} } > The caption is the text that goes under the main image. Can include copyrights/credits. Markdown is allowed. Intro: {intro} } > A brief paragraph that will be shown on post previews on social media and so on. Additional Images: {Object.keys(extraImages).length} } > {img ? ( <> Here you can add any images you want to include in the post body. {Object.keys(extraImages).map((key) => { const markup = '![The image alt goes here](' + cloudflareImageUrl({ id: extraImages[key], variant: 'public' }) + ' "The image caption/title goes here")' return ( <> setExtraImg(key, img)} type="showcase" subId={key} img={extraImages[key]} slug={slug} /> {extraImages[key] && ( <>

To include this image in your post, use this markdown snippet:

)} ) })} ) : ( Please add a main image first )}
Post body: {body.slice(0, 30) + '...'} } > The actual post body. Supports Markdown. ) : ( <>

{title}

)}
) }