|
1 | | -import { capitalize } from "lodash"; |
2 | | -import React from "react"; |
3 | | -import { FaGithub, FaXTwitter } from "react-icons/fa6"; |
4 | | - |
5 | 1 | import { ApiArticle } from "@/cms/api/ApiArticle"; |
6 | 2 |
|
7 | | -type ChipProps = { children: React.ReactNode; href: string; type: "twitter" | "github" }; |
8 | | - |
9 | | -const Chip = ({ children, href, type }: ChipProps) => { |
10 | | - const kype = capitalize(type); |
11 | | - const Icon = type === "twitter" ? FaXTwitter : FaGithub; |
12 | | - |
13 | | - const classes = ["Post__Footer__Chip", `Post__Footer__Chip--${kype}`].join(" "); |
14 | | - |
15 | | - return ( |
16 | | - <a className={classes} href={href} target="blank"> |
17 | | - <Icon className="Post__Footer__Chip__Icon" /> |
18 | | - {children} |
19 | | - </a> |
20 | | - ); |
21 | | -}; |
22 | | - |
23 | 3 | type FooterProps = { post: ApiArticle }; |
24 | 4 |
|
25 | 5 | export function Footer({ post }: FooterProps) { |
26 | | - const githubEditUrl = `https://github.com/codecoolture/codecoolture.com/edit/trunk/cms/content${post.url}.mdx`; |
27 | 6 | const shareableUrl = `https://codecoolture.com${post.url}`; |
28 | 7 | const tweet = encodeURIComponent(`Check out "${post.title}" by @codecoolture\n\n`); |
29 | 8 |
|
30 | 9 | return ( |
31 | 10 | <footer className="Post__Footer"> |
32 | | - <Chip type="twitter" href={`https://x.com/intent/tweet?url=${encodeURIComponent(shareableUrl)}&text=${tweet}`}> |
33 | | - Share on Twitter |
34 | | - </Chip> |
35 | | - |
36 | | - <Chip type="github" href={githubEditUrl}> |
37 | | - Edit on GitHub |
38 | | - </Chip> |
| 11 | + <nav> |
| 12 | + <ul className="Post__Footer__List"> |
| 13 | + <li className="Post__Footer__ListItem"> |
| 14 | + <a |
| 15 | + className="Post__Footer__Link" |
| 16 | + href={`https://x.com/intent/tweet?url=${encodeURIComponent(shareableUrl)}&text=${tweet}`} |
| 17 | + > |
| 18 | + Share |
| 19 | + </a> |
| 20 | + </li> |
| 21 | + |
| 22 | + <li className="Post__Footer__ListItem"> |
| 23 | + <a |
| 24 | + className="Post__Footer__Link" |
| 25 | + href={`https://github.com/codecoolture/codecoolture.com/edit/trunk/cms/content${post.url}.mdx`} |
| 26 | + > |
| 27 | + Edit on GitHub |
| 28 | + </a> |
| 29 | + </li> |
| 30 | + </ul> |
| 31 | + </nav> |
39 | 32 | </footer> |
40 | 33 | ); |
41 | 34 | } |
0 commit comments