1
- import { useRouter } from "next/router" ;
2
- import { useTranslation } from "next-i18next" ;
3
- import { Badge } from "@chakra-ui/react" ;
1
+ import { useRouter } from "next/router"
2
+ import { useTranslation } from "next-i18next"
3
+ import { Badge } from "@chakra-ui/react"
4
4
5
- import type { Lang , TranslationKey } from "@/lib/types" ;
6
- import { TutorialFrontmatter } from "@/lib/interfaces" ;
5
+ import type { Lang , TranslationKey } from "@/lib/types"
6
+ import { TutorialFrontmatter } from "@/lib/interfaces"
7
7
8
- import CopyToClipboard from "@/components/CopyToClipboard" ;
9
- import Emoji from "@/components/Emoji" ;
10
- import InlineLink from "@/components/Link" ;
11
- import Translation from "@/components/Translation" ;
12
- import TutorialTags from "@/components/TutorialTags" ;
8
+ import CopyToClipboard from "@/components/CopyToClipboard"
9
+ import Emoji from "@/components/Emoji"
10
+ import InlineLink from "@/components/Link"
11
+ import Translation from "@/components/Translation"
12
+ import TutorialTags from "@/components/TutorialTags"
13
13
14
- import { getLocaleTimestamp } from "@/lib/utils/time" ;
15
- import { Flex } from "./ui/flex" ;
14
+ import { getLocaleTimestamp } from "@/lib/utils/time"
15
+
16
+ import { Flex } from "./ui/flex"
16
17
17
18
export type TutorialMetadataProps = {
18
- frontmatter : TutorialFrontmatter ;
19
- timeToRead : number ;
20
- } ;
19
+ frontmatter : TutorialFrontmatter
20
+ timeToRead : number
21
+ }
21
22
22
23
export enum Skill {
23
24
BEGINNER = "beginner" ,
@@ -27,67 +28,66 @@ export enum Skill {
27
28
28
29
export const getSkillTranslationId = ( skill : Skill ) : TranslationKey =>
29
30
`page-developers-tutorials:page-tutorial-${ Skill [ skill . toUpperCase ( ) as keyof typeof Skill ]
30
- } `;
31
+ } `
31
32
32
33
const TutorialMetadata = ( {
33
34
frontmatter,
34
35
timeToRead,
35
36
} : TutorialMetadataProps ) => {
36
- const { locale } = useRouter ( ) ;
37
- const { t } = useTranslation ( "page-developers-tutorials" ) ;
37
+ const { locale } = useRouter ( )
38
+ const { t } = useTranslation ( "page-developers-tutorials" )
38
39
39
- const hasSource = frontmatter . source && frontmatter . sourceUrl ;
40
- const published = frontmatter . published ;
41
- const author = frontmatter . author ;
42
- const address = frontmatter . address ;
40
+ const hasSource = frontmatter . source && frontmatter . sourceUrl
41
+ const published = frontmatter . published
42
+ const author = frontmatter . author
43
+ const address = frontmatter . address
43
44
44
45
return (
45
- < Flex className = " flex-col justify-between pb-2 border-b-0 lg: border-b border- border" >
46
- < Flex className = " justify-between items-center w-full mb-8 " >
47
- < div className = "flex flex-wrap w-full " >
46
+ < Flex className = "flex-col justify-between border-b-0 border-border pb-2 lg: border-b " >
47
+ < Flex className = "mb-8 w-full items-center justify-between " >
48
+ < Flex className = "w-full flex-wrap" >
48
49
< TutorialTags tags = { frontmatter . tags } />
49
- </ div >
50
- < Badge variant = "secondary" className = "self-start mb-2 whitespace-nowrap" >
50
+ </ Flex >
51
+ < Badge
52
+ variant = "secondary"
53
+ className = "mb-2 self-start whitespace-nowrap"
54
+ >
51
55
{ t ( getSkillTranslationId ( frontmatter . skill as Skill ) ) }
52
56
</ Badge >
53
57
</ Flex >
54
- < div className = "flex flex-wrap gap-4 mt-[-1rem] text-sm text-text300 mb-6 " >
58
+ < Flex className = "text-text300 mb-6 mt-[-1rem] flex-wrap gap-4 text-sm " >
55
59
{ author && (
56
60
< div >
57
61
< Emoji className = "me-2 text-sm" text = ":writing_hand:" />
58
62
{ author }
59
63
</ div >
60
64
) }
61
65
{ hasSource && (
62
- < div >
66
+ < div >
63
67
< Emoji className = "me-2 text-sm" text = ":books:" />
64
68
< InlineLink href = { frontmatter . sourceUrl } >
65
69
{ frontmatter . source }
66
70
</ InlineLink >
67
71
</ div >
68
72
) }
69
73
{ published && (
70
- < div >
74
+ < div >
71
75
< Emoji className = "me-2 text-sm" text = ":calendar:" /> { " " }
72
76
{ getLocaleTimestamp ( locale ! as Lang , published ) }
73
77
</ div >
74
78
) }
75
- < div >
76
- < Emoji className = "me-2 text-sm" text = ":stopwatch:" />
79
+ < div >
80
+ < Emoji className = "me-2 text-sm" text = ":stopwatch:" />
77
81
{ timeToRead } { t ( "comp-tutorial-metadata-minute-read" ) } minute read
78
82
</ div >
79
- </ div >
83
+ </ Flex >
80
84
{ address && (
81
- < div className = "flex flex-wrap mt-[-1rem] text-sm text-text300 mb-6 " >
85
+ < Flex className = "text-text300 mb-6 mt-[-1rem] flex-wrap text-sm " >
82
86
< CopyToClipboard text = { address } >
83
87
{ ( isCopied ) => (
84
- < div
85
- className = "text-primary cursor-pointer overflow-hidden text-ellipsis font-mono bg-ednBackground px-1 text-sm hover:bg-primary100"
86
- >
88
+ < div className = "bg-ednBackground hover:bg-primary100 cursor-pointer overflow-hidden text-ellipsis px-1 font-mono text-sm text-primary" >
87
89
< div className = "uppercase" >
88
- < Translation
89
- id = "comp-tutorial-metadata-tip-author"
90
- /> { " " }
90
+ < Translation id = "comp-tutorial-metadata-tip-author" /> { " " }
91
91
</ div >
92
92
{ address } { isCopied && < Translation id = "copied" /> }
93
93
{ isCopied && (
@@ -96,10 +96,10 @@ const TutorialMetadata = ({
96
96
</ div >
97
97
) }
98
98
</ CopyToClipboard >
99
- </ div >
99
+ </ Flex >
100
100
) }
101
101
</ Flex >
102
- ) ;
103
- } ;
102
+ )
103
+ }
104
104
105
- export default TutorialMetadata ;
105
+ export default TutorialMetadata
0 commit comments