|
| 1 | +import Link from 'next/link' |
| 2 | + |
| 3 | +export default function About() { |
| 4 | + return ( |
| 5 | + <main className="min-h-screen"> |
| 6 | + {/* Header */} |
| 7 | + <section className="py-16 px-4 border-b border-gray-200 dark:border-gray-800"> |
| 8 | + <div className="max-w-3xl mx-auto"> |
| 9 | + <Link |
| 10 | + href="/" |
| 11 | + className="inline-flex items-center text-sm text-gray-500 dark:text-gray-500 hover:text-black dark:hover:text-white transition-colors mb-8" |
| 12 | + > |
| 13 | + ← Back to store |
| 14 | + </Link> |
| 15 | + <h1 className="text-4xl font-bold text-black dark:text-white mb-4"> |
| 16 | + How it works |
| 17 | + </h1> |
| 18 | + <p className="text-lg text-gray-600 dark:text-gray-400"> |
| 19 | + This demo uses Vercel's bulk redirects feature to manage seasonal URLs without code changes. |
| 20 | + </p> |
| 21 | + </div> |
| 22 | + </section> |
| 23 | + |
| 24 | + {/* Content */} |
| 25 | + <section className="py-16 px-4"> |
| 26 | + <div className="max-w-3xl mx-auto space-y-16"> |
| 27 | + {/* The Problem */} |
| 28 | + <div> |
| 29 | + <h2 className="text-2xl font-bold text-black dark:text-white mb-4"> |
| 30 | + The problem |
| 31 | + </h2> |
| 32 | + <p className="text-gray-600 dark:text-gray-400 mb-4"> |
| 33 | + E-commerce sites often need vanity URLs that stay consistent while the content behind them changes: |
| 34 | + </p> |
| 35 | + <ul className="space-y-2 text-gray-600 dark:text-gray-400"> |
| 36 | + <li className="flex items-start gap-3"> |
| 37 | + <span className="text-gray-400">•</span> |
| 38 | + <span><code className="px-1.5 py-0.5 bg-gray-100 dark:bg-gray-900 rounded text-sm font-mono">/catalog/fall</code> should always show the current fall collection</span> |
| 39 | + </li> |
| 40 | + <li className="flex items-start gap-3"> |
| 41 | + <span className="text-gray-400">•</span> |
| 42 | + <span><code className="px-1.5 py-0.5 bg-gray-100 dark:bg-gray-900 rounded text-sm font-mono">/catalog/latest</code> should point to the newest drop</span> |
| 43 | + </li> |
| 44 | + <li className="flex items-start gap-3"> |
| 45 | + <span className="text-gray-400">•</span> |
| 46 | + <span>Retired product SKUs should redirect to relevant collections</span> |
| 47 | + </li> |
| 48 | + </ul> |
| 49 | + </div> |
| 50 | + |
| 51 | + {/* The Solution */} |
| 52 | + <div> |
| 53 | + <h2 className="text-2xl font-bold text-black dark:text-white mb-4"> |
| 54 | + The solution |
| 55 | + </h2> |
| 56 | + <p className="text-gray-600 dark:text-gray-400 mb-6"> |
| 57 | + Vercel's bulk redirects let you manage thousands of redirects at the edge—no middleware, no server-side logic. |
| 58 | + </p> |
| 59 | + <div className="space-y-4"> |
| 60 | + <div className="border border-gray-200 dark:border-gray-800 rounded-lg p-4"> |
| 61 | + <div className="font-medium text-black dark:text-white mb-1">1. Define redirects in a JSON file</div> |
| 62 | + <p className="text-sm text-gray-600 dark:text-gray-400"> |
| 63 | + Or fetch them from a CMS like Contentful, Sanity, or any API |
| 64 | + </p> |
| 65 | + </div> |
| 66 | + <div className="border border-gray-200 dark:border-gray-800 rounded-lg p-4"> |
| 67 | + <div className="font-medium text-black dark:text-white mb-1">2. Use vercel.ts to generate at build time</div> |
| 68 | + <p className="text-sm text-gray-600 dark:text-gray-400"> |
| 69 | + The config file runs during build and outputs the redirect rules |
| 70 | + </p> |
| 71 | + </div> |
| 72 | + <div className="border border-gray-200 dark:border-gray-800 rounded-lg p-4"> |
| 73 | + <div className="font-medium text-black dark:text-white mb-1">3. Redirects execute at the edge</div> |
| 74 | + <p className="text-sm text-gray-600 dark:text-gray-400"> |
| 75 | + Fast, globally distributed, no app code involved |
| 76 | + </p> |
| 77 | + </div> |
| 78 | + </div> |
| 79 | + </div> |
| 80 | + |
| 81 | + {/* Code Example */} |
| 82 | + <div> |
| 83 | + <h2 className="text-2xl font-bold text-black dark:text-white mb-4"> |
| 84 | + Example code |
| 85 | + </h2> |
| 86 | + <pre className="bg-gray-950 text-gray-100 p-6 rounded-lg overflow-x-auto text-sm font-mono"> |
| 87 | +{`// vercel.ts |
| 88 | +import type { VercelConfig } from '@vercel/config/v1' |
| 89 | +import { writeFileSync } from 'fs' |
| 90 | +
|
| 91 | +const redirects = [ |
| 92 | + { |
| 93 | + source: '/catalog/fall', |
| 94 | + destination: '/catalog/fall-2025', |
| 95 | + statusCode: 302 |
| 96 | + }, |
| 97 | + { |
| 98 | + source: '/catalog/latest', |
| 99 | + destination: '/catalog/spring-2026', |
| 100 | + permanent: true |
| 101 | + } |
| 102 | +] |
| 103 | +
|
| 104 | +writeFileSync( |
| 105 | + 'generated-redirects.json', |
| 106 | + JSON.stringify(redirects, null, 2) |
| 107 | +) |
| 108 | +
|
| 109 | +export const config: VercelConfig = { |
| 110 | + bulkRedirectsPath: './generated-redirects.json', |
| 111 | +}`} |
| 112 | + </pre> |
| 113 | + </div> |
| 114 | + |
| 115 | + {/* Try it */} |
| 116 | + <div> |
| 117 | + <h2 className="text-2xl font-bold text-black dark:text-white mb-4"> |
| 118 | + Try it |
| 119 | + </h2> |
| 120 | + <p className="text-gray-600 dark:text-gray-400 mb-6"> |
| 121 | + Click these links to see the redirects in action: |
| 122 | + </p> |
| 123 | + <div className="grid sm:grid-cols-2 gap-4"> |
| 124 | + <Link |
| 125 | + href="/catalog/fall" |
| 126 | + className="block border border-gray-200 dark:border-gray-800 rounded-lg p-4 hover:border-black dark:hover:border-white transition-colors" |
| 127 | + > |
| 128 | + <code className="text-sm font-mono text-black dark:text-white">/catalog/fall</code> |
| 129 | + <p className="text-xs text-gray-500 dark:text-gray-500 mt-1">→ fall-2025</p> |
| 130 | + </Link> |
| 131 | + <Link |
| 132 | + href="/catalog/winter" |
| 133 | + className="block border border-gray-200 dark:border-gray-800 rounded-lg p-4 hover:border-black dark:hover:border-white transition-colors" |
| 134 | + > |
| 135 | + <code className="text-sm font-mono text-black dark:text-white">/catalog/winter</code> |
| 136 | + <p className="text-xs text-gray-500 dark:text-gray-500 mt-1">→ winter-2025</p> |
| 137 | + </Link> |
| 138 | + <Link |
| 139 | + href="/catalog/latest" |
| 140 | + className="block border border-gray-200 dark:border-gray-800 rounded-lg p-4 hover:border-black dark:hover:border-white transition-colors" |
| 141 | + > |
| 142 | + <code className="text-sm font-mono text-black dark:text-white">/catalog/latest</code> |
| 143 | + <p className="text-xs text-gray-500 dark:text-gray-500 mt-1">→ spring-2026</p> |
| 144 | + </Link> |
| 145 | + <Link |
| 146 | + href="/catalog/outlet" |
| 147 | + className="block border border-gray-200 dark:border-gray-800 rounded-lg p-4 hover:border-black dark:hover:border-white transition-colors" |
| 148 | + > |
| 149 | + <code className="text-sm font-mono text-black dark:text-white">/catalog/outlet</code> |
| 150 | + <p className="text-xs text-gray-500 dark:text-gray-500 mt-1">→ archive</p> |
| 151 | + </Link> |
| 152 | + </div> |
| 153 | + </div> |
| 154 | + |
| 155 | + {/* Resources */} |
| 156 | + <div> |
| 157 | + <h2 className="text-2xl font-bold text-black dark:text-white mb-4"> |
| 158 | + Resources |
| 159 | + </h2> |
| 160 | + <div className="space-y-3"> |
| 161 | + <a |
| 162 | + href="https://vercel.com/docs/edge-network/redirects" |
| 163 | + target="_blank" |
| 164 | + rel="noopener noreferrer" |
| 165 | + className="flex items-center justify-between border border-gray-200 dark:border-gray-800 rounded-lg p-4 hover:border-black dark:hover:border-white transition-colors" |
| 166 | + > |
| 167 | + <div> |
| 168 | + <div className="font-medium text-black dark:text-white">Vercel Redirects Docs</div> |
| 169 | + <div className="text-sm text-gray-500 dark:text-gray-500">Official documentation</div> |
| 170 | + </div> |
| 171 | + <span className="text-gray-400">→</span> |
| 172 | + </a> |
| 173 | + <a |
| 174 | + href="https://github.com/vercel/examples/tree/main/cdn/cms-bulk-redirects" |
| 175 | + target="_blank" |
| 176 | + rel="noopener noreferrer" |
| 177 | + className="flex items-center justify-between border border-gray-200 dark:border-gray-800 rounded-lg p-4 hover:border-black dark:hover:border-white transition-colors" |
| 178 | + > |
| 179 | + <div> |
| 180 | + <div className="font-medium text-black dark:text-white">Source Code</div> |
| 181 | + <div className="text-sm text-gray-500 dark:text-gray-500">View on GitHub</div> |
| 182 | + </div> |
| 183 | + <span className="text-gray-400">→</span> |
| 184 | + </a> |
| 185 | + </div> |
| 186 | + </div> |
| 187 | + </div> |
| 188 | + </section> |
| 189 | + </main> |
| 190 | + ) |
| 191 | +} |
0 commit comments