Skip to content

Commit

Permalink
integration
Browse files Browse the repository at this point in the history
  • Loading branch information
martrapp committed Aug 27, 2024
1 parent 2a31ea6 commit d977d52
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-terms-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro-vtbot': patch
---

Makes inspection chamber integration more robust.
2 changes: 1 addition & 1 deletion integration/astro-inspection-chamber.js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const inspectionChamber = readFileSync('node_modules/@vtbag/inspection-chamber/l

export async function GET({ params, request }) {
return new Response(
`if (!!document.startViewTransition && sessionStorage.getItem('vtbot-inspection-chamber') === 'true') {${inspectionChamber}};`,
`if (!!top.document.startViewTransition && top.sessionStorage.getItem('vtbot-inspection-chamber') === 'true') {${inspectionChamber}};`,
{
status: 200,
headers: {
Expand Down
2 changes: 1 addition & 1 deletion integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function createIntegration(options?: VtBotOptions): AstroIntegrat

setupOptions.injectScript(
'head-inline',
`(function() {var s=document.createElement('script');s.src='/_vtbot_inspection_chamber.js';document.head.appendChild(s);var t=document.currentScript;setTimeout(()=>{t.remove();s.remove()},1000)})();`
`(function() {var s=document.createElement('script');s.blocking="render";s.src='/_vtbot_inspection_chamber.js';document.head.appendChild(s);var t=document.currentScript;setTimeout(()=>{t.remove();s.remove()},1000)})();`
);
}

Expand Down

0 comments on commit d977d52

Please sign in to comment.