removed ads, fixed copy image for newer iOS
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
---
|
||||
import BackToTop from "./BackToTop.astro"
|
||||
import LeftSidebarDesktop from "./LeftSidebarDesktop.astro"
|
||||
---
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-2">
|
||||
@@ -14,7 +13,6 @@ import LeftSidebarDesktop from "./LeftSidebarDesktop.astro"
|
||||
<div id="facetContainer"></div>
|
||||
</div>
|
||||
</div>
|
||||
<LeftSidebarDesktop />
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-10 mt-0">
|
||||
<div class="d-flex flex-column gap-1 flex-md-row align-items-center mb-3 w-100 justify-content-start">
|
||||
@@ -114,6 +112,9 @@ import LeftSidebarDesktop from "./LeftSidebarDesktop.astro"
|
||||
|
||||
// ── Global helpers ────────────────────────────────────────────────────────
|
||||
window.copyImage = async function(img) {
|
||||
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) ||
|
||||
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
|
||||
|
||||
try {
|
||||
const canvas = document.createElement("canvas");
|
||||
const ctx = canvas.getContext("2d");
|
||||
@@ -129,10 +130,17 @@ import LeftSidebarDesktop from "./LeftSidebarDesktop.astro"
|
||||
clean.src = img.src;
|
||||
});
|
||||
|
||||
const blob = await new Promise((resolve, reject) => {
|
||||
canvas.toBlob(b => b ? resolve(b) : reject(new Error('toBlob failed')), 'image/png');
|
||||
});
|
||||
|
||||
if (isIOS) {
|
||||
const file = new File([blob], 'card.png', { type: 'image/png' });
|
||||
await navigator.share({ files: [file] });
|
||||
return;
|
||||
}
|
||||
|
||||
if (navigator.clipboard && navigator.clipboard.write) {
|
||||
const blob = await new Promise((resolve, reject) => {
|
||||
canvas.toBlob(b => b ? resolve(b) : reject(new Error('toBlob failed')), 'image/png');
|
||||
});
|
||||
await navigator.clipboard.write([new ClipboardItem({ "image/png": blob })]);
|
||||
showCopyToast('📋 Image copied!', '#198754');
|
||||
} else {
|
||||
@@ -151,6 +159,7 @@ import LeftSidebarDesktop from "./LeftSidebarDesktop.astro"
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (err.name === 'AbortError') return;
|
||||
console.error('Failed:', err);
|
||||
showCopyToast('❌ Copy failed', '#dc3545');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user