From 3794fd0466abec3290a4ff770481cabdc5caaa52 Mon Sep 17 00:00:00 2001 From: XiNiHa Date: Thu, 16 May 2024 20:12:10 +0900 Subject: [PATCH 1/2] =?UTF-8?q?@inox-tools/sitemap-ext=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 +- pnpm-lock.yaml | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4a2611adb..52b1b573f 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,8 @@ "@iconify-json/ic": "^1.1.17", "@iconify-json/material-symbols": "^1.1.78", "@iconify-json/simple-icons": "^1.1.100", + "@inox-tools/sitemap-ext": "^0.2.11", + "@portone-io/lint-local-links-valid": "workspace:^", "@preact/compat": "^17.1.2", "@preact/signals": "^1.2.3", "@rollup/plugin-yaml": "^4.1.2", @@ -74,7 +76,6 @@ "httpsnippet-lite": "^3.0.5", "js-yaml": "^4.1.0", "json5": "^2.2.3", - "@portone-io/lint-local-links-valid": "workspace:^", "lodash-es": "^4.17.21", "mdast-util-from-markdown": "^2.0.0", "mdast-util-mdx": "^3.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0bd11b112..86be59f81 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -61,6 +61,9 @@ importers: '@iconify-json/simple-icons': specifier: ^1.1.100 version: 1.1.100 + '@inox-tools/sitemap-ext': + specifier: ^0.2.11 + version: 0.2.11(@types/node@20.12.7)(astro@4.6.3(@types/node@20.12.7)(typescript@5.4.5)) '@portone-io/lint-local-links-valid': specifier: workspace:^ version: link:packages/lint-local-links-valid @@ -1205,6 +1208,20 @@ packages: cpu: [x64] os: [win32] + '@inox-tools/aik-route-config@0.5.2': + resolution: {integrity: sha512-67DFZlI+chMjc0dbCB3gy3Gc7SZ/SSxz2EpZfjEVBuWw2yzeI0zhHS5exz/V9MbuxSMY9ZQ3SR0ZeWoFki9UBw==} + peerDependencies: + astro: ^4.3.5 + astro-integration-kit: ~0.13 + + '@inox-tools/sitemap-ext@0.2.11': + resolution: {integrity: sha512-6Ma70vJ6+acew5Moqmia6ey9Os9b6VywJwNChtlsLuEEJ0rRFizYpRzWfvD6RP6vU1d//AQLSv0fgg9GjbPOLg==} + peerDependencies: + astro: ^4.3.5 + + '@inox-tools/utils@0.1.1': + resolution: {integrity: sha512-RXtCDrY4YR86WkC+B2ihXlNT+lK4yqZ3x48Ub4Mq1oR/fOK9rvWGRcQaXO5OPRyi7lB9hisNQvzys7gJmMYivg==} + '@isaacs/cliui@8.0.2': resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} engines: {node: '>=12'} @@ -1935,6 +1952,10 @@ packages: ast-types-flow@0.0.8: resolution: {integrity: sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==} + ast-types@0.16.1: + resolution: {integrity: sha512-6t10qk83GOG8p0vKmaCr8eiilZwO171AvbROMtvvNiwrTly62t+7XkA8RdIIVbpMhCASAsxgAzdRSwh6nw/5Dg==} + engines: {node: '>=4'} + astring@1.8.6: resolution: {integrity: sha512-ISvCdHdlTDlH5IpxQJIex7BWBywFWgjJSVdwst+/iQCoEYnyOaQ95+X1JGshuBjGp6nxKUy1jMgE3zPqN7fQdg==} hasBin: true @@ -1943,6 +1964,15 @@ packages: resolution: {integrity: sha512-CGaBseNtunAV2DCpwBXqTKq8+9Tw65XZetMaC0FsMoZuLj0gxNIkbCf2QyKYScVrNOU7/ayfNdVw8ZCSHBiqCg==} engines: {node: ^14.18.0 || >=16.0.0} + astro-integration-kit@0.13.2: + resolution: {integrity: sha512-0NkGf91Q+Vgs+Aj70kj8YCMon750llWnv+9TdRWcqrpccjDgt6LtG+wagS7j8CTyBrTiQvvDg3kIdvYNLcu/xg==} + peerDependencies: + '@astrojs/db': ^0.9 || ^0.10 || ^0.11 + astro: ^4.4.1 + peerDependenciesMeta: + '@astrojs/db': + optional: true + astro@4.6.3: resolution: {integrity: sha512-p2zs1Gac+ysdc/yFCoc8pOXTZE5L9foAtmqUzUVL22WX68bYTRovd03GRs7J1MDpwzsl9kJtlK20ROpjyIFpNw==} engines: {node: ^18.17.1 || ^20.3.0 || >=21.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0'} @@ -3953,6 +3983,10 @@ packages: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} engines: {node: '>=8.10.0'} + recast@0.23.7: + resolution: {integrity: sha512-MpQlLZVpqbbxYcqEjwpRWo88sGvjOYoXptySz710RuddNMHx+wPkoNX6YyLZJlXAh5VZr1qmPrTwcTuFMh0Lag==} + engines: {node: '>= 4'} + reflect.getprototypeof@1.0.5: resolution: {integrity: sha512-62wgfC8dJWrmxv44CA36pLDnP6KKl3Vhxb7PL+8+qrrFMMoJij4vgiMP8zV4O8+CBMXY1mHxI5fITGHXFHVmQQ==} engines: {node: '>= 0.4'} @@ -4339,6 +4373,10 @@ packages: resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} engines: {node: '>=0.10.0'} + source-map@0.6.1: + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + engines: {node: '>=0.10.0'} + source-map@0.7.4: resolution: {integrity: sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==} engines: {node: '>= 8'} @@ -4501,6 +4539,9 @@ packages: tiny-inflate@1.0.3: resolution: {integrity: sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==} + tiny-invariant@1.3.3: + resolution: {integrity: sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==} + tinybench@2.8.0: resolution: {integrity: sha512-1/eK7zUnIklz4JUUlL+658n58XO2hHLQfSk1Zf2LKieUjxidN16eKFEoDEfjHc3ohofSSqK3X5yO6VGb6iW8Lw==} @@ -5916,6 +5957,41 @@ snapshots: '@img/sharp-win32-x64@0.33.3': optional: true + '@inox-tools/aik-route-config@0.5.2(@types/node@20.12.7)(astro-integration-kit@0.13.2(astro@4.6.3(@types/node@20.12.7)(typescript@5.4.5)))(astro@4.6.3(@types/node@20.12.7)(typescript@5.4.5))': + dependencies: + '@inox-tools/utils': 0.1.1 + astro: 4.6.3(@types/node@20.12.7)(typescript@5.4.5) + astro-integration-kit: 0.13.2(astro@4.6.3(@types/node@20.12.7)(typescript@5.4.5)) + recast: 0.23.7 + vite: 5.2.11(@types/node@20.12.7) + transitivePeerDependencies: + - '@types/node' + - less + - lightningcss + - sass + - stylus + - sugarss + - terser + + '@inox-tools/sitemap-ext@0.2.11(@types/node@20.12.7)(astro@4.6.3(@types/node@20.12.7)(typescript@5.4.5))': + dependencies: + '@astrojs/sitemap': 3.1.4 + '@inox-tools/aik-route-config': 0.5.2(@types/node@20.12.7)(astro-integration-kit@0.13.2(astro@4.6.3(@types/node@20.12.7)(typescript@5.4.5)))(astro@4.6.3(@types/node@20.12.7)(typescript@5.4.5)) + astro: 4.6.3(@types/node@20.12.7)(typescript@5.4.5) + astro-integration-kit: 0.13.2(astro@4.6.3(@types/node@20.12.7)(typescript@5.4.5)) + sitemap: 7.1.1 + transitivePeerDependencies: + - '@astrojs/db' + - '@types/node' + - less + - lightningcss + - sass + - stylus + - sugarss + - terser + + '@inox-tools/utils@0.1.1': {} + '@isaacs/cliui@8.0.2': dependencies: string-width: 5.1.2 @@ -6875,6 +6951,10 @@ snapshots: ast-types-flow@0.0.8: {} + ast-types@0.16.1: + dependencies: + tslib: 2.6.2 + astring@1.8.6: {} astro-eslint-parser@0.16.3: @@ -6891,6 +6971,12 @@ snapshots: transitivePeerDependencies: - supports-color + astro-integration-kit@0.13.2(astro@4.6.3(@types/node@20.12.7)(typescript@5.4.5)): + dependencies: + astro: 4.6.3(@types/node@20.12.7)(typescript@5.4.5) + pathe: 1.1.2 + recast: 0.23.7 + astro@4.6.3(@types/node@20.12.7)(typescript@5.4.5): dependencies: '@astrojs/compiler': 2.7.1 @@ -9543,6 +9629,14 @@ snapshots: dependencies: picomatch: 2.3.1 + recast@0.23.7: + dependencies: + ast-types: 0.16.1 + esprima: 4.0.1 + source-map: 0.6.1 + tiny-invariant: 1.3.3 + tslib: 2.6.2 + reflect.getprototypeof@1.0.5: dependencies: call-bind: 1.0.7 @@ -10342,6 +10436,8 @@ snapshots: source-map-js@1.2.0: {} + source-map@0.6.1: {} + source-map@0.7.4: {} space-separated-tokens@2.0.2: {} @@ -10540,6 +10636,8 @@ snapshots: tiny-inflate@1.0.3: {} + tiny-invariant@1.3.3: {} + tinybench@2.8.0: {} tinypool@0.8.4: {} From 948b4877538eda91058a367c1354737bc774df46 Mon Sep 17 00:00:00 2001 From: XiNiHa Date: Thu, 16 May 2024 20:12:49 +0900 Subject: [PATCH 2/2] =?UTF-8?q?@inox-tools/sitemap-ext=20=ED=99=9C?= =?UTF-8?q?=EC=84=B1=ED=99=94=20=EB=B0=8F=20=EB=8F=99=EC=A0=81=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=EB=93=A4=EC=97=90=20=EB=8C=80=ED=95=9C=20?= =?UTF-8?q?=EC=82=AC=EC=9D=B4=ED=8A=B8=EB=A7=B5=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astro.config.ts | 6 +----- src/pages/api/rest-v1/[...slug].astro | 15 +++++++++++++++ src/pages/api/rest-v2-legacy/index.astro | 4 ++++ src/pages/api/rest-v2/[...slug].astro | 15 +++++++++++++++ src/pages/blog/posts/[...slug].astro | 7 +++++++ src/pages/blog/tags/[tag].astro | 14 ++++++++++++++ src/pages/docs/[lang]/[...slug].astro | 15 +++++++++++++++ src/pages/release-notes/[...slug].astro | 8 ++++++++ src/pages/test/typography.astro | 6 ++++++ 9 files changed, 85 insertions(+), 5 deletions(-) diff --git a/astro.config.ts b/astro.config.ts index eca9d2c68..72a2d1054 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -3,8 +3,8 @@ import * as path from "node:path"; import mdx from "@astrojs/mdx"; import preact from "@astrojs/preact"; -import sitemap from "@astrojs/sitemap"; import vercel from "@astrojs/vercel/serverless"; +import sitemap from "@inox-tools/sitemap-ext"; import yaml from "@rollup/plugin-yaml"; import rehypeShiki, { type RehypeShikiOptions } from "@shikijs/rehype"; import { transformerMetaHighlight } from "@shikijs/transformers"; @@ -22,10 +22,6 @@ export default defineConfig({ customPages: ["/api/rest-v1/", "/api/rest-v2/"].map( (url) => `https://developers.portone.io${url}`, ), - filter: (page) => - ![/^\/test/, /^\/platform/, /^\/api\/rest-v2-legacy/].some((regex) => - regex.test(page.replace("https://developers.portone.io", "")), - ), }), ], vite: { diff --git a/src/pages/api/rest-v1/[...slug].astro b/src/pages/api/rest-v1/[...slug].astro index 89e982eb2..c1c2d1a7d 100644 --- a/src/pages/api/rest-v1/[...slug].astro +++ b/src/pages/api/rest-v1/[...slug].astro @@ -1,4 +1,6 @@ --- +import sitemap from "sitemap-ext:config"; + import * as prose from "~/components/prose"; import LayoutBase from "~/layouts/LayoutBase.astro"; import NavMenu from "~/layouts/rest-api/nav-menu/NavMenu.astro"; @@ -9,6 +11,19 @@ import { overrideSystemVersion } from "~/state/system-version/server"; import Component from "./_Page"; +sitemap(async ({ addToSitemap }) => { + const categories = getCategories(schema).flatMap((category) => [ + category, + ...(category.children ?? []), + ]); + + addToSitemap( + categories.map((category) => ({ + slug: category.id, + })), + ); +}); + const { v1auth } = await getApiSectionDescriptions(); const { slug } = Astro.params; diff --git a/src/pages/api/rest-v2-legacy/index.astro b/src/pages/api/rest-v2-legacy/index.astro index cbf0d44d7..bd9343682 100644 --- a/src/pages/api/rest-v2-legacy/index.astro +++ b/src/pages/api/rest-v2-legacy/index.astro @@ -1,4 +1,8 @@ --- +import sitemap from "sitemap-ext:config"; + +sitemap(false); + return new Response(null, { status: 301, headers: { diff --git a/src/pages/api/rest-v2/[...slug].astro b/src/pages/api/rest-v2/[...slug].astro index 63815a53d..83bc60dc2 100644 --- a/src/pages/api/rest-v2/[...slug].astro +++ b/src/pages/api/rest-v2/[...slug].astro @@ -1,4 +1,6 @@ --- +import sitemap from "sitemap-ext:config"; + import LayoutBase from "~/layouts/LayoutBase.astro"; import NavMenu from "~/layouts/rest-api/nav-menu/NavMenu.astro"; import { getCategories } from "~/layouts/rest-api/schema-utils/category"; @@ -7,6 +9,19 @@ import { overrideSystemVersion } from "~/state/system-version/server"; import Component from "./_Page"; +sitemap(async ({ addToSitemap }) => { + const categories = getCategories(schema).flatMap((category) => [ + category, + ...(category.children ?? []), + ]); + + addToSitemap( + categories.map((category) => ({ + slug: category.id, + })), + ); +}); + const { slug } = Astro.params; const [_api, _rest, section = ""] = Astro.url.pathname .split("/") diff --git a/src/pages/blog/posts/[...slug].astro b/src/pages/blog/posts/[...slug].astro index 2d2a62d2d..a8cf8ce61 100644 --- a/src/pages/blog/posts/[...slug].astro +++ b/src/pages/blog/posts/[...slug].astro @@ -2,6 +2,7 @@ import { Image } from "astro:assets"; import { getCollection } from "astro:content"; import { format } from "date-fns"; +import sitemap from "sitemap-ext:config"; import { match, P } from "ts-pattern"; import PostList from "~/components/blog/PostList/PostList.astro"; @@ -15,6 +16,12 @@ import authors from "~/content/blog/_authors.yaml"; import LayoutBase from "~/layouts/LayoutBase.astro"; // import NavigationMenu from "~/components/blog/NavigationMenu"; +sitemap(async ({ addToSitemap }) => { + const entries = await getCollection("blog"); + + addToSitemap(entries.map((entry) => ({ slug: entry.slug }))); +}); + const { slug } = Astro.params; const entries = await getCollection("blog").then((entries) => entries.sort((a, b) => b.data.date.getTime() - a.data.date.getTime()), diff --git a/src/pages/blog/tags/[tag].astro b/src/pages/blog/tags/[tag].astro index d14c372f1..73f6df44f 100644 --- a/src/pages/blog/tags/[tag].astro +++ b/src/pages/blog/tags/[tag].astro @@ -1,8 +1,22 @@ --- import { getCollection } from "astro:content"; +import sitemap from "sitemap-ext:config"; import PostListLayout from "~/components/blog/PostList/PostListLayout.astro"; +sitemap(async ({ addToSitemap }) => { + const entries = await getCollection( + "blog", + (entry) => + !entry.data.draft || + import.meta.env.DEV || + import.meta.env.VERCEL_ENV === "preview", + ); + const tags = [...new Set(entries.flatMap((entry) => entry.data.tags))]; + + addToSitemap(tags.map((tag) => ({ tag }))); +}); + const tag = decodeURIComponent(Astro.params.tag?.toString() ?? ""); const entries = await getCollection( "blog", diff --git a/src/pages/docs/[lang]/[...slug].astro b/src/pages/docs/[lang]/[...slug].astro index 53e7469b7..08e32d558 100644 --- a/src/pages/docs/[lang]/[...slug].astro +++ b/src/pages/docs/[lang]/[...slug].astro @@ -1,10 +1,25 @@ --- import { getCollection } from "astro:content"; +import sitemap from "sitemap-ext:config"; import Docs from "~/layouts/Docs.astro"; import { getRedirection } from "~/misc/redirection"; import { isLang } from "~/type"; +sitemap(async ({ addToSitemap }) => { + const entries = await getCollection("docs"); + + addToSitemap( + entries + .filter((entry) => !entry.slug.startsWith("en/")) + .map((entry) => { + const lang = entry.slug.split("/")[0]; + const slug = entry.slug.replace(`${lang}/`, ""); + return { lang, slug }; + }), + ); +}); + const { lang, slug } = Astro.params; if (!isLang(lang) || !slug) { return new Response(null, { status: 404 }); diff --git a/src/pages/release-notes/[...slug].astro b/src/pages/release-notes/[...slug].astro index 2195965c2..f539cf945 100644 --- a/src/pages/release-notes/[...slug].astro +++ b/src/pages/release-notes/[...slug].astro @@ -1,5 +1,7 @@ --- +import { getCollection } from "astro:content"; import { format } from "date-fns"; +import sitemap from "sitemap-ext:config"; import { match } from "ts-pattern"; import * as prose from "~/components/prose"; @@ -9,6 +11,12 @@ import LayoutBase from "~/layouts/LayoutBase.astro"; import Nav from "~/layouts/release-notes/Nav.astro"; import { getReleaseNotes } from "~/misc/releaseNote"; +sitemap(async ({ addToSitemap }) => { + const entries = await getCollection("release-notes"); + + addToSitemap(entries.map((entry) => ({ slug: entry.slug }))); +}); + const { slug } = Astro.params; if (!slug) return new Response(null, { status: 404 }); const { apiSdkNotes, consoleNotes, platformNotes } = await getReleaseNotes(); diff --git a/src/pages/test/typography.astro b/src/pages/test/typography.astro index 134ec0adc..8c452d5b6 100644 --- a/src/pages/test/typography.astro +++ b/src/pages/test/typography.astro @@ -1,8 +1,14 @@ --- +import sitemap from "sitemap-ext:config"; + import * as prose from "~/components/prose"; import LayoutBase from "~/layouts/LayoutBase.astro"; import { interleave } from "~/layouts/rest-api"; +export const prerender = true; + +sitemap(false); + const ipsumEn = `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`; const ipsumKo = `국교는 인정되지 아니하며, 종교와 정치는 분리된다. 중앙선거관리위원회는 법령의 범위안에서 선거관리·국민투표관리 또는 정당사무에 관한 규칙을 제정할 수 있으며, 법률에 저촉되지 아니하는 범위안에서 내부규율에 관한 규칙을 제정할 수 있다. 언론·출판에 대한 허가나 검열과 집회·결사에 대한 허가는 인정되지 아니한다. 대통령은 제1항과 제2항의 처분 또는 명령을 한 때에는 지체없이 국회에 보고하여 그 승인을 얻어야 한다.`;