Only activate partytown if necessary
This commit is contained in:
@ -9,15 +9,15 @@ import image from '@astrojs/image';
|
||||
import mdx from '@astrojs/mdx';
|
||||
import partytown from '@astrojs/partytown';
|
||||
|
||||
import { remarkReadingTime } from './src/utils/frontmatter.js';
|
||||
|
||||
import { remarkReadingTime } from './src/utils/frontmatter.mjs';
|
||||
import { SITE } from './src/config.mjs';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
// https://astro.build/config
|
||||
const whenExternalScripts = (items = []) =>
|
||||
SITE.googleAnalyticsId ? (Array.isArray(items) ? items.map((item) => item()) : [items()]) : [];
|
||||
|
||||
export default defineConfig({
|
||||
// Astro uses this full URL to generate your sitemap and canonical URLs in your final build
|
||||
site: SITE.origin,
|
||||
base: SITE.basePathname,
|
||||
trailingSlash: SITE.trailingSlash ? 'always' : 'never',
|
||||
@ -36,10 +36,11 @@ export default defineConfig({
|
||||
}),
|
||||
mdx(),
|
||||
|
||||
/* Disable this integration if you don't use Google Analytics (or other external script). */
|
||||
partytown({
|
||||
config: { forward: ['dataLayer.push'] },
|
||||
}),
|
||||
...whenExternalScripts(() =>
|
||||
partytown({
|
||||
config: { forward: ['dataLayer.push'] },
|
||||
})
|
||||
),
|
||||
],
|
||||
|
||||
markdown: {
|
||||
|
Reference in New Issue
Block a user