diff --git a/advanced/subpath/vercel.mdx b/advanced/subpath/vercel.mdx index 85939577..e7bfd4e7 100644 --- a/advanced/subpath/vercel.mdx +++ b/advanced/subpath/vercel.mdx @@ -1,30 +1,30 @@ --- title: "Vercel" -description: "Host documentation at a /docs subpath using Vercel" +description: "Host documentation at a subpath using Vercel" --- -## vercel.json Configuration +import { VercelJsonGenerator } from "/snippets/vercel-json-generator.mdx"; -To host your documentation at a custom subpath using Vercel, you need to add the -following configuration to your `vercel.json` file. + + + Edit your file structure so that all your files are within a folder which is your custom subpath. So if you want to host your docs at `/docs` you would do the following: -```json -{ - "rewrites": [ - { - "source": "/docs", - "destination": "https://[subdomain].mintlify.dev/docs" - }, - { - "source": "/docs/:match*", - "destination": "https://[subdomain].mintlify.dev/docs/:match*" - } - ] -} -``` + ``` + /docs + introduction.mdx + navigation.mdx + docs.json + ``` + + + In your main website add the following rewrites to your `vercel.json`. + + + + For more information, you can also refer to Vercel's offical guide on rewrites: [Project Configuration: Rewrites](https://vercel.com/docs/projects/project-configuration#rewrites) - + \ No newline at end of file diff --git a/snippets/vercel-json-generator.mdx b/snippets/vercel-json-generator.mdx new file mode 100644 index 00000000..e6c61100 --- /dev/null +++ b/snippets/vercel-json-generator.mdx @@ -0,0 +1,94 @@ +export const VercelJsonGenerator = () => { + const [subdomain, setSubdomain] = useState('[SUBDOMAIN]') + const [subdirectory, setSubdirectory] = useState('docs') + + const vercelConfig = { + rewrites: [ + { + source: "/api/request", + destination: `https://${subdomain}.mintlify.app/api/request` + }, + { + source: `/${subdirectory}`, + destination: `https://${subdomain}.mintlify.app` + }, + { + source: `/${subdirectory}/llms.txt`, + destination: `https://${subdomain}.mintlify.app/llms.txt` + }, + { + source: `/${subdirectory}/llms-full.txt`, + destination: `https://${subdomain}.mintlify.app/llms-full.txt` + }, + { + source: `/${subdirectory}/sitemap.xml`, + destination: `https://${subdomain}.mintlify.app/sitemap.xml` + }, + { + source: `/${subdirectory}/robots.txt`, + destination: `https://${subdomain}.mintlify.app/robots.txt` + }, + { + source: `/${subdirectory}/:path*`, + destination: `https://${subdomain}.mintlify.app/${subdirectory}/:path*` + }, + { + source: "/mintlify-assets/:path+", + destination: `https://${subdomain}.mintlify.app/mintlify-assets/:path+` + } + ] + } + + const copyToClipboard = () => { + navigator.clipboard + .writeText(JSON.stringify(vercelConfig, null, 2)) + .then(() => { + console.log('Copied config to clipboard!') + }) + .catch((err) => { + console.error("Failed to copy: ", err) + }) + } + + return ( +
+
+
+ + setSubdomain(e.target.value)} + placeholder="your-subdomain" + className="w-full p-1 text-sm rounded border dark:border-white/10 bg-transparent" + /> +
+
+ + setSubdirectory(e.target.value)} + placeholder="docs" + className="w-full p-1 text-sm rounded border dark:border-white/10 bg-transparent" + /> +
+
+
+ +
+          {JSON.stringify(vercelConfig, null, 2)}
+        
+
+
+ ) +}