continue-custom/docs/snippets/OSAutoDetect.jsx
Dallin Romney d585c3b8e8
feat(cli): curl/irl installation scripts and docs (#9835)
* feat: curl/irl scripts for installing Continue CLI

* fix: address code review comments for installation scripts

- Fix CLEANUP_FNM to only mark for cleanup if fnm dir doesn't pre-exist
- Guard FNM_DIR expansion with parameter substitution to avoid set -u errors
- Persist fnm PATH to user environment in PowerShell for future sessions
- Persist npm global bin PATH to user environment in PowerShell

Co-authored-by: dallin <dallin@continue.dev>

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>

* feat: use CLIInstall component throughout guides and docs

* fix: cubic feedback typo

* docs: move node installation path into tab

* docs: move node installation path into tab

* fix: address cubic feedback

---------

Co-authored-by: RomneyDa <RomneyDa@users.noreply.github.com>
Co-authored-by: Continue <noreply@continue.dev>
Co-authored-by: continue[bot] <230936708+continue[bot]@users.noreply.github.com>
2026-02-05 19:07:57 -08:00

35 lines
1.2 KiB
JavaScript

// Auto-selects the appropriate tab based on the user's OS
// Import with: import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
// Usage: <OSAutoDetect /> at the top of a page with OS-specific tabs
// Tab order: 0 = macOS/Linux, 1 = Windows, 2 = npm (default)
export const OSAutoDetect = () => {
return (
<script
dangerouslySetInnerHTML={{
__html: `
if (typeof window !== 'undefined') {
window.addEventListener('load', function() {
const ua = navigator.userAgent.toLowerCase();
const isWindows = ua.includes('win');
const isMac = ua.includes('mac');
const isLinux = ua.includes('linux');
// macOS/Linux (0), Windows (1), npm (2 - default)
let tabIndex = 2;
if (isMac || isLinux) {
tabIndex = 0;
} else if (isWindows) {
tabIndex = 1;
}
const tabButtons = document.querySelectorAll('[role="tablist"] button');
if (tabButtons && tabButtons[tabIndex]) {
tabButtons[tabIndex].click();
}
});
}
`,
}}
/>
);
};