-
Notifications
You must be signed in to change notification settings - Fork 0
Chore/next-sitemap #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
364aa5c
ab6684b
470c53d
9a84ed7
8b59fee
29f7afd
33971d8
2e9863e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| const RAW_SITE_URL = process.env.SITE_URL ?? "https://myplanmate.vercel.app"; | ||
| const siteUrl = RAW_SITE_URL.replace(/\/+$/, ""); // λ μ¬λμ μ κ±° | ||
|
|
||
| // "/" μ΄μΈ κ²½λ‘μ λ μ¬λμ μ κ±° | ||
| const strip = (p) => (p !== "/" && p.endsWith("/") ? p.slice(0, -1) : p); | ||
|
|
||
| const config = { | ||
| siteUrl, | ||
| generateRobotsTxt: true, | ||
| outDir: "public", | ||
| sitemapSize: 5000, | ||
|
|
||
| // κΈ°μ‘΄ exclude κ·Έλλ‘ μ μ§ | ||
| exclude: ["/api/*", "/admin/*", "/debug", "/lab/*"], | ||
|
|
||
| // <loc>μ΄ canonicalκ³Ό 1:1λ‘ λμΌνλλ‘ μ κ·ν | ||
| transform: async (cfg, path) => { | ||
| const loc = strip(path); | ||
|
|
||
| // μ°μ μμ κ·μΉ | ||
| const priority = loc === "/" ? 1.0 : loc.startsWith("/blog") ? 0.8 : (cfg.priority ?? 0.7); | ||
|
|
||
| return { | ||
| loc, // β canonicalκ³Ό λμΌν λ¬Έμμ΄ | ||
| changefreq: "daily", | ||
| priority, | ||
| lastmod: new Date().toISOString(), | ||
|
|
||
| // μΈμ΄λ³ νμ΄μ§κ° μλ€λ©΄ κ²½λ‘ λ¨μλ‘ alternateRefs λ§€ν | ||
| // μ) /todos β /ko/todos, /en/todos | ||
| alternateRefs: [ | ||
| { href: `${siteUrl}/ko${loc === "/" ? "" : loc}`, hreflang: "ko" }, | ||
| { href: `${siteUrl}/en${loc === "/" ? "" : loc}`, hreflang: "en" }, | ||
| ], | ||
| }; | ||
| }, | ||
|
|
||
| // robots.txt | ||
| robotsTxtOptions: { | ||
| policies: [ | ||
| { userAgent: "*", allow: "/" }, | ||
| { userAgent: "*", disallow: ["/api/", "/admin/", "/debug", "/lab/"] }, | ||
| ], | ||
| additionalSitemaps: [`${siteUrl}/server-sitemap.xml`], // λμ sitemap | ||
| }, | ||
| }; | ||
|
|
||
| export default config; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # * | ||
| User-agent: * | ||
| Allow: / | ||
|
|
||
| # * | ||
| User-agent: * | ||
| Disallow: /api/ | ||
| Disallow: /admin/ | ||
| Disallow: /debug | ||
| Disallow: /lab/ | ||
|
|
||
| # Host | ||
| Host: https://myplanmate.vercel.app | ||
|
|
||
| # Sitemaps | ||
| Sitemap: https://myplanmate.vercel.app/sitemap.xml | ||
| Sitemap: https://myplanmate.vercel.app/server-sitemap.xml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"> | ||
| <url><loc>https://myplanmate.vercel.app</loc><lastmod>2025-10-21T17:20:15.421Z</lastmod><changefreq>daily</changefreq><priority>1</priority><xhtml:link rel="alternate" hreflang="ko" href="https://myplanmate.vercel.app/ko"/><xhtml:link rel="alternate" hreflang="en" href="https://myplanmate.vercel.app/en"/></url> | ||
| </urlset> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | ||
| <sitemap><loc>https://myplanmate.vercel.app/sitemap-0.xml</loc></sitemap> | ||
| <sitemap><loc>https://myplanmate.vercel.app/server-sitemap.xml</loc></sitemap> | ||
| </sitemapindex> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,12 +9,12 @@ import { | |
| LOCALE, | ||
| OG_DEFAULT_IMAGE, | ||
| SITE_NAME, | ||
| SITE_URL, | ||
| SITE_URL, // β constantsμμ SITE_URL μ¬μ© | ||
| TITLE_TEMPLATE, | ||
| } from "@/seo/constants"; | ||
|
|
||
| export const metadata: Metadata = { | ||
| // μ λ URL κΈ°μ€μ (canonical/OG μ λκ²½λ‘ λ³νμ μ¬μ©) | ||
| // β μ λ URL κΈ°μ€μ (canonical / OG μ λκ²½λ‘ λ³νμ©) | ||
| metadataBase: new URL(SITE_URL), | ||
|
|
||
| // μ μ νμ΄ν κ·μΉ | ||
|
|
@@ -48,6 +48,15 @@ export const metadata: Metadata = { | |
| twitter: { | ||
| card: "summary_large_image", | ||
| }, | ||
|
|
||
| // canonical λ° μΈμ΄λ³ hreflang | ||
| alternates: { | ||
| canonical: "/", // => https://myplanmate.vercel.app/ | ||
| languages: { | ||
| ko: "/ko", // => https://myplanmate.vercel.app/ko | ||
| en: "/en", // => https://myplanmate.vercel.app/en | ||
| }, | ||
|
Comment on lines
+52
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Layout metadata advertises alternate language URLs ( Useful? React with πΒ / π. |
||
| }, | ||
| }; | ||
|
|
||
| export default function RootLayout({ children }: { children: React.ReactNode }) { | ||
|
|
@@ -60,15 +69,6 @@ export default function RootLayout({ children }: { children: React.ReactNode }) | |
| - λͺ¨λ νμ μ»΄ν¬λνΈκ° λμΌν client & cache 곡μ | ||
| - useQuery, useMutation ν μ΄ μ΄λμλ μ μ λμ | ||
| */} | ||
| {/* | ||
| β μΆν νμ₯ μμ: | ||
| <AuthProvider> | ||
| <ThemeProvider> | ||
| <Providers>{children}</Providers> | ||
| </ThemeProvider> | ||
| </AuthProvider> | ||
| */} | ||
|
|
||
| <Providers>{children}</Providers> | ||
| </body> | ||
| </html> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sitemap configuration reads
process.env.SITE_URLexclusively. Other modules (e.g.src/seo/constants.ts) still supportNEXT_PUBLIC_SITE_URL, which was the only variable required before this commit. Environments that set only the public variable will now fall back to the hardcodedhttps://myplanmate.vercel.app, producing sitemaps and robots.txt pointing at the wrong domain. Consider checking both env names to keep generated URLs consistent with the rest of the app.Useful? React with πΒ / π.