diff --git a/.changeset/twenty-turtles-rule.md b/.changeset/twenty-turtles-rule.md new file mode 100644 index 00000000..9e2464b9 --- /dev/null +++ b/.changeset/twenty-turtles-rule.md @@ -0,0 +1,5 @@ +--- +'@spotlightjs/astro': patch +--- + +Show Spotlight button if dev overlay is not enabled diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 6527cfb6..9fa65b2e 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -7,5 +7,6 @@ module.exports = { plugins: ['react-refresh'], rules: { 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], + '@typescript-eslint/ban-ts-comment': 'off', }, }; diff --git a/packages/astro/src/index.ts b/packages/astro/src/index.ts index 5d92815f..1eea4da1 100644 --- a/packages/astro/src/index.ts +++ b/packages/astro/src/index.ts @@ -23,6 +23,7 @@ const createPlugin = (options?: SpotlightOptions): AstroIntegration => { hooks: { 'astro:config:setup': async ({ command, injectScript, addDevOverlayPlugin, logger, config }) => { + console.log(config); if (command === 'dev') { logger.info('[@spotlightjs/astro] Setting up Spotlight'); @@ -36,7 +37,21 @@ const createPlugin = (options?: SpotlightOptions): AstroIntegration => { ...(config.vite.plugins || []), ]; - injectScript('page', buildClientInitSnippet({ importPath: PKG_NAME, showTriggerButton: false, ...options })); + let showTriggerButton = true; + // We suppose with 4.0 this will be promoted top level and expimental will be removed + // to keep backwards compatibility we check both + // @ts-ignore + if (config.devOverlay) { + // @ts-ignore + showTriggerButton = config.devOverlay ? false : true; + } + // @ts-ignore + if (config.experimental?.devOverlay) { + // @ts-ignore + showTriggerButton = config.experimental?.devOverlay ? false : true; + } + + injectScript('page', buildClientInitSnippet({ importPath: PKG_NAME, showTriggerButton, ...options })); injectScript('page-ssr', SPOTLIGHT_SERVER_SNIPPET); const importPath = path.dirname(url.fileURLToPath(import.meta.url));