mirror of https://github.com/sunface/rust-course
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.6 KiB
35 lines
1.6 KiB
|
5 years ago
|
import React from "react"
|
||
|
5 years ago
|
import {chakra, Heading, Image, Text, HStack,Button, Flex,PropsOf,Box, Avatar, VStack, propNames} from "@chakra-ui/react"
|
||
|
5 years ago
|
import { Tag } from "src/types/tag"
|
||
|
|
import { ReserveUrls } from "src/data/reserve-urls"
|
||
|
|
import NextLink from "next/link"
|
||
|
5 years ago
|
import { Story } from "src/types/story"
|
||
|
5 years ago
|
import moment from 'moment'
|
||
|
|
import { FaGithub } from "react-icons/fa"
|
||
|
|
import Link from "next/link"
|
||
|
|
import { useRouter } from "next/router"
|
||
|
|
|
||
|
|
type Props = PropsOf<typeof chakra.div> & {
|
||
|
5 years ago
|
size?: 'lg' | 'md'
|
||
|
5 years ago
|
story : Story
|
||
|
5 years ago
|
showFooter?: boolean
|
||
|
5 years ago
|
}
|
||
|
|
|
||
|
5 years ago
|
export const StoryAuthor= ({story,showFooter=true,size='lg'}:Props) =>{
|
||
|
5 years ago
|
const router = useRouter()
|
||
|
|
return (
|
||
|
|
<HStack spacing="4">
|
||
|
5 years ago
|
<Avatar src={story.creator.avatar} size={size} onClick={() => router.push(`/${story.creator.username}`)} cursor="pointer"/>
|
||
|
5 years ago
|
<VStack alignItems="left" spacing="1">
|
||
|
5 years ago
|
<Heading size="sm" onClick={() => router.push(`/${story.creator.username}`)} cursor="pointer">{story.creator.nickname === "" ? story.creator.username : story.creator.nickname}</Heading>
|
||
|
|
<Text layerStyle="textSecondary" fontSize={size==='lg' ? ".9rem" : ".8rem"}>发布于<chakra.span fontWeight="600" ml="1">{moment(story.created).fromNow()}</chakra.span></Text>
|
||
|
5 years ago
|
{showFooter && <HStack layerStyle="textSecondary" fontSize=".9rem" spacing="3">
|
||
|
5 years ago
|
<FaGithub /> <chakra.span>4 min read</chakra.span>
|
||
|
5 years ago
|
</HStack>}
|
||
|
5 years ago
|
</VStack>
|
||
|
|
</HStack>
|
||
|
|
)
|
||
|
|
}
|
||
|
|
|
||
|
5 years ago
|
export default StoryAuthor
|