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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ APP_PORT=3000
UMBRACO_BASE_URL=http://localhost:7158
CMS_PUBLIC_URL=http://localhost:7158
SITE_URL=http://localhost:3000/
SEARCH_INDEXING_ENABLED=true
5 changes: 4 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { config } from '@fortawesome/fontawesome-svg-core';
import '@fortawesome/fontawesome-svg-core/styles.css';
import './globals.css';
import { Footer } from '@/components/Footer';
import { getSiteUrl } from '@/serverConfig';
import { getSiteUrl, isSearchIndexingEnabled } from '@/serverConfig';

config.autoAddCss = false;

Expand All @@ -22,6 +22,9 @@ export async function generateMetadata(): Promise<Metadata> {
default: 'Method Conference - October 12th 2024 - Springfield, MO',
},
metadataBase: getSiteUrl(),
robots: isSearchIndexingEnabled()
? undefined
: { index: false, follow: false },
};
}

Expand Down
13 changes: 13 additions & 0 deletions src/app/robots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { MetadataRoute } from 'next';
import { connection } from 'next/server';
import { isSearchIndexingEnabled } from '@/serverConfig';

export default async function robots(): Promise<MetadataRoute.Robots> {
await connection();

return {
rules: isSearchIndexingEnabled()
? { userAgent: '*', allow: '/' }
: { userAgent: '*', disallow: '/' },
};
}
4 changes: 4 additions & 0 deletions src/serverConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export function getSiteUrl(): URL {
return getRequiredUrl('SITE_URL');
}

export function isSearchIndexingEnabled(): boolean {
return process.env.SEARCH_INDEXING_ENABLED === 'true';
}

export function getNewsletterConfig(): {
endpoint?: URL;
listId?: string;
Expand Down