From deb6993edaa27b5de26cc04a3a4e634c3bb11cac Mon Sep 17 00:00:00 2001 From: Eddie Jaoude Date: Fri, 24 Nov 2023 11:07:39 +0100 Subject: [PATCH] feat: meta description for profile --- models/Profile.js | 6 +++++ pages/[username].js | 14 ++--------- pages/account/manage/profile.js | 38 ++++++++++++++++++++++++++--- pages/api/account/manage/profile.js | 2 ++ 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/models/Profile.js b/models/Profile.js index 341a949a82d..931f0e5e13e 100644 --- a/models/Profile.js +++ b/models/Profile.js @@ -67,6 +67,12 @@ const ProfileSchema = new Schema( min: 2, max: 256, }, + metaDescription: { + type: String, + required: false, + min: 2, + max: 160, + }, tags: { type: [String], default: [], diff --git a/pages/[username].js b/pages/[username].js index 6356efe0379..f910f212846 100644 --- a/pages/[username].js +++ b/pages/[username].js @@ -1,8 +1,6 @@ import { useEffect, useState } from "react"; import { IconContext } from "react-icons"; import { FaArrowsRotate, FaEye, FaRegFaceSmileWink } from "react-icons/fa6"; -import { remark } from "remark"; -import strip from "strip-markdown"; import requestIp from "request-ip"; import { authOptions } from "./api/auth/[...nextauth]"; import { getServerSession } from "next-auth/next"; @@ -44,14 +42,6 @@ export async function getServerSideProps(context) { logger.info(`data loaded for username: ${username}`); - try { - const processedBio = await remark().use(strip).process(profile.bio); - profile.cleanBio = processedBio.toString(); - } catch (e) { - logger.error(e, `cannot strip markdown for: ${username}`); - profile.cleanBio = profile.bio; - } - // override hiding navbar and footer if custom domain matches if ( profile.settings?.domain && @@ -87,9 +77,9 @@ export default function User({ data, BASE_URL, isLoggedIn }) { <> { @@ -101,7 +113,15 @@ export default function Profile({ BASE_URL, profile, fileExists }) { headers: { "Content-Type": "application/json", }, - body: JSON.stringify({ name, bio, tags, layout, pronoun, isStatsPublic }), + body: JSON.stringify({ + name, + bio, + tags, + layout, + pronoun, + isStatsPublic, + metaDescription, + }), }); const update = await res.json(); @@ -256,6 +276,18 @@ export default function Profile({ BASE_URL, profile, fileExists }) { Separate tags with commas (tags cannot be duplicated).

+ +
+