Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const scripts = [];
// `npm start` and `npm run dev` sets it to 'development'
if (process.env.NODE_ENV === 'production') {
scripts.push({ src: '/js/reo.js' });
scripts.push({
src: 'https://tluma.ai/widget.js',
async: true,
});
}

// Determine base URL from environment variable or use defaults
Expand Down Expand Up @@ -406,6 +410,16 @@ const config: Config = {
darkTheme: prismThemes.dracula,
},
} satisfies Preset.ThemeConfig,
headTags: [
{
tagName: 'script',
innerHTML: `window.tlumaConfig = {
source: 'harperfast/documentation',
theme: 'auto',
button: 'bottom-right',
};`,
},
],
Comment on lines +413 to +422
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The tluma.ai widget script is only loaded in production (process.env.NODE_ENV === 'production'), but its configuration (window.tlumaConfig) is currently injected into the head tags in all environments, including development. To keep the environments consistent and avoid polluting the global scope with unused configuration in development, we should conditionally inject the headTags only in production.

	...(process.env.NODE_ENV === 'production'
		? {
				headTags: [
					{
						tagName: 'script',
						innerHTML: `window.tlumaConfig = {
			source: 'harperfast/documentation',
			theme: 'auto',
			button: 'bottom-right',
		};`,
					},
				],
			}
		: {}),

scripts,
};

Expand Down
Loading