Skip to content

Commit

Permalink
feat: disable search engine indexing on unlisted and private lists
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Cao <[email protected]>
  • Loading branch information
ryanccn committed Nov 8, 2023
1 parent 3a59aa8 commit f07cb2f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/pages/list/[id]/analytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ export const getServerSideProps: GetServerSideProps<PageProps | { notFound: true
if (typeof query.id !== "string") throw new Error("?");
const data = await getSpecificList(query.id);

res.setHeader("x-robots-tag", "noindex");

if (!data || data.ownerProfile.banned) {
return {
notFound: true,
Expand Down
2 changes: 2 additions & 0 deletions src/pages/list/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,8 @@ export const getServerSideProps: GetServerSideProps<PageProps | { notFound: true
};
}

if (data.visibility !== "public") res.setHeader("x-robots-tag", "noindex");

return {
props: {
data: { ...data },
Expand Down
8 changes: 6 additions & 2 deletions src/pages/list/[id]/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ const ListSettings: NextPage<PageProps> = ({ data }) => {
<span className="font-display text-lg font-medium">Unlisted</span>
</div>
<span className="text-xs opacity-60">
Anyone with the link will be able to see the list, and it might be indexed by search engines.
Anyone with the link will be able to see the list, and it should not be indexed by search
engines.
</span>
</MMRadio>
<MMRadio name="visibility" value={"public"} currentValue={visibility} onCheck={setVisibility}>
Expand All @@ -189,7 +190,8 @@ const ListSettings: NextPage<PageProps> = ({ data }) => {
<span className="font-display text-lg font-medium">Public</span>
</div>
<span className="text-xs opacity-60">
Anyone with the link will be able to see the list, and it will be available in Search.
Anyone with the link will be able to see the list, and it will be available both in Search and
to search engines.
</span>
</MMRadio>
</div>
Expand Down Expand Up @@ -250,6 +252,8 @@ export const getServerSideProps: GetServerSideProps<PageProps | { notFound: true
if (typeof query.id !== "string") throw new Error("?");
const data = await getSpecificList(query.id);

res.setHeader("x-robots-tag", "noindex");

if (!data || data.ownerProfile.banned) {
return {
notFound: true,
Expand Down

0 comments on commit f07cb2f

Please sign in to comment.