Skip to content

Commit

Permalink
Merge pull request #280 from 0x74h51N/Staging
Browse files Browse the repository at this point in the history
seo settings
  • Loading branch information
0x74h51N committed Aug 23, 2024
2 parents 233ec38 + 783df8a commit 0d6b3fe
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/robots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { MetadataRoute } from 'next';

export default function robots(): MetadataRoute.Robots {
return {
rules: {
userAgent: '*',
allow: '/',
disallow: ['/private/', '/public', '/actions/', '/404', '/policies/*'],
},
sitemap: 'https://crunchypix.com/sitemap.xml',
};
}
42 changes: 42 additions & 0 deletions app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { MetadataRoute } from 'next';
import { fetchSupabaseData } from '@/lib/utils/fetchSupabaseData';
import { PortfolioItemProps, PortfolioItemSchema } from '@/schemas';

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const staticUrls = [
{
url: 'https://crunchypix.com',
lastModified: new Date(),
changeFrequency: 'monthly' as const,
priority: 1,
},
{
url: 'https://crunchypix.com/portfolio',
lastModified: new Date(),
changeFrequency: 'weekly' as const,
priority: 0.85,
},
{
url: 'https://crunchypix.com/about',
lastModified: new Date(),
changeFrequency: 'monthly' as const,
priority: 0.5,
},
];

const portfolioItems = await fetchSupabaseData<PortfolioItemProps>(
'portfolio_schema',
'portfolio_items',
'*',
PortfolioItemSchema,
);

const dynamicUrls = portfolioItems.map((item) => ({
url: `https://crunchypix.com/portfolio/${item._id}`,
lastModified: new Date(),
changeFrequency: 'monthly' as const,
priority: 0.8,
}));

return [...staticUrls, ...dynamicUrls];
}

0 comments on commit 0d6b3fe

Please sign in to comment.