Skip to content

fix firefox icon rendering (#221) #128

fix firefox icon rendering (#221)

fix firefox icon rendering (#221) #128

Workflow file for this run

name: github pages
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build-deploy:
runs-on: ubuntu-latest
env:
CARGO_INCREMENTAL: 1
steps:
- uses: actions/checkout@v4
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
version: 1.0
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: x86_64-unknown-linux-gnu,wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
cache-on-failure: "false"
- uses: cargo-bins/cargo-binstall@main
- name: Install CLI
run: cargo binstall dioxus-cli -y --force --version 0.7.0
- name: Build
run: cd preview && dx build --web --release --base-path "components"
- name: Copy output
run: cp -r target/dx/preview/release/web/public docs
- name: Add gh pages 404
run: |
echo "<!DOCTYPE html>
<html lang=\"en\">
<head>
<meta charset=\"UTF-8\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
<title>Redirecting</title>
</head>
<body>
<script>
// Find the subroute root from the current URL. Just the pattern components/pr-preview/pr-<PR_NUMBER>
const parts = window.location.pathname.split('/');
let realUrl;
if (parts[2] === 'pr-preview') {
realUrl = '/' + parts.slice(1, 4).join('/') + '/';
} else {
// If not a PR preview, redirect to the main page
realUrl = '/' + parts.slice(1, 2).join('/');
}
// Manually fetch the index.html file from the correct subroute
fetch(realUrl)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.text();
})
.then(html => {
// Set the current document's HTML to the fetched content
document.documentElement.innerHTML = html;
// After setting `document.documentElement.innerHTML = ...`, run scripts manually
document.documentElement.querySelectorAll('script').forEach(oldScript => {
const newScript = document.createElement('script');
// copy over all attributes (e.g. src, type, async, etc.)
for (const { name, value } of oldScript.attributes) {
newScript.setAttribute(name, value);
}
// copy inline code or fallback to src-based loading
newScript.textContent = oldScript.textContent;
// replace the old <script> so the browser will actually execute it
oldScript.replaceWith(newScript);
});
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
});
</script>
</body>
</html>" > docs/404.html
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4.2.3
with:
branch: gh-pages # The branch the action should deploy to.
folder: docs # The folder the action should deploy.
target-folder: .
clean: true
clean-exclude: pr-preview/**