Skip to content

Commit

Permalink
fix: fix incorrect sitemap generation (#116)
Browse files Browse the repository at this point in the history
* fix: sitemap and robots

Remove next-sitemap package and use robots.ts and sitemap.ts

* refactor: final touches

---------

Co-authored-by: Michał <skolakmichal1@gmail.com>
  • Loading branch information
devstack-be and Skolaczk authored Jul 14, 2024
1 parent 87c6fbf commit b94d632
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 50 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
- 🐶 Husky & Lint Staged - Run scripts on your staged files before they are committed
- 🔹 Icons - From Lucide
- 🌑 Dark mode - With next-themes
- 🗺️ Sitemap & robots.txt - With next-sitemap
- 📝 Commitlint - Lint your git commits
- 🤖 Github actions - Lint your code on PR
- ⚙️ T3-env - Manage your environment variables
- 🗺️ Sitemap & robots.txt
- 💯 Perfect Lighthouse score
- 🌐 I18n with Paraglide

Expand Down
7 changes: 0 additions & 7 deletions next-sitemap.config.js

This file was deleted.

41 changes: 1 addition & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"test:watch": "jest --watchAll",
"e2e": "playwright test",
"e2e:ui": "playwright test --ui",
"postbuild": "next-sitemap --config next-sitemap.config.js",
"prepare": "husky",
"postinstall": "paraglide-js compile --project ./project.inlang --outdir ./src/paraglide"
},
Expand Down Expand Up @@ -79,7 +78,6 @@
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^15.2.7",
"next-sitemap": "^4.2.3",
"postcss": "^8",
"prettier": "^3.3.2",
"prisma": "^5.16.1",
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 { MetadataRoute } from 'next';

import { env } from '@/env.mjs';

export default function robots(): MetadataRoute.Robots {
return {
rules: {
userAgent: '*',
allow: '/',
},
sitemap: `${env.APP_URL}/sitemap.xml`,
};
}
19 changes: 19 additions & 0 deletions src/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { MetadataRoute } from 'next';

import { env } from '@/env.mjs';

export default function sitemap(): MetadataRoute.Sitemap {
return [
{
url: env.APP_URL || '/',
lastModified: new Date(),
changeFrequency: 'yearly',
priority: 1,
alternates: {
languages: {
pl: `${env.APP_URL}/pl`,
},
},
},
];
}

0 comments on commit b94d632

Please sign in to comment.