import { Page } from 'web/components/page'
import { postPath, getPostBySlug } from 'web/lib/firebase/posts'
import { Post } from 'common/post'
import { Title } from 'web/components/title'
import { Spacer } from 'web/components/layout/spacer'
import { Content } from 'web/components/editor'
import { getUser, User } from 'web/lib/firebase/users'
import { ShareIcon } from '@heroicons/react/solid'
import clsx from 'clsx'
import { Button } from 'web/components/button'
import { useState } from 'react'
import { SharePostModal } from 'web/components/share-post-modal'
import { Row } from 'web/components/layout/row'
import { Col } from 'web/components/layout/col'
import { ENV_CONFIG } from 'common/envs/constants'
import Custom404 from 'web/pages/404'
import { UserLink } from 'web/components/user-link'
export async function getStaticProps(props: { params: { slugs: string[] } }) {
  const { slugs } = props.params
  const post = await getPostBySlug(slugs[0])
  const creator = post ? await getUser(post.creatorId) : null
  return {
    props: {
      post: post,
      creator: creator,
    },
    revalidate: 60, // regenerate after a minute
  }
}
export async function getStaticPaths() {
  return { paths: [], fallback: 'blocking' }
}
export default function PostPage(props: { post: Post; creator: User }) {
  const [isShareOpen, setShareOpen] = useState(false)
  if (props.post == null) {
    return 
  }
  const shareUrl = `https://${ENV_CONFIG.domain}${postPath(props?.post.slug)}`
  return (
    
      
        
        
        
          
            
          
          
            
          
        
        
        
       
    
  )
}