File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,19 +55,10 @@ jobs:
5555 mkdir -p _site/playground
5656 cp -r packages/playground/dist/* _site/playground/
5757
58- # SPA fallback for playground client-side routes
59- cat > _site/404.html << 'FOUROHFOUR'
60- <!DOCTYPE html><html><head><meta charset="utf-8"><script>
61- var p = window.location.pathname;
62- if (p.startsWith('/spac/playground')) {
63- var base = '/spac/playground/';
64- var route = p.slice(base.length).split('?')[0];
65- var search = window.location.search;
66- var sep = search ? search + '&' : '?';
67- window.location.replace(base + sep + '__route=' + encodeURIComponent(route) + window.location.hash);
68- }
69- </script></head><body></body></html>
70- FOUROHFOUR
58+ # SPA fallback — use the playground's index.html as 404 page.
59+ # This gives crawlers the OG meta tags, and browsers get the SPA
60+ # which reads the example from the URL path client-side.
61+ cp _site/playground/index.html _site/404.html
7162
7263 - uses : actions/upload-pages-artifact@v3
7364 with :
Original file line number Diff line number Diff line change 1313 < meta name ="twitter:card " content ="summary_large_image " />
1414 < meta name ="twitter:title " content ="spac playground " />
1515 < meta name ="twitter:description " content ="Interactive TypeScript → OpenAPI explorer with hover docs and source maps " />
16- < meta name ="twitter:image " content ="__OG_IMAGE__ " />
16+ < meta name ="twitter:image " content ="/og/playground.png " />
1717 </ head >
1818 < body >
1919 < style > html { color-scheme : dark; }</ style >
Original file line number Diff line number Diff line change @@ -16,18 +16,6 @@ const EXAMPLE_OPTIONS: Record<string, ExampleOption> = {
1616}
1717
1818function getExampleFromPath ( ) : string | null {
19- // Check for SPA fallback redirect (GitHub Pages 404.html sets __route param)
20- const params = new URLSearchParams ( window . location . search )
21- const route = params . get ( '__route' )
22- if ( route ) {
23- // Clean up the __route param from the URL
24- params . delete ( '__route' )
25- const clean = params . toString ( )
26- const newUrl = `${ baseUrl } ${ route } ${ clean ? '?' + clean : '' } ${ window . location . hash } `
27- window . history . replaceState ( { } , '' , newUrl )
28- return route . split ( '/' ) [ 0 ] || null
29- }
30-
3119 // Strip the Vite base URL before parsing
3220 const path = window . location . pathname . replace ( baseUrl . replace ( / \/ $ / , '' ) , '' )
3321 const seg = path . split ( '/' ) . filter ( Boolean ) [ 0 ]
You can’t perform that action at this time.
0 commit comments