@@ -29,63 +29,64 @@ jobs:
2929 with :
3030 cache-all-crates : " true"
3131 cache-on-failure : " false"
32+ - uses : cargo-bins/cargo-binstall@main
3233 - name : Install CLI
33- run : cargo install dioxus-cli --git https://github.com/dioxuslabs/dioxus --rev 0dd0f05d
34+ run : cargo binstall dioxus-cli -y --force --version 0.7.0-alpha.2
3435 - name : Build
3536 run : cd preview && dx build --platform web --release --base-path "components"
3637 - name : Copy output
3738 run : cp -r target/dx/preview/release/web/public docs
3839 - name : Add gh pages 404
3940 run : |
40- echo "<!DOCTYPE html>
41- <html lang=\"en\">
42- <head>
43- <meta charset=\"UTF-8\">
44- <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
45- <title>Redirecting</title>
46- </head>
47- <body>
48- <script>
49- // Find the subroute root from the current URL. Just the pattern components/pr-preview/pr-<PR_NUMBER>
50- const parts = window.location.pathname.split('/');
51- let realUrl;
52- if (parts[2] === 'pr-preview') {
53- realUrl = '/' + parts.slice(1, 4).join('/') + '/';
54- } else {
55- // If not a PR preview, redirect to the main page
56- realUrl = '/' + parts.slice(1, 2).join('/');
57- }
58- // Manually fetch the index.html file from the correct subroute
59- fetch(realUrl)
60- .then(response => {
61- if (!response.ok) {
62- throw new Error('Network response was not ok');
41+ echo "<!DOCTYPE html>
42+ <html lang=\"en\">
43+ <head>
44+ <meta charset=\"UTF-8\">
45+ <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
46+ <title>Redirecting</title>
47+ </head>
48+ <body>
49+ <script>
50+ // Find the subroute root from the current URL. Just the pattern components/pr-preview/pr-<PR_NUMBER>
51+ const parts = window.location.pathname.split('/');
52+ let realUrl;
53+ if (parts[2] === 'pr-preview') {
54+ realUrl = '/' + parts.slice(1, 4).join('/') + '/';
55+ } else {
56+ // If not a PR preview, redirect to the main page
57+ realUrl = '/' + parts.slice(1, 2).join('/');
58+ }
59+ // Manually fetch the index.html file from the correct subroute
60+ fetch(realUrl)
61+ .then(response => {
62+ if (!response.ok) {
63+ throw new Error('Network response was not ok');
64+ }
65+ return response.text();
66+ })
67+ .then(html => {
68+ // Set the current document's HTML to the fetched content
69+ document.documentElement.innerHTML = html;
70+ // After setting `document.documentElement.innerHTML = ...`, run scripts manually
71+ document.documentElement.querySelectorAll('script').forEach(oldScript => {
72+ const newScript = document.createElement('script');
73+ // copy over all attributes (e.g. src, type, async, etc.)
74+ for (const { name, value } of oldScript.attributes) {
75+ newScript.setAttribute(name, value);
6376 }
64- return response.text();
65- })
66- .then(html => {
67- // Set the current document's HTML to the fetched content
68- document.documentElement.innerHTML = html;
69- // After setting `document.documentElement.innerHTML = ...`, run scripts manually
70- document.documentElement.querySelectorAll('script').forEach(oldScript => {
71- const newScript = document.createElement('script');
72- // copy over all attributes (e.g. src, type, async, etc.)
73- for (const { name, value } of oldScript.attributes) {
74- newScript.setAttribute(name, value);
75- }
76- // copy inline code or fallback to src-based loading
77- newScript.textContent = oldScript.textContent;
78- // replace the old <script> so the browser will actually execute it
79- oldScript.replaceWith(newScript);
80- });
77+ // copy inline code or fallback to src-based loading
78+ newScript.textContent = oldScript.textContent;
79+ // replace the old <script> so the browser will actually execute it
80+ oldScript.replaceWith(newScript);
81+ });
8182
82- })
83- .catch(error => {
84- console.error('There was a problem with the fetch operation:', error);
85- });
86- </script>
87- </body>
88- </html>" > docs/404.html
83+ })
84+ .catch(error => {
85+ console.error('There was a problem with the fetch operation:', error);
86+ });
87+ </script>
88+ </body>
89+ </html>" > docs/404.html
8990 - name : Deploy 🚀
9091 uses : JamesIves/github-pages-deploy-action@v4.2.3
9192 with :
0 commit comments