Skip to content

Commit

Permalink
Show Spotlight trigger if no dev overlay is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
HazAT committed Nov 24, 2023
1 parent 91d843c commit 5eedd2d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/twenty-turtles-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@spotlightjs/astro': patch
---

Show Spotlight button if dev overlay is not enabled
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ module.exports = {
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
'@typescript-eslint/ban-ts-comment': 'off',
},
};
17 changes: 16 additions & 1 deletion packages/astro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const createPlugin = (options?: SpotlightOptions): AstroIntegration => {

hooks: {
'astro:config:setup': async ({ command, injectScript, addDevOverlayPlugin, logger, config }) => {
console.log(config);

This comment has been minimized.

Copy link
@HazAT

HazAT Nov 24, 2023

Author Member

I removed that already

if (command === 'dev') {
logger.info('[@spotlightjs/astro] Setting up Spotlight');

Expand All @@ -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));
Expand Down

0 comments on commit 5eedd2d

Please sign in to comment.