@agility/create-next-app 1.0.0-beta.3 → 1.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agility/create-next-app",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.4",
4
4
  "description": "Create a new Next.js project with Agility CMS integration",
5
5
  "main": "dist/cli/index.js",
6
6
  "bin": {
@@ -0,0 +1,8 @@
1
+ # Agility CMS Robots Configuration
2
+ # This allows indexing of all pages and references the sitemap
3
+
4
+ User-agent: *
5
+ Allow: /
6
+
7
+ # Sitemap location (update the domain for your production site)
8
+ Sitemap: ${SITE_URL}/sitemap.xml
@@ -0,0 +1,56 @@
1
+ import { getSitemapFlat } from "@/lib/cms/getSitemapFlat"
2
+ import { locales, defaultLocale } from "@/lib/i18n/config"
3
+ import type { MetadataRoute } from "next"
4
+
5
+ /**
6
+ * Agility CMS Sitemap
7
+ *
8
+ * Generates a sitemap from Agility CMS pages using getSitemapFlat().
9
+ * Iterates through all configured locales and generates entries for each visible page.
10
+ */
11
+ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
12
+ const allSitemapEntries: MetadataRoute.Sitemap = []
13
+ const baseUrl = process.env.SITE_URL || "https://example.com"
14
+
15
+ // Generate sitemap entries for each locale
16
+ for (const locale of locales) {
17
+ const sitemapData = await getSitemapFlat({
18
+ channelName: process.env.AGILITY_SITEMAP || "website",
19
+ languageCode: locale
20
+ })
21
+
22
+ if (!sitemapData) continue
23
+
24
+ const localeEntries = Object.keys(sitemapData)
25
+ .filter((path) => {
26
+ const node = sitemapData[path]
27
+
28
+ // Skip folders and redirects
29
+ if (node.isFolder || node.redirect) {
30
+ return false
31
+ }
32
+
33
+ // Skip pages not visible in sitemap
34
+ if (!node.visible?.sitemap) {
35
+ return false
36
+ }
37
+
38
+ return true
39
+ })
40
+ .map((path, index) => {
41
+ // For default locale, don't add locale prefix to URL
42
+ const localizedPath = locale === defaultLocale ? path : `/${locale}${path}`
43
+
44
+ return {
45
+ url: index === 0 && path === "/" ? baseUrl : `${baseUrl}${localizedPath}`,
46
+ lastModified: new Date(),
47
+ changeFrequency: "daily" as const,
48
+ priority: path === "/" ? 1.0 : 0.8
49
+ }
50
+ })
51
+
52
+ allSitemapEntries.push(...localeEntries)
53
+ }
54
+
55
+ return allSitemapEntries
56
+ }