Skip to content

Commit

Permalink
fix blog share buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
AahilRafiq committed May 31, 2024
1 parent 053add0 commit 42dead0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 39 deletions.
10 changes: 1 addition & 9 deletions src/app/blogs/[slug]/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import MoreBlogsSection from "@/components/blogs/MoreBlogsSection"
import { getStrapiMedia } from "@/helpers/strapi_api"
import Markdown from "react-markdown"
import ShareSection from "@/components/blogs/ShareSection"
import Head from "next/head"
import 'highlight.js/styles/atom-one-dark.css';
import rehypeHighlight from "rehype-highlight"

Expand All @@ -31,13 +30,6 @@ export default async function Page({ params }) {

return (
<>
{/* Meta */}
<Head>
<title>{title} - WebClub NITK</title>
<meta property="og:title" content={title} />
<meta property="og:image" content={cover_image} />
</Head>

<section className="w-full lg:h-24 h-20 flex items-center justify-center bg-accent-900 bg-cover bg-center">
</section>
{/* Blog content */}
Expand Down Expand Up @@ -100,7 +92,7 @@ export default async function Page({ params }) {

{/* Share section */}
<div className="mb-6">
<ShareSection/>
<ShareSection title={title}/>
</div>

{/* Categories section */}
Expand Down
27 changes: 0 additions & 27 deletions src/components/blogs/BlogCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ export default function BlogCard({ slug, attributes}) {
width="300"
/>

<div className="absolute top-4 left-4 flex items-center space-x-2">
<PodcastIcon className="h-6 w-6 text-primary-700" />
<span className="text-sm font-semibold text-primary-700">WebClub Blogs</span>
</div>

</div>

<div className="flex-grow flex flex-col justify-between">
Expand Down Expand Up @@ -71,26 +66,4 @@ export default function BlogCard({ slug, attributes}) {
</Card>
</Link>
)
}

function PodcastIcon(props) {
return (
<svg
{...props}
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="M16.85 18.58a9 9 0 1 0-9.7 0" />
<path d="M8 14a5 5 0 1 1 8 0" />
<circle cx="12" cy="11" r="1" />
<path d="M13 17a1 1 0 1 0-2 0l.5 4.5a.5.5 0 1 0 1 0Z" />
</svg>
)
}
7 changes: 4 additions & 3 deletions src/components/blogs/ShareSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TwitterIcon } from "../icons/twitter";
import { FacebookIcon } from "../icons/facebook";
import { Linkedin } from "lucide-react";

export default function ShareSection() {
export default function ShareSection({title}) {
const pathname = usePathname();
const [currentUrl, setCurrentUrl] = useState("");

Expand All @@ -15,7 +15,8 @@ export default function ShareSection() {
}
}, [pathname]);

const shareText = "Check out this blog from WebClub NITK";
const shareText =
`Check out this blog from WebClub NITK\n${title}\n`;

return (
<>
Expand All @@ -27,7 +28,7 @@ export default function ShareSection() {
<a href={`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(currentUrl)}&quote=${encodeURIComponent(shareText)}`} target="_blank" rel="noopener noreferrer">
<FacebookIcon className="bg-blue-700 text-white p-2 rounded-full h-10 w-10" />
</a>
<a href={`https://www.linkedin.com/shareArticle?url=${encodeURIComponent(currentUrl)}&summary=${encodeURIComponent(shareText)}`} target="_blank" rel="noopener noreferrer" className="p-2">
<a href={`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(currentUrl)}`} target="_blank" rel="noopener noreferrer" className="p-2">
<Linkedin className="h-6 w-6"/>
</a>
</div>
Expand Down

0 comments on commit 42dead0

Please sign in to comment.