From 429ade7b0f2402274813936e8c3ad88ccd8b7a63 Mon Sep 17 00:00:00 2001 From: MrOrz Date: Tue, 24 Jan 2023 19:15:36 +0800 Subject: [PATCH 1/4] feat(article): add meta tag that blocks search engine for blocked articles --- pages/article/[id].js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pages/article/[id].js b/pages/article/[id].js index 987fdb5d..a1ed134a 100644 --- a/pages/article/[id].js +++ b/pages/article/[id].js @@ -133,6 +133,7 @@ const LOAD_ARTICLE = gql` replyRequestCount replyCount createdAt + status references { type } @@ -353,6 +354,8 @@ function ArticlePage() { {ellipsis(article.text, { wordCount: 100 })} | {t`Cofacts`} + {/* Don't let search engines index blocked spam */ article.status === + 'BLOCKED' && }
From 0b1b9d7d1ba9fbff9909c829714374c41a08eeaf Mon Sep 17 00:00:00 2001 From: MrOrz Date: Tue, 24 Jan 2023 19:52:12 +0800 Subject: [PATCH 2/4] feat(article): add ugc rel for all article's hyperlinks --- components/Hyperlinks.js | 10 ++++++---- pages/article/[id].js | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/components/Hyperlinks.js b/components/Hyperlinks.js index 7a996eee..a1eeb7f1 100644 --- a/components/Hyperlinks.js +++ b/components/Hyperlinks.js @@ -127,8 +127,9 @@ function getErrorText(error) { /** * @param {object} props.hyperlink + * @param {string} props.rel - rel prop for the hyperlink (other than noopener and noreferrer) */ -function Hyperlink({ hyperlink }) { +function Hyperlink({ hyperlink, rel = '' }) { const { title, topImageUrl, error, url } = hyperlink; const summary = (hyperlink.summary || '').slice(0, 200); @@ -146,7 +147,7 @@ function Hyperlink({ hyperlink }) {
- + {url} @@ -173,8 +174,9 @@ function PollingHyperlink({ pollingType, pollingId }) { * @param {object[] | null} props.hyperlinks * @param {'articles'|'replies'?} props.pollingType - poll article or reply for hyperlinks when it's not loaded (null) * @param {string?} props.pollingId - polling article or reply id for hyperlinks when it's not loaded (null) + * @param {string?} props.rel - rel prop for the hyperlink (other than noopener and noreferrer) */ -function Hyperlinks({ hyperlinks, pollingType, pollingId }) { +function Hyperlinks({ hyperlinks, pollingType, pollingId, rel }) { if (!((pollingId && pollingType) || (!pollingId && !pollingType))) { throw new Error('pollingType and pollingId must be specified together'); } @@ -191,7 +193,7 @@ function Hyperlinks({ hyperlinks, pollingType, pollingId }) { mb={1} > {(hyperlinks || []).map((hyperlink, idx) => ( - + ))} {!hyperlinks && pollingId && ( diff --git a/pages/article/[id].js b/pages/article/[id].js index a1ed134a..d67aec6c 100644 --- a/pages/article/[id].js +++ b/pages/article/[id].js @@ -420,10 +420,11 @@ function ArticlePage() { linkify(text, { props: { target: '_blank', + rel: 'ugc nofollow', }, }) )} - + Date: Tue, 24 Jan 2023 19:55:27 +0800 Subject: [PATCH 3/4] feat(article): hide blocked article for anonymous users --- pages/article/[id].js | 106 ++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/pages/article/[id].js b/pages/article/[id].js index d67aec6c..d16456e5 100644 --- a/pages/article/[id].js +++ b/pages/article/[id].js @@ -375,56 +375,62 @@ function ArticlePage() { - {(() => { - switch (articleType) { - case 'IMAGE': - return !originalAttachmentUrl ? ( - image - ) : ( - - image - - ); - case 'VIDEO': - return !originalAttachmentUrl ? ( - t`Log in to view video content` - ) : ( -