docs(website): tabbed per-OS install instructions with auto-detection
website / deploy (push) Successful in 33s
website / deploy (push) Successful in 33s
Split the install page into Linux / macOS / Windows tabs so each visitor sees only the commands that apply to them. A small InstallOsDetect component seeds Starlight's synced-tabs localStorage key with the detected OS before the tabs render, so the matching tab is pre-selected with no flash — and only when the visitor hasn't already picked a tab, so a manual choice wins. - installation.md -> .mdx (needs the Tabs/TabItem components) - detection covers navigator.userAgentData and the legacy platform/UA fallbacks; unknown platforms fall through to the default tab - piggybacks on Starlight's own restore mechanism rather than re-implementing tab switching
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
// Pre-selects the install-instructions tab that matches the visitor's OS.
|
||||||
|
//
|
||||||
|
// This piggybacks on Starlight's synced-tabs mechanism rather than fighting it.
|
||||||
|
// A `<Tabs syncKey="install-os">` restores its active tab from
|
||||||
|
// `localStorage["starlight-synced-tabs__install-os"]` via a script Starlight
|
||||||
|
// inlines *before* the tabs render (so there is no flash of the wrong tab). All
|
||||||
|
// we do here is seed that same key with the detected OS — and only when the
|
||||||
|
// visitor has not already chosen a tab themselves, so a manual choice always wins.
|
||||||
|
//
|
||||||
|
// Requirements (mirrors Starlight's own restore script):
|
||||||
|
// - Must be placed *before* the `<Tabs>` it targets, so this runs first.
|
||||||
|
// - The stored value must equal one of the TabItem labels exactly
|
||||||
|
// ("Linux" / "macOS" / "Windows").
|
||||||
|
// - Inlined, so it runs during parse before the restore script's
|
||||||
|
// connectedCallback and paint.
|
||||||
|
---
|
||||||
|
|
||||||
|
<script is:inline>
|
||||||
|
(() => {
|
||||||
|
const KEY = 'starlight-synced-tabs__install-os';
|
||||||
|
try {
|
||||||
|
// A previously stored value is a deliberate user choice — never override it.
|
||||||
|
if (localStorage.getItem(KEY)) return;
|
||||||
|
const data = navigator.userAgentData;
|
||||||
|
const platform = ((data && data.platform) || navigator.platform || '').toLowerCase();
|
||||||
|
const ua = (navigator.userAgent || '').toLowerCase();
|
||||||
|
let os = null;
|
||||||
|
if (platform.includes('win') || ua.includes('windows')) os = 'Windows';
|
||||||
|
else if (platform.includes('mac') || ua.includes('mac os x')) os = 'macOS';
|
||||||
|
else if (platform.includes('linux') || platform.includes('x11') || ua.includes('linux'))
|
||||||
|
os = 'Linux';
|
||||||
|
if (os) localStorage.setItem(KEY, os);
|
||||||
|
} catch (e) {
|
||||||
|
// localStorage unavailable (private mode, blocked cookies, …) — silently
|
||||||
|
// fall back to the default first tab. No detection, no harm.
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
+65
-37
@@ -5,77 +5,105 @@ sidebar:
|
|||||||
order: 1
|
order: 1
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import { Tabs, TabItem } from '@astrojs/starlight/components';
|
||||||
|
import InstallOsDetect from '../../../components/InstallOsDetect.astro';
|
||||||
|
|
||||||
RDBMS Playground is a single self-contained program. There is nothing to
|
RDBMS Playground is a single self-contained program. There is nothing to
|
||||||
configure and no separate database to install — everything it needs is
|
configure and no separate database to install — everything it needs is
|
||||||
built in.
|
built in.
|
||||||
|
|
||||||
Pick whichever method suits your platform. The one-line installers are the
|
Pick the tab for your platform — we try to select it automatically — then
|
||||||
quickest if you just want to get going.
|
use whichever method you prefer. The one-line installers are the quickest if
|
||||||
|
you just want to get going.
|
||||||
|
|
||||||
## One line
|
<InstallOsDetect />
|
||||||
|
|
||||||
These download the matching binary for your machine, verify its checksum,
|
<Tabs syncKey="install-os">
|
||||||
and put it on your `PATH`.
|
<TabItem label="Linux">
|
||||||
|
|
||||||
### Linux & macOS
|
**One-line installer**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
curl -fsSL https://git.lazyeval.net/oli/rdbms-playground/raw/branch/main/scripts/install.sh | sh
|
curl -fsSL https://git.lazyeval.net/oli/rdbms-playground/raw/branch/main/scripts/install.sh | sh
|
||||||
```
|
```
|
||||||
|
|
||||||
It detects your operating system and CPU, installs to `~/.local/bin`, and
|
It detects your CPU, installs to `~/.local/bin`, and prints a hint if that
|
||||||
prints a hint if that directory isn't on your `PATH`. Set
|
directory isn't on your `PATH`. Set `RDBMS_INSTALL_DIR` to install elsewhere,
|
||||||
`RDBMS_INSTALL_DIR` to install somewhere else, or `RDBMS_VERSION=vX.Y.Z` to
|
or `RDBMS_VERSION=vX.Y.Z` to pin a version. Prefer to read a script before
|
||||||
pin a specific version. Prefer to read a script before running it? It lives
|
running it? It lives at
|
||||||
at [`scripts/install.sh`](https://git.lazyeval.net/oli/rdbms-playground/raw/branch/main/scripts/install.sh).
|
[`scripts/install.sh`](https://git.lazyeval.net/oli/rdbms-playground/raw/branch/main/scripts/install.sh).
|
||||||
|
|
||||||
### Windows (PowerShell)
|
**Homebrew**
|
||||||
|
|
||||||
```powershell
|
|
||||||
irm https://git.lazyeval.net/oli/rdbms-playground/raw/branch/main/scripts/install.ps1 | iex
|
|
||||||
```
|
|
||||||
|
|
||||||
It downloads the matching `.exe`, verifies its checksum, installs to
|
|
||||||
`%LOCALAPPDATA%\Programs\rdbms-playground`, and adds that folder to your
|
|
||||||
user `PATH`. Use `-InstallDir` to choose a different location or `-Version`
|
|
||||||
to pin a release.
|
|
||||||
|
|
||||||
## Package managers
|
|
||||||
|
|
||||||
### Homebrew (macOS & Linux)
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
brew tap lazyeval/tap https://git.lazyeval.net/lazyeval/homebrew-tap
|
brew tap lazyeval/tap https://git.lazyeval.net/lazyeval/homebrew-tap
|
||||||
brew install lazyeval/tap/rdbms-playground
|
brew install lazyeval/tap/rdbms-playground
|
||||||
```
|
```
|
||||||
|
|
||||||
### Scoop (Windows)
|
</TabItem>
|
||||||
|
<TabItem label="macOS">
|
||||||
|
|
||||||
|
**One-line installer**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curl -fsSL https://git.lazyeval.net/oli/rdbms-playground/raw/branch/main/scripts/install.sh | sh
|
||||||
|
```
|
||||||
|
|
||||||
|
It detects your CPU (Apple Silicon or Intel), installs to `~/.local/bin`, and
|
||||||
|
prints a hint if that directory isn't on your `PATH`. Set `RDBMS_INSTALL_DIR`
|
||||||
|
to install elsewhere, or `RDBMS_VERSION=vX.Y.Z` to pin a version. Prefer to
|
||||||
|
read a script before running it? It lives at
|
||||||
|
[`scripts/install.sh`](https://git.lazyeval.net/oli/rdbms-playground/raw/branch/main/scripts/install.sh).
|
||||||
|
|
||||||
|
**Homebrew**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
brew tap lazyeval/tap https://git.lazyeval.net/lazyeval/homebrew-tap
|
||||||
|
brew install lazyeval/tap/rdbms-playground
|
||||||
|
```
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
<TabItem label="Windows">
|
||||||
|
|
||||||
|
**One-line installer (PowerShell)**
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
irm https://git.lazyeval.net/oli/rdbms-playground/raw/branch/main/scripts/install.ps1 | iex
|
||||||
|
```
|
||||||
|
|
||||||
|
It downloads the matching `.exe`, verifies its checksum, installs to
|
||||||
|
`%LOCALAPPDATA%\Programs\rdbms-playground`, and adds that folder to your user
|
||||||
|
`PATH`. Use `-InstallDir` to choose a different location or `-Version` to pin
|
||||||
|
a release.
|
||||||
|
|
||||||
|
**Scoop**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
scoop bucket add lazyeval https://git.lazyeval.net/lazyeval/scoop-bucket
|
scoop bucket add lazyeval https://git.lazyeval.net/lazyeval/scoop-bucket
|
||||||
scoop install rdbms-playground
|
scoop install rdbms-playground
|
||||||
```
|
```
|
||||||
|
|
||||||
### winget (Windows)
|
**winget**
|
||||||
|
|
||||||
:::note
|
|
||||||
A winget package (`winget install LazyEvaluation.RdbmsPlayground`) is on its
|
A winget package (`winget install LazyEvaluation.RdbmsPlayground`) is on its
|
||||||
way and awaiting review in the public winget catalogue. Until it lands, use
|
way and awaiting review in the public winget catalogue. Until it lands, use
|
||||||
Scoop or the PowerShell one-liner above.
|
Scoop or the PowerShell one-liner above.
|
||||||
:::
|
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
## With cargo
|
## With cargo
|
||||||
|
|
||||||
If you have a Rust toolchain, you can install from
|
These work on any platform with a Rust toolchain. Install from
|
||||||
[crates.io](https://crates.io/crates/rdbms-playground):
|
[crates.io](https://crates.io/crates/rdbms-playground):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cargo install rdbms-playground
|
cargo install rdbms-playground
|
||||||
```
|
```
|
||||||
|
|
||||||
For a faster install that fetches a prebuilt binary instead of compiling,
|
For a faster install that fetches a prebuilt binary instead of compiling, use
|
||||||
use [`cargo-binstall`](https://github.com/cargo-bins/cargo-binstall)
|
[`cargo-binstall`](https://github.com/cargo-bins/cargo-binstall) (install it
|
||||||
(install it first — it is not part of `cargo` itself):
|
first — it is not part of `cargo` itself):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cargo binstall rdbms-playground
|
cargo binstall rdbms-playground
|
||||||
@@ -83,11 +111,11 @@ cargo binstall rdbms-playground
|
|||||||
|
|
||||||
## Prebuilt binaries
|
## Prebuilt binaries
|
||||||
|
|
||||||
Every release publishes static Linux, standalone Windows, and macOS
|
Every release publishes static Linux, standalone Windows, and macOS binaries
|
||||||
binaries (x86_64 and aarch64), each with a `.sha256` checksum, on the
|
(x86_64 and aarch64), each with a `.sha256` checksum, on the
|
||||||
[releases page](https://git.lazyeval.net/oli/rdbms-playground/releases).
|
[releases page](https://git.lazyeval.net/oli/rdbms-playground/releases).
|
||||||
Download the one for your platform, make it executable if needed, and put
|
Download the one for your platform, make it executable if needed, and put it
|
||||||
it somewhere on your `PATH`.
|
somewhere on your `PATH`.
|
||||||
|
|
||||||
## Run it
|
## Run it
|
||||||
|
|
||||||
Reference in New Issue
Block a user