#VT and Starlight

4 messages · Page 1 of 1 (latest)

brittle mirage
#

I'm seeking some guidance with implementing ViewTransitions in Starlight in my project. Here's what I've done so far:

Created a simple layout component:

---
import { ViewTransitions } from "astro:transitions";
---
<html lang="en">
<head>
<ViewTransitions />
</head>
<body>
<slot />
</body>
</html>

Added the layout property to MDX files in the docs directory:

---
layout: ../../../../layouts/StarlightLayout.astro
---

The issue I'm encountering is that when I click on any sidebar links, the page flashes and momentarily resets the styles. Other languages without custom layouts work fine, with a standard page reload (although I'm not entirely sure anymore if this is normal)

To troubleshoot, I tried the following:

  • Removed customCss: ["./src/styles/starlight.css"] from the astro.configo and imported the CSS directly into the layout. However, the issue persisted.
  • Checked the console and noticed some CSP errors from Vercel. Adjusted the configuration to eliminate the errors, issue persisted.
  • Reverted all changes, including removing the CSS import and restoring the default Starlight theme, issue persisted
  • Removed custom Tailwind plugins, issue persisted.

Interestingly, everything works smoothly in local development mode without any flashes or style resets.

Additionally, I'm encountering a "Failed to load resource" error for TableOfContents.astro, although the TOC is displaying fine on the page.

floral trailBOT
#

Hi @brittle mirage. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in the knowledge sources, it seems like you're encountering some common issues with Astro's ViewTransitions. Here are some potential solutions and explanations:

  1. Flashing and Style Resets: This could be due to the way ViewTransitions works. When you navigate to a new page, Astro creates default page animations based on the similarities between the old and new page. This might cause a brief "flash" as the old page content fades out and the new page content fades in (source (https://docs.astro.build/en/tutorials/add-view-transitions#add-the-viewtransitions--router)).

  2. Issues with Sidebar Links: If you're using a smaller screen size and trying to use a hamburger menu to navigate between pages, you might notice that your menu will no longer work after the first page load (source (https://docs.astro.build/en/tutorials/add-view-transitions#add-the-viewtransitions--router)).

  3. Issues with Scripts: If you're using scripts in your layout, you might encounter issues with them not working as expected when using ViewTransitions. There are some workarounds suggested in the Discord support thread, such as wrapping your script in an init function (source (https://discord.com/channels/830184174198718474/1193760306690793552)).

  4. "Failed to load resource" Error: This could be due to a variety of reasons, and without more specific information, it's hard to provide a definitive solution. However, it's worth noting that some users have reported similar issues on GitHub and Discord, and it might be worth checking out those threads for potential solutions (source (https://github.com/withastro/astro/issues/8341), source (https://discord.com/channels/830184174198718474/1210302661946253342)).

#

Remember, these are just potential solutions based on the information provided in the knowledge sources. If these solutions don't work, you might want to consider reaching out to the Astro community for more specific help.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: