Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/app/(frontend)/[lyovson]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,9 @@ async function AuthorLayout({ children, params }: LayoutProps) {

export default function Layout(props: LayoutProps) {
return (
<Suspense
fallback={
<>
<ProfileSkeleton />
{props.children}
</>
}
>
// The fallback must not render children too: the page would then be in
// the HTML twice (two H1s and every card doubled for crawlers).
<Suspense fallback={<ProfileSkeleton />}>
<AuthorLayout {...props} />
</Suspense>
);
Expand Down
7 changes: 6 additions & 1 deletion src/app/(frontend)/topics/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ export async function generateMetadata({
}: PageProps): Promise<Metadata> {
const { slug } = await paramsPromise;

const topic = await getTopic(slug);
const [topic, posts] = await Promise.all([
getTopic(slug),
getTopicPosts(slug),
]);

if (!topic) {
return buildNotFoundMetadata({
Expand Down Expand Up @@ -147,6 +150,8 @@ export async function generateMetadata({
height: 630,
alt: topicName,
},
// An empty topic is a page with a heading and nothing else.
...(posts?.totalDocs ? {} : { robots: { index: false, follow: true } }),
});
}

Expand Down
20 changes: 9 additions & 11 deletions src/utilities/get-reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,16 @@ export function getShownReviews(activity: Activity) {
}

/**
* Search engines get a hub only when it carries the Lyovsons' own words: an
* activity note or written review, or a post. A page of catalog
* facts alone stays out of the index.
* Search engines get a hub only when it shows the Lyovsons' own words: an
* activity note or written review. Catalog facts and post cards alone stay
* out of the index: a citing post shows only its card here, and the post
* page is the one that should rank.
*/
export function hubHasOwnWords({ activities, posts }: ReferenceHub) {
return (
posts.length > 0 ||
activities.some(
(activity) =>
Boolean(extractLexicalText(activity.notes).trim()) ||
(activity.reviews ?? []).some((review) => Boolean(review.note?.trim()))
)
export function hubHasOwnWords({ activities }: ReferenceHub) {
return activities.some(
(activity) =>
Boolean(extractLexicalText(activity.notes).trim()) ||
(activity.reviews ?? []).some((review) => Boolean(review.note?.trim()))
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/utilities/sitemap-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ function getTopicRoutes(
postCounts: Map<string, number>
): Sitemap {
return topics.flatMap((topic) => {
if (!topic?.slug) {
// A topic without posts is noindex, so it stays out of the sitemap.
if (!(topic?.slug && postCounts.get(topic.slug))) {
return [];
}
const { slug } = topic;
Expand Down
Loading