|
5 | 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
6 | 6 | <title>FluxMQ Documentation</title> |
7 | 7 | <script> |
8 | | - // GitHub Pages 404 重定向脚本 |
9 | | - // 这个脚本会重定向到正确的路径 |
10 | | - var pathSegmentsToKeep = 1; |
11 | | - |
12 | | - var l = window.location; |
13 | | - l.replace( |
14 | | - l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + |
15 | | - l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' + |
16 | | - l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') + |
17 | | - (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + |
18 | | - l.hash |
19 | | - ); |
| 8 | + // SPA fallback for GitHub Pages/custom domains. |
| 9 | + // Custom domain: /architecture -> /?/architecture |
| 10 | + // Project page: /flux-message-flow/architecture -> /flux-message-flow/?/architecture |
| 11 | + (function () { |
| 12 | + var l = window.location; |
| 13 | + var origin = l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : ''); |
| 14 | + var isProjectPage = l.hostname === 'quickmsg.github.io' && l.pathname.indexOf('/flux-message-flow/') === 0; |
| 15 | + var pathSegmentsToKeep = isProjectPage ? 1 : 0; |
| 16 | + var pathSegments = l.pathname.split('/'); |
| 17 | + var basePath = pathSegments.slice(0, 1 + pathSegmentsToKeep).join('/'); |
| 18 | + var routePath = l.pathname |
| 19 | + .slice(1) |
| 20 | + .split('/') |
| 21 | + .slice(pathSegmentsToKeep) |
| 22 | + .join('/') |
| 23 | + .replace(/^\/+|\/+$/g, ''); |
| 24 | + |
| 25 | + var search = l.search; |
| 26 | + |
| 27 | + // Older fallback settings could create URLs like /architecture/?/&/~and~/... |
| 28 | + // Drop that generated query and keep the real route segment. |
| 29 | + if (search.indexOf('?/') === 0 || search.indexOf('?/&') === 0) { |
| 30 | + search = ''; |
| 31 | + } |
| 32 | + |
| 33 | + l.replace( |
| 34 | + origin + |
| 35 | + basePath + |
| 36 | + '/?/' + |
| 37 | + routePath.replace(/&/g, '~and~') + |
| 38 | + (search ? '&' + search.slice(1).replace(/&/g, '~and~') : '') + |
| 39 | + l.hash |
| 40 | + ); |
| 41 | + })(); |
20 | 42 | </script> |
21 | 43 | </head> |
22 | 44 | <body> |
|
0 commit comments