@@ -11,6 +11,19 @@ import { RehypePlugins } from "@astrojs/markdown-remark"
1111import yaml from "@rollup/plugin-yaml"
1212import { ccipRedirects } from "./src/config/redirects/ccip"
1313import trailingSlashMiddleware from "./src/integrations/trailing-slash-middleware"
14+ import redirectsJson from "./src/features/redirects/redirects.json"
15+
16+ // Prepare set of redirect source URLs to exclude from sitemap
17+ // This prevents duplicate entries and ensures only canonical URLs are indexed
18+ const redirectSources = new Set (
19+ redirectsJson . redirects
20+ . map ( ( r ) => r . source )
21+ . filter ( ( source ) => source )
22+ . map ( ( source ) => {
23+ const normalized = source . startsWith ( "/" ) ? source : `/${ source } `
24+ return normalized . endsWith ( "/" ) ? normalized . slice ( 0 , - 1 ) : normalized
25+ } )
26+ )
1427
1528// https://astro.build/config
1629export default defineConfig ( {
@@ -30,7 +43,47 @@ export default defineConfig({
3043 react ( {
3144 include : [ "**/react/*" ] ,
3245 } ) ,
33- sitemap ( { changefreq : "daily" } ) ,
46+ sitemap ( {
47+ changefreq : "daily" ,
48+ customPages : [
49+ "https://docs.chain.link/llms.txt" ,
50+ "https://docs.chain.link/vrf/llms-full.txt" ,
51+ "https://docs.chain.link/ccip/llms-full.txt" ,
52+ "https://docs.chain.link/data-feeds/llms-full.txt" ,
53+ "https://docs.chain.link/data-streams/llms-full.txt" ,
54+ "https://docs.chain.link/chainlink-functions/llms-full.txt" ,
55+ "https://docs.chain.link/chainlink-automation/llms-full.txt" ,
56+ "https://docs.chain.link/resources/llms-full.txt" ,
57+ "https://docs.chain.link/architecture-overview/llms-full.txt" ,
58+ "https://docs.chain.link/getting-started/llms-full.txt" ,
59+ "https://docs.chain.link/chainlink-nodes/llms-full.txt" ,
60+ "https://docs.chain.link/chainlink-local/llms-full.txt" ,
61+ ] ,
62+ filter : ( page ) => {
63+ // Exclude redirect source URLs from sitemap to prevent duplicates
64+ const pathname = new URL ( page ) . pathname
65+ const cleanPath = pathname . endsWith ( "/" ) && pathname !== "/" ? pathname . slice ( 0 , - 1 ) : pathname
66+
67+ // Exclude short format API reference URLs (e.g., /api-reference/v150, /ccip/api-reference/evm/v150)
68+ // These are aliases for versioned content - we keep only the canonical long format URLs
69+ const shortVersionPattern = / \/ a p i - r e f e r e n c e \/ (?: .* \/ ) ? v \d { 3 , 4 } (?: \/ | $ ) /
70+ if ( shortVersionPattern . test ( cleanPath ) ) {
71+ return false
72+ }
73+
74+ return ! redirectSources . has ( cleanPath )
75+ } ,
76+ serialize ( item ) {
77+ // Remove trailing slash from URLs (except for root)
78+ const url = new URL ( item . url )
79+ if ( url . pathname . endsWith ( "/" ) && url . pathname !== "/" ) {
80+ url . pathname = url . pathname . slice ( 0 , - 1 )
81+ item . url = url . toString ( )
82+ }
83+
84+ return item
85+ } ,
86+ } ) ,
3487 mdx ( ) ,
3588 ] ,
3689 markdown : {
0 commit comments