Skip to content

Commit f1564dc

Browse files
devongovettLFDanLu
andauthored
docs: Fix docs issues (#9021)
* Hide error page from side nav * Set cache control headers in azure * Fix og image paths * Fix link clicks outside public url * add missing vanilla css dep * Fix og image paths * use environment variable for public url? --------- Co-authored-by: Daniel Lu <dl1644@gmail.com>
1 parent 8160fb1 commit f1564dc

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

.circleci/config.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -816,9 +816,10 @@ jobs:
816816
- run:
817817
name: deploy
818818
command: |
819-
azcopy copy "/tmp/dist/production/docs/*" "https://reactspectrum.blob.core.windows.net/\$web${AZURE_STORAGE_SAS_TOKEN}" --recursive --exclude-pattern "*.md;*.txt"
820-
azcopy copy "/tmp/dist/production/docs/*" "https://reactspectrum.blob.core.windows.net/\$web${AZURE_STORAGE_SAS_TOKEN}" --recursive --include-pattern "*.md" --content-type "text/markdown; charset=utf-8"
821-
azcopy copy "/tmp/dist/production/docs/*" "https://reactspectrum.blob.core.windows.net/\$web${AZURE_STORAGE_SAS_TOKEN}" --recursive --include-pattern "*.txt" --content-type "text/plain; charset=utf-8"
819+
azcopy copy "/tmp/dist/production/docs/*" "https://reactspectrum.blob.core.windows.net/\$web${AZURE_STORAGE_SAS_TOKEN}" --recursive --exclude-pattern "*.md;*.txt;*.html;*.rsc"
820+
azcopy copy "/tmp/dist/production/docs/*" "https://reactspectrum.blob.core.windows.net/\$web${AZURE_STORAGE_SAS_TOKEN}" --recursive --include-pattern "*.md" --content-type "text/markdown; charset=utf-8" --cache-control "max-age=300"
821+
azcopy copy "/tmp/dist/production/docs/*" "https://reactspectrum.blob.core.windows.net/\$web${AZURE_STORAGE_SAS_TOKEN}" --recursive --include-pattern "*.txt" --content-type "text/plain; charset=utf-8" --cache-control "max-age=300"
822+
azcopy copy "/tmp/dist/production/docs/*" "https://reactspectrum.blob.core.windows.net/\$web${AZURE_STORAGE_SAS_TOKEN}" --recursive --include-pattern "*.html;*.rsc" --cache-control "max-age=300"
822823
823824
comment:
824825
executor: rsp

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,16 @@ s2-api-diff:
146146
node scripts/api-diff.js --skip-same --skip-style-props
147147

148148
s2-docs:
149-
BASE_URL=https://reactspectrum.blob.core.windows.net PUBLIC_URL=/reactspectrum/$$(git rev-parse HEAD)/s2-docs DIST_DIR=dist/$$(git rev-parse HEAD)/s2-docs $(MAKE) build-s2-docs
149+
PUBLIC_URL=https://reactspectrum.blob.core.windows.net/reactspectrum/$$(git rev-parse HEAD)/s2-docs DIST_DIR=dist/$$(git rev-parse HEAD)/s2-docs $(MAKE) build-s2-docs
150150

151151
s2-docs-production:
152-
BASE_URL=https://react-spectrum.adobe.com PUBLIC_URL=/beta DIST_DIR=dist/production/docs/beta $(MAKE) build-s2-docs
152+
PUBLIC_URL=https://react-spectrum.adobe.com/beta DIST_DIR=dist/production/docs/beta $(MAKE) build-s2-docs
153153

154154
build-s2-docs:
155155
yarn workspace @react-spectrum/s2-docs generate:md
156156
yarn workspace @react-spectrum/s2-docs generate:og
157-
REGISTRY_URL=$(BASE_URL)$(PUBLIC_URL)/registry node scripts/buildRegistry.mjs
158-
REGISTRY_URL=$(BASE_URL)$(PUBLIC_URL)/registry yarn build:s2-docs --public-url $(PUBLIC_URL)
157+
REGISTRY_URL=$(PUBLIC_URL)/registry node scripts/buildRegistry.mjs
158+
REGISTRY_URL=$(PUBLIC_URL)/registry yarn build:s2-docs --public-url $(PUBLIC_URL)
159159
mkdir -p $(DIST_DIR)
160160
mv packages/dev/s2-docs/dist/* $(DIST_DIR)
161161
mkdir -p $(DIST_DIR)/registry

packages/dev/s2-docs/src/CodeSandbox.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ const dependencies = {
3838
'react-aria-components': '^1.10.0',
3939
react: '^19',
4040
'react-dom': '^19',
41-
'lucide-react': '^0.514.0'
41+
'lucide-react': '^0.514.0',
42+
'clsx': '^2.1.1'
4243
},
4344
tailwind: {
4445
'react-aria-components': '^1.10.0',

packages/dev/s2-docs/src/Layout.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,11 @@ const getTitle = (currentPage: Page): string => {
6464
};
6565

6666
const getOgImageUrl = (currentPage: Page): string => {
67-
const slug = currentPage.url.replace(/^\//, '').replace(/\.html$/, '');
68-
69-
if (slug.includes('s2-docs/')) {
70-
// For build links, use the full URL
71-
const ogPath = slug.replace(/s2-docs\//, 's2-docs/og/');
72-
return `https://reactspectrum.blob.core.windows.net/${ogPath}.png`;
67+
let publicUrl = process.env.PUBLIC_URL || '/';
68+
if (!publicUrl.endsWith('/')) {
69+
publicUrl += '/';
7370
}
74-
75-
// For production, use relative path with /og/ prefix
76-
return `/og/${slug}.png`;
71+
return publicUrl + 'og/' + currentPage.url.replace(publicUrl, '').replace(/\.html$/, '.png');
7772
};
7873

7974
const getDescription = (currentPage: Page): string => {

packages/dev/s2-docs/src/Nav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function Nav({pages, currentPage}: PageProps) {
1111
let currentLibrary = getLibraryFromPage(currentPage);
1212
let sections = new Map();
1313
for (let page of pages) {
14-
if (page.exports?.hideNav) {
14+
if (page.exports?.hideNav || page.exports?.hideFromSearch) {
1515
continue;
1616
}
1717

packages/dev/s2-docs/src/client.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ async function navigate(pathname: string, push = false) {
4949
// Intercept link clicks to perform RSC navigation.
5050
document.addEventListener('click', e => {
5151
let link = (e.target as Element).closest('a');
52+
let publicUrl = process.env.PUBLIC_URL || '/';
53+
let publicUrlPathname = publicUrl.startsWith('http') ? new URL(publicUrl).pathname : publicUrl;
5254
if (
5355
link &&
5456
link instanceof HTMLAnchorElement &&
@@ -57,6 +59,7 @@ document.addEventListener('click', e => {
5759
link.origin === location.origin &&
5860
link.pathname !== location.pathname &&
5961
!link.hasAttribute('download') &&
62+
link.pathname.startsWith(publicUrlPathname) &&
6063
e.button === 0 && // left clicks only
6164
!e.metaKey && // open in new tab (mac)
6265
!e.ctrlKey && // open in new tab (windows)

0 commit comments

Comments
 (0)