Ignore visits from the Astro integration #984
-
Describe your problem 🧐I'm using Astro along with Swup for page transitions and Sanity Studio as my CMS, which is hosted under /admin. I want to completely disable Swup when users visit /admin so that it loads normally without interference. What is your question? 🙋♀️Does the Astro Swup integration provide an option to exclude certain paths (e.g., /admin) from Swup? If not, what would be the best way to achieve this? I didn't see an ignoreVisit or similar option in the integration's config. I would appreciate any recommendations or workarounds to handle this properly. Thanks in advance! URL to minimal reproduction 🔗localhost:4321/admin Checked all these? 📚
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 27 replies
-
|
Hi! The Astro integration doesn't have an In the meantime, you can set an option to make swup available on the global window object, and set the // astro.config.js
import { defineConfig } from 'astro/config'
import swup from '@swup/astro'
export default defineConfig({
integrations: [
swup({
globalInstance: true
})
]
}
);<!-- Layout.astro -->
<!DOCTYPE html>
<html>
<head>
<script>
const setup = () => {
window.swup.options.ignoreVisit = (url) => url.startsWith('/admin')
}
if (window.swup) {
setup()
} else {
document.addEventListener('swup:enable', setup)
}
</script>
</head> |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
|
Thank you for looking into this. I couldn't get your solution working, but I will wait for an official fix. |
Beta Was this translation helpful? Give feedback.
-
|
I see the issue now :) You have to remove the |
Beta Was this translation helpful? Give feedback.
-
|
We've published version 1.6.0 of the Astro integration which allows ignoring links. You should be good to go with this option: swup({
ignore: ['/studio']
}) |
Beta Was this translation helpful? Give feedback.
We've published version 1.6.0 of the Astro integration which allows ignoring links. You should be good to go with this option: