From 68f298fc2144e0b59a575e01f6aff10bb0bb442d Mon Sep 17 00:00:00 2001 From: keyan Date: Wed, 16 Aug 2023 14:03:37 -0500 Subject: [PATCH] add simple badge to ad --- components/comment.js | 2 +- components/hat.js | 4 ++-- components/item.js | 8 ++++++-- lib/constants.js | 1 + svgs/advertisement-fill.svg | 1 + 5 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 svgs/advertisement-fill.svg diff --git a/components/comment.js b/components/comment.js index ef9b29d7..d4273f66 100644 --- a/components/comment.js +++ b/components/comment.js @@ -150,7 +150,7 @@ export default function Comment ({ commentsText='replies' commentTextSingular='reply' className={`${itemStyles.other} ${styles.other}`} - embellishUser={op && OP} + embellishUser={op && <> OP} extraInfo={ <> {includeParent && } diff --git a/components/hat.js b/components/hat.js index 84aee1f7..ac9350af 100644 --- a/components/hat.js +++ b/components/hat.js @@ -4,10 +4,10 @@ import Tooltip from 'react-bootstrap/Tooltip' import CowboyHatIcon from '../svgs/cowboy.svg' import AnonIcon from '../svgs/spy-fill.svg' import { numWithUnits } from '../lib/format' -import { ANON_USER_ID } from '../lib/constants' +import { AD_USER_ID, ANON_USER_ID } from '../lib/constants' export default function Hat ({ user, badge, className = 'ms-1', height = 16, width = 16 }) { - if (!user) return null + if (!user || Number(user.id) === AD_USER_ID) return null if (Number(user.id) === ANON_USER_ID) { return ( diff --git a/components/item.js b/components/item.js index ded16dd3..403f378b 100644 --- a/components/item.js +++ b/components/item.js @@ -2,7 +2,7 @@ import Link from 'next/link' import styles from './item.module.css' import UpVote from './upvote' import { useRef, useState } from 'react' -import { NOFOLLOW_LIMIT } from '../lib/constants' +import { AD_USER_ID, NOFOLLOW_LIMIT } from '../lib/constants' import Pin from '../svgs/pushpin-fill.svg' import reactStringReplace from 'react-string-replace' import PollIcon from '../svgs/bar-chart-horizontal-fill.svg' @@ -14,6 +14,7 @@ import { numWithUnits } from '../lib/format' import ItemInfo from './item-info' import { commentsViewedAt } from '../lib/new-comments' import { useRouter } from 'next/router' +import { Badge } from 'react-bootstrap' export function SearchTitle ({ title }) { return reactStringReplace(title, /:high\[([^\]]+)\]/g, (match, i) => { @@ -75,7 +76,10 @@ export default function Item ({ item, rank, belowTitle, right, full, children, s } - + AD} + /> {belowTitle} {right} diff --git a/lib/constants.js b/lib/constants.js index e2caaa73..f3621874 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -47,6 +47,7 @@ module.exports = { }, OLD_ITEM_DAYS: 3, ANON_USER_ID: 27, + AD_USER_ID: 9, ANON_POST_FEE: 1000, ANON_COMMENT_FEE: 100, SSR: typeof window === 'undefined' diff --git a/svgs/advertisement-fill.svg b/svgs/advertisement-fill.svg new file mode 100644 index 00000000..4d44f5d4 --- /dev/null +++ b/svgs/advertisement-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file