diff --git a/frontend/src/components/Posts.jsx b/frontend/src/components/Posts.jsx
index dd06e41..699498f 100644
--- a/frontend/src/components/Posts.jsx
+++ b/frontend/src/components/Posts.jsx
@@ -17,13 +17,12 @@ import InfiniteScroll from "react-infinite-scroll-component";
import { Navigate, useNavigate } from "react-router-dom";
import SearchBar from "./SearchBar";
import { useUser } from "../hook/useUser";
-import Loader from "./loading";
-import { InfinitySpin } from "react-loader-spinner";
import { gsap } from "gsap";
import { useRef } from "react";
import parse from "html-react-parser";
import DOMPurify from "dompurify";
import Linkify from "linkify-react";
+import "../styles/link.css";
const Posts = () => {
const [posts, setPosts] = useState([]);
@@ -38,6 +37,19 @@ const Posts = () => {
const toast = useToast();
const fetchInitialized = useRef(false);
+ const options = {
+ attributes: {
+ target: "_blank",
+ rel: "noopener noreferrer",
+ },
+ className: "custom-link",
+ defaultProtocol: "https",
+ format: (value) => value,
+ formatHref: (href) => href,
+ tagName: "a",
+ validate: true,
+ };
+
const fetchPosts = async (pageParam = page) => {
try {
let collegeId = selectedCommunity === "all" ? null : selectedCommunity;
@@ -226,7 +238,9 @@ const Posts = () => {
{post.User.username}
- {parse(DOMPurify.sanitize(post.content))}
+
+ {parse(DOMPurify.sanitize(post.content))}
+
diff --git a/frontend/src/components/SinglePost.jsx b/frontend/src/components/SinglePost.jsx
index 09e88d7..35d07ce 100644
--- a/frontend/src/components/SinglePost.jsx
+++ b/frontend/src/components/SinglePost.jsx
@@ -23,9 +23,9 @@ import { gsap } from "gsap";
import axios from "axios";
import CreateComment from "./CreateComment";
import { useUser } from "../hook/useUser";
-import { InfinitySpin } from "react-loader-spinner";
import DeleteConfirmation from "./DeleteConfirmation";
import { FaTrash } from "react-icons/fa";
+import "../styles/link.css";
const SinglePost = () => {
const { id } = useParams();
@@ -43,6 +43,19 @@ const SinglePost = () => {
const toast = useToast();
const navigate = useNavigate();
+ const options = {
+ attributes: {
+ target: "_blank",
+ rel: "noopener noreferrer",
+ },
+ className: "custom-link",
+ defaultProtocol: "https",
+ format: (value) => value,
+ formatHref: (href) => href,
+ tagName: "a",
+ validate: true,
+ };
+
useEffect(() => {
const fetchPost = async () => {
try {
@@ -244,7 +257,9 @@ const SinglePost = () => {
- {parse(DOMPurify.sanitize(post.content))}
+
+ {parse(DOMPurify.sanitize(post.content))}
+
@@ -328,7 +343,7 @@ const SinglePost = () => {
- {comment.content}
+ {comment.content}
{comment.User.user_id === userDetails.user_id && (
diff --git a/frontend/src/styles/link.css b/frontend/src/styles/link.css
new file mode 100644
index 0000000..5299cba
--- /dev/null
+++ b/frontend/src/styles/link.css
@@ -0,0 +1,8 @@
+.custom-link {
+ color: #4a90e2;
+ text-decoration: none;
+}
+
+.custom-link:hover {
+ text-decoration: underline;
+}