Skip to content

Commit 837e2c5

Browse files
committed
Read RTD canonical URL to set VitePress base path for sub-path deploys
1 parent 93e6ace commit 837e2c5

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

.vitepress/config.mts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import { defineConfig } from 'vitepress'
22
import { redirectsPlugin, defaultPluginOptions } from './plugins/redirects'
33

4+
// Read the path prefix from RTD's canonical URL env var when present
5+
// (e.g. https://<slug>.readthedocs.build/en/171/ → /en/171/), so all
6+
// asset URLs resolve correctly under the PR-preview subpath. Defaults
7+
// to '/' for the GitHub Pages build at zarr.dev.
8+
const rtdUrl = process.env.READTHEDOCS_CANONICAL_URL
9+
const base = rtdUrl ? new URL(rtdUrl).pathname : '/'
10+
411
export default defineConfig({
12+
base,
513
title: 'Zarr',
614
description: 'Zarr is a community project to develop specifications and software for storage of large N-dimensional typed arrays, also commonly known as tensors.',
715
cleanUrls: true,

0 commit comments

Comments
 (0)