diff --git a/public/images/linkedin-icon.svg b/public/images/linkedin-icon.svg new file mode 100644 index 000000000..7929cb179 --- /dev/null +++ b/public/images/linkedin-icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/components/Blog/ContentTable/index.tsx b/src/components/Blog/ContentsTable/index.tsx similarity index 57% rename from src/components/Blog/ContentTable/index.tsx rename to src/components/Blog/ContentsTable/index.tsx index e8de5c6f9..972171424 100644 --- a/src/components/Blog/ContentTable/index.tsx +++ b/src/components/Blog/ContentsTable/index.tsx @@ -1,12 +1,11 @@ import kebabCase from 'lodash/kebabCase' -import css from '../styles.module.css' import { BLOCKS, type Document as ContentfulDocument, type Text } from '@contentful/rich-text-types' import { isText } from '@/lib/typeGuards' import { useMemo } from 'react' import { scrollToElement } from '@/lib/scrollSmooth' import { Typography } from '@mui/material' -const ContentTable = ({ content }: { content: ContentfulDocument }) => { +const ContentsTable = ({ content }: { content: ContentfulDocument }) => { const handleContentTableClick = (e: React.MouseEvent, target: string) => { e.preventDefault() @@ -26,24 +25,22 @@ const ContentTable = ({ content }: { content: ContentfulDocument }) => { ) return ( - + return ( +
  • + + handleContentTableClick(e, headingKey)} href={`#${headingKey}`}> + {heading.text} + + +
  • + ) + })} + ) } -export default ContentTable +export default ContentsTable diff --git a/src/components/Blog/Post/index.tsx b/src/components/Blog/Post/index.tsx index 52ce82317..2d8a9ff45 100644 --- a/src/components/Blog/Post/index.tsx +++ b/src/components/Blog/Post/index.tsx @@ -11,7 +11,8 @@ import BreadcrumbsNav from '@/components/Blog/BreadcrumbsNav' import Tags from '@/components/Blog/Tags' import Authors from '@/components/Blog/Authors' import RichText from '@/components/Campaign/RichText' -import ContentTable from '@/components/Blog/ContentTable' +import ContentsTable from '@/components/Blog/ContentsTable' +import Socials from '@/components/Blog/Socials' import RelatedPosts from '@/components/Blog/RelatedPosts' import CategoryIcon from '@/public/images/Blog/category-icon.svg' import css from '../styles.module.css' @@ -27,15 +28,6 @@ const BlogPost = ({ blogPost }: { blogPost: BlogPostEntry }) => { - {isAsset(coverImage) && coverImage.fields.file?.url ? ( - {(coverImage.fields.title - ) : undefined} -
    @@ -65,10 +57,21 @@ const BlogPost = ({ blogPost }: { blogPost: BlogPostEntry }) => { - + + {isAsset(coverImage) && coverImage.fields.file?.url ? ( + {(coverImage.fields.title + ) : undefined} diff --git a/src/components/Blog/Socials/index.tsx b/src/components/Blog/Socials/index.tsx new file mode 100644 index 000000000..1dd01a545 --- /dev/null +++ b/src/components/Blog/Socials/index.tsx @@ -0,0 +1,40 @@ +import { useRouter } from 'next/router' +import { AppRoutes } from '@/config/routes' +import XIcon from '@/public/images/x-icon.svg' +import LinkedinIcon from '@/public/images/linkedin-icon.svg' +import { type Entry } from 'contentful' +import { type TypeAuthorSkeleton } from '@/contentful/types' +import { IconButton, SvgIcon } from '@mui/material' +import css from '../styles.module.css' + +const Socials = ({ title, authors }: { title: string; authors: Entry[] }) => { + const router = useRouter() + + const currentUrl = `${AppRoutes.blog}${router.asPath}` + + const sharingText = `${title} by @${authors + .map((author) => author.fields.name) + .join(', @') + .toString()}` + + const xUrl = `https://twitter.com/intent/tweet?url=${encodeURIComponent(currentUrl)}&text=${encodeURIComponent( + sharingText, + )}` + const linkedinUrl = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(currentUrl)}` + + return ( +
    + {/* X */} + + + + + {/* Linkedin */} + + + +
    + ) +} + +export default Socials diff --git a/src/components/Blog/styles.module.css b/src/components/Blog/styles.module.css index 5ff4f09c8..868e6b1dd 100644 --- a/src/components/Blog/styles.module.css +++ b/src/components/Blog/styles.module.css @@ -71,15 +71,25 @@ color: var(--mui-palette-primary-main); } -.contentTable ul { +.sidebar ul { padding-left: 0px; list-style: none; } -.contentTable li { +.sidebar li { margin-bottom: 8px; } +.socials { + display: flex; + gap: 16px; +} + +.socials svg { + width: 24px; + height: 24px; +} + @media (min-width: 900px) { .title { margin-top: 24px; @@ -93,7 +103,7 @@ flex-direction: row-reverse; } - .contentTable { + .sidebar { position: sticky; top: calc(var(--header-height) + 24px); }