docs: refresh docs site
This commit is contained in:
parent
e322aad2e9
commit
e8e04a49f9
1
.github/workflows/pages.yml
vendored
1
.github/workflows/pages.yml
vendored
@ -8,6 +8,7 @@ on:
|
||||
- "docs/**"
|
||||
- "scripts/gen-command-reference.sh"
|
||||
- "scripts/build-docs-site.mjs"
|
||||
- "scripts/docs-site-assets.mjs"
|
||||
- "Makefile"
|
||||
- ".github/workflows/pages.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
@ -340,7 +340,8 @@ go run scripts/gen-auth-services-md.go
|
||||
|
||||
## Documentation
|
||||
|
||||
- [docs/README.md](docs/README.md): docs overview
|
||||
- [docs/index.md](docs/index.md): docs overview (rendered at <https://gogcli.sh/>)
|
||||
- [docs/quickstart.md](docs/quickstart.md): five-minute setup walkthrough
|
||||
- [docs/commands/README.md](docs/commands/README.md): generated command index
|
||||
- [docs/safety-profiles.md](docs/safety-profiles.md): command guards and baked safe binaries
|
||||
- [docs/auth-clients.md](docs/auth-clients.md): OAuth clients, account mapping, and service accounts
|
||||
|
||||
@ -1,77 +0,0 @@
|
||||
# gog Docs
|
||||
|
||||
`gog` is a single CLI for Google Workspace automation: Gmail, Calendar, Drive,
|
||||
Docs, Sheets, Slides, Contacts, Tasks, People, Forms, Apps Script, Groups, Admin,
|
||||
Keep, and related agent workflows.
|
||||
|
||||
## Start Here
|
||||
|
||||
- Install and authenticate from the repository
|
||||
[README](https://github.com/steipete/gogcli#readme).
|
||||
- Read [Install and Runtime Packages](install.md) when installing from
|
||||
Homebrew, Docker, GitHub releases, Windows ZIPs, or source.
|
||||
- Read [Auth Clients](auth-clients.md) when setting up OAuth clients, service
|
||||
accounts, or Workspace domain-wide delegation.
|
||||
- Read [Command Guards and Baked Safety Profiles](safety-profiles.md) when
|
||||
running `gog` from agents or automation.
|
||||
- Read the bundled [`gog` agent skill](../.agents/skills/gog/SKILL.md) when an
|
||||
agent needs safe auth preflight, JSON-first output, or guarded Workspace
|
||||
automation patterns.
|
||||
- Read [Sheets Tables](sheets-tables.md) when creating or inspecting Google
|
||||
Sheets structured tables.
|
||||
- Open the [Command Index](commands/README.md) for generated docs for every CLI
|
||||
command.
|
||||
|
||||
## Feature Pages
|
||||
|
||||
- [Install and Runtime Packages](install.md)
|
||||
- [Auth Clients](auth-clients.md)
|
||||
- [Command Guards and Baked Safety Profiles](safety-profiles.md)
|
||||
- [Raw API Dumps](raw-api.md)
|
||||
- [Raw API Sensitive Field Audit](raw-audit.md)
|
||||
- [Gmail Workflows](gmail-workflows.md)
|
||||
- [Gmail watch](watch.md)
|
||||
- [Email Tracking](email-tracking.md)
|
||||
- [Drive Audits](drive-audits.md)
|
||||
- [Contacts Dedupe Preview](contacts-dedupe.md)
|
||||
- [Contacts JSON Update](contacts-json-update.md)
|
||||
- [Google Docs Editing](docs-editing.md)
|
||||
- [Sheets Tables](sheets-tables.md)
|
||||
- [Sheets Formatting](sheets-formatting.md)
|
||||
- [Slides from Markdown](slides-markdown.md)
|
||||
- [Slides Template Replacement](slides-template-replacement.md)
|
||||
- [Backups](backup.md)
|
||||
- [Date and Time Input Formats](dates.md)
|
||||
|
||||
## Common Paths
|
||||
|
||||
```bash
|
||||
gog auth add you@gmail.com --services gmail,calendar,drive
|
||||
gog gmail search 'newer_than:7d' --max 10
|
||||
gog gmail get <messageId> --sanitize-content --json
|
||||
gog calendar events --today
|
||||
gog drive ls --max 20
|
||||
```
|
||||
|
||||
## Command Docs
|
||||
|
||||
Every command page under `docs/commands/` is generated from
|
||||
`gog schema --json`. Do not hand-edit generated command pages. After changing
|
||||
commands, flags, aliases, arguments, or help text, run:
|
||||
|
||||
```bash
|
||||
make docs-commands
|
||||
```
|
||||
|
||||
`make docs-check` verifies that every schema command has a generated page and
|
||||
that required feature pages are present and linked from this overview.
|
||||
|
||||
Then build the GitHub Pages site locally:
|
||||
|
||||
```bash
|
||||
make docs-site
|
||||
open dist/docs-site/index.html
|
||||
```
|
||||
|
||||
The site is intentionally static: no framework, no package install, and no
|
||||
client-side dependency beyond a small navigation script embedded by the builder.
|
||||
@ -1,489 +0,0 @@
|
||||
:root {
|
||||
--bg0: #07070b;
|
||||
--bg1: #0b0b11;
|
||||
--bg2: #11111a;
|
||||
--card: rgba(17, 17, 26, 0.72);
|
||||
--card2: rgba(12, 12, 18, 0.64);
|
||||
--stroke: rgba(255, 255, 255, 0.08);
|
||||
--stroke2: rgba(255, 255, 255, 0.05);
|
||||
--text: #f3f4f6;
|
||||
--muted: rgba(243, 244, 246, 0.7);
|
||||
--dim: rgba(243, 244, 246, 0.46);
|
||||
|
||||
--b: #4285f4;
|
||||
--r: #ea4335;
|
||||
--y: #fbbc05;
|
||||
--g: #34a853;
|
||||
|
||||
--shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
|
||||
--shadow2: 0 16px 40px rgba(0, 0, 0, 0.45);
|
||||
|
||||
--radius: 16px;
|
||||
--radius2: 22px;
|
||||
|
||||
--serif: "Fraunces", ui-serif, Georgia, serif;
|
||||
--sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
||||
--mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: radial-gradient(1200px 800px at 50% -20%, rgba(66, 133, 244, 0.18), transparent 60%),
|
||||
radial-gradient(900px 700px at 80% 18%, rgba(234, 67, 53, 0.14), transparent 55%),
|
||||
radial-gradient(1000px 900px at 18% 62%, rgba(52, 168, 83, 0.14), transparent 55%),
|
||||
radial-gradient(900px 900px at 65% 88%, rgba(251, 188, 5, 0.12), transparent 55%),
|
||||
linear-gradient(180deg, var(--bg0), var(--bg1) 40%, var(--bg0));
|
||||
color: var(--text);
|
||||
font-family: var(--sans);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
line-height: 1.55;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: var(--mono);
|
||||
font-size: 0.95em;
|
||||
}
|
||||
|
||||
.skip {
|
||||
position: absolute;
|
||||
left: -999px;
|
||||
top: 10px;
|
||||
background: var(--bg2);
|
||||
border: 1px solid var(--stroke);
|
||||
color: var(--text);
|
||||
padding: 10px 12px;
|
||||
border-radius: 10px;
|
||||
z-index: 20;
|
||||
}
|
||||
.skip:focus {
|
||||
left: 12px;
|
||||
}
|
||||
|
||||
.bg {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.bg__mesh {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: radial-gradient(1200px 800px at 20% 20%, rgba(66, 133, 244, 0.18), transparent 60%),
|
||||
radial-gradient(1000px 800px at 82% 30%, rgba(234, 67, 53, 0.12), transparent 55%),
|
||||
radial-gradient(1000px 900px at 40% 85%, rgba(52, 168, 83, 0.12), transparent 55%);
|
||||
filter: blur(4px) saturate(1.12);
|
||||
opacity: 0.95;
|
||||
}
|
||||
|
||||
.bg__grid {
|
||||
position: absolute;
|
||||
inset: -2px;
|
||||
background-image: linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
|
||||
linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
|
||||
background-size: 72px 72px;
|
||||
opacity: 0.055;
|
||||
transform: perspective(900px) rotateX(58deg) translateY(-18%);
|
||||
transform-origin: top;
|
||||
mask-image: radial-gradient(60% 60% at 50% 30%, rgba(0, 0, 0, 1), transparent 72%);
|
||||
}
|
||||
|
||||
.bg__grain {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
opacity: 0.2;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E");
|
||||
mix-blend-mode: overlay;
|
||||
}
|
||||
|
||||
.wrap {
|
||||
width: min(1100px, calc(100% - 48px));
|
||||
margin: 0 auto;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.top {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
background: rgba(7, 7, 11, 0.58);
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
|
||||
.top__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 14px 0;
|
||||
}
|
||||
|
||||
.brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
.brand__mark {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border-radius: 10px;
|
||||
background: conic-gradient(from 200deg, var(--b), var(--g), var(--y), var(--r), var(--b));
|
||||
box-shadow: 0 10px 24px rgba(66, 133, 244, 0.15), 0 10px 24px rgba(52, 168, 83, 0.12);
|
||||
}
|
||||
|
||||
.brand__mark--small {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 7px;
|
||||
}
|
||||
|
||||
.brand__name {
|
||||
font-family: var(--mono);
|
||||
font-weight: 500;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.brand__tag {
|
||||
font-size: 12px;
|
||||
color: var(--dim);
|
||||
border: 1px solid var(--stroke2);
|
||||
background: rgba(17, 17, 26, 0.55);
|
||||
padding: 3px 8px;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18px;
|
||||
font-size: 14px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.nav a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.nav a:hover {
|
||||
color: var(--text);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.nav__cta {
|
||||
color: var(--text) !important;
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
padding: 8px 12px;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.main {
|
||||
padding-bottom: 70px;
|
||||
}
|
||||
|
||||
.hero {
|
||||
padding: 56px 0 26px;
|
||||
}
|
||||
|
||||
.hero__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1.05fr 0.95fr;
|
||||
gap: 28px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.kicker {
|
||||
display: inline-flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
color: rgba(243, 244, 246, 0.58);
|
||||
margin: 0 0 14px;
|
||||
}
|
||||
|
||||
.kicker::before {
|
||||
content: "";
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 3px;
|
||||
background: linear-gradient(135deg, rgba(66, 133, 244, 0.9), rgba(52, 168, 83, 0.85));
|
||||
box-shadow: 0 0 0 4px rgba(66, 133, 244, 0.08);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-family: var(--serif);
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.03em;
|
||||
line-height: 0.95;
|
||||
margin: 0 0 14px;
|
||||
font-size: clamp(44px, 5.5vw, 68px);
|
||||
}
|
||||
|
||||
.hero__word {
|
||||
display: block;
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
animation: rise 700ms cubic-bezier(0.2, 1, 0.2, 1) forwards;
|
||||
}
|
||||
|
||||
.hero__word:nth-child(1) {
|
||||
animation-delay: 80ms;
|
||||
}
|
||||
.hero__word:nth-child(2) {
|
||||
animation-delay: 160ms;
|
||||
}
|
||||
.hero__word:nth-child(3) {
|
||||
animation-delay: 260ms;
|
||||
}
|
||||
|
||||
.hero__word--mono {
|
||||
font-family: var(--mono);
|
||||
font-weight: 500;
|
||||
letter-spacing: -0.04em;
|
||||
color: rgba(243, 244, 246, 0.92);
|
||||
}
|
||||
|
||||
@keyframes rise {
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.lede {
|
||||
margin: 0 0 18px;
|
||||
font-size: 16.5px;
|
||||
color: var(--muted);
|
||||
max-width: 52ch;
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
animation: rise 700ms cubic-bezier(0.2, 1, 0.2, 1) 320ms forwards;
|
||||
}
|
||||
|
||||
.lede strong {
|
||||
color: var(--text);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.pills {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin: 0 0 20px;
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
animation: rise 700ms cubic-bezier(0.2, 1, 0.2, 1) 380ms forwards;
|
||||
}
|
||||
|
||||
.pill {
|
||||
font-size: 12px;
|
||||
border-radius: 999px;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid var(--stroke2);
|
||||
background: rgba(17, 17, 26, 0.55);
|
||||
color: rgba(243, 244, 246, 0.76);
|
||||
}
|
||||
|
||||
.pill--b {
|
||||
box-shadow: inset 0 0 0 1px rgba(66, 133, 244, 0.25);
|
||||
}
|
||||
.pill--r {
|
||||
box-shadow: inset 0 0 0 1px rgba(234, 67, 53, 0.22);
|
||||
}
|
||||
.pill--y {
|
||||
box-shadow: inset 0 0 0 1px rgba(251, 188, 5, 0.22);
|
||||
}
|
||||
.pill--g {
|
||||
box-shadow: inset 0 0 0 1px rgba(52, 168, 83, 0.22);
|
||||
}
|
||||
|
||||
.hero__actions {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin: 0 0 12px;
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
animation: rise 700ms cubic-bezier(0.2, 1, 0.2, 1) 440ms forwards;
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
padding: 10px 14px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
text-decoration: none !important;
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
|
||||
}
|
||||
|
||||
.btn--primary {
|
||||
background: linear-gradient(135deg, rgba(66, 133, 244, 0.92), rgba(52, 168, 83, 0.86));
|
||||
color: #091018;
|
||||
border-color: rgba(255, 255, 255, 0.12);
|
||||
box-shadow: 0 18px 44px rgba(66, 133, 244, 0.18), 0 18px 44px rgba(52, 168, 83, 0.14);
|
||||
}
|
||||
|
||||
.btn--ghost {
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.note {
|
||||
margin: 0;
|
||||
color: rgba(243, 244, 246, 0.56);
|
||||
font-size: 13px;
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
animation: rise 700ms cubic-bezier(0.2, 1, 0.2, 1) 520ms forwards;
|
||||
}
|
||||
|
||||
.note code {
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border: 1px solid rgba(255, 255, 255, 0.07);
|
||||
padding: 2px 6px;
|
||||
border-radius: 8px;
|
||||
color: rgba(243, 244, 246, 0.84);
|
||||
}
|
||||
|
||||
.hero__panel {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
animation: rise 700ms cubic-bezier(0.2, 1, 0.2, 1) 260ms forwards;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: 1px solid var(--stroke);
|
||||
background: var(--card);
|
||||
border-radius: var(--radius2);
|
||||
box-shadow: var(--shadow);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.term__bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 12px 14px;
|
||||
background: rgba(12, 12, 18, 0.58);
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
|
||||
.dots {
|
||||
display: inline-flex;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.dot {
|
||||
width: 11px;
|
||||
height: 11px;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.dot--r {
|
||||
background: #ff5f57;
|
||||
}
|
||||
.dot--y {
|
||||
background: #febc2e;
|
||||
}
|
||||
.dot--g {
|
||||
background: #28c840;
|
||||
}
|
||||
|
||||
.term__title {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
font-family: var(--mono);
|
||||
font-size: 12px;
|
||||
color: rgba(243, 244, 246, 0.55);
|
||||
}
|
||||
|
||||
.term__body {
|
||||
padding: 14px 14px 16px;
|
||||
background: rgba(11, 11, 17, 0.6);
|
||||
}
|
||||
|
||||
.term__pre {
|
||||
margin: 0;
|
||||
font-family: var(--mono);
|
||||
font-size: 12.5px;
|
||||
color: rgba(243, 244, 246, 0.86);
|
||||
line-height: 1.6;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.term__pre code {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.meta {
|
||||
padding: 14px 14px;
|
||||
background: var(--card2);
|
||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||
box-shadow: var(--shadow2);
|
||||
}
|
||||
|
||||
.meta__item {
|
||||
display: grid;
|
||||
grid-template-columns: 90px 1fr;
|
||||
gap: 12px;
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.meta__item + .meta__item {
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
|
||||
.meta__k {
|
||||
color: rgba(243, 244, 246, 0.55);
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.meta__v {
|
||||
color: rgba(243, 244, 246, 0.86);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.meta__v code {
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border: 1px solid rgba(255, 255, 255, 0.07);
|
||||
padding: 2px 6px;
|
||||
border-radius: 8px;
|
||||
color: rgba(243, 244, 246, 0.9);
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
(() => {
|
||||
const el = document.getElementById("demo");
|
||||
if (!el) return;
|
||||
|
||||
const original = el.textContent || "";
|
||||
const prefersReduced = window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches;
|
||||
if (prefersReduced) return;
|
||||
|
||||
el.textContent = "";
|
||||
|
||||
const lines = original.split("\n");
|
||||
const chunkDelay = 16;
|
||||
const lineDelay = 140;
|
||||
let i = 0;
|
||||
let j = 0;
|
||||
|
||||
const tick = () => {
|
||||
if (i >= lines.length) return;
|
||||
const line = lines[i];
|
||||
if (j <= line.length) {
|
||||
el.textContent += line.slice(j, j + 1);
|
||||
j += 1;
|
||||
window.setTimeout(tick, chunkDelay);
|
||||
return;
|
||||
}
|
||||
el.textContent += "\n";
|
||||
i += 1;
|
||||
j = 0;
|
||||
window.setTimeout(tick, lineDelay);
|
||||
};
|
||||
|
||||
window.setTimeout(tick, 260);
|
||||
})();
|
||||
|
||||
@ -1,239 +0,0 @@
|
||||
.section {
|
||||
padding: 52px 0;
|
||||
}
|
||||
|
||||
.section__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 0.36fr 0.64fr;
|
||||
gap: 28px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-family: var(--serif);
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
margin: 0 0 6px;
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin: 0 0 8px;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.muted {
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.cols {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.block {
|
||||
padding: 16px 16px;
|
||||
}
|
||||
|
||||
.code {
|
||||
margin: 0;
|
||||
padding: 12px 12px;
|
||||
border-radius: 14px;
|
||||
background: rgba(0, 0, 0, 0.22);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.code code {
|
||||
font-family: var(--mono);
|
||||
font-size: 12.5px;
|
||||
color: rgba(243, 244, 246, 0.88);
|
||||
}
|
||||
|
||||
.steps {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.step {
|
||||
display: grid;
|
||||
grid-template-columns: 46px 1fr;
|
||||
gap: 14px;
|
||||
padding: 16px;
|
||||
border-radius: var(--radius2);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
background: rgba(12, 12, 18, 0.46);
|
||||
box-shadow: var(--shadow2);
|
||||
}
|
||||
|
||||
.step__n {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 14px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
font-family: var(--mono);
|
||||
font-weight: 500;
|
||||
color: rgba(243, 244, 246, 0.92);
|
||||
background: linear-gradient(135deg, rgba(66, 133, 244, 0.22), rgba(52, 168, 83, 0.18));
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
.step p {
|
||||
margin: 0 0 10px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.callout {
|
||||
margin-top: 14px;
|
||||
display: grid;
|
||||
grid-template-columns: 44px 1fr;
|
||||
gap: 14px;
|
||||
padding: 16px;
|
||||
border-radius: var(--radius2);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
background: linear-gradient(135deg, rgba(66, 133, 244, 0.14), rgba(234, 67, 53, 0.08));
|
||||
box-shadow: var(--shadow2);
|
||||
}
|
||||
|
||||
.callout__icon {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 16px;
|
||||
background: rgba(0, 0, 0, 0.18);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
box-shadow: inset 0 0 0 1px rgba(66, 133, 244, 0.18);
|
||||
}
|
||||
|
||||
.callout__body p {
|
||||
margin: 0 0 10px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.callout__body code {
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border: 1px solid rgba(255, 255, 255, 0.07);
|
||||
padding: 2px 6px;
|
||||
border-radius: 8px;
|
||||
color: rgba(243, 244, 246, 0.92);
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.feat {
|
||||
padding: 16px;
|
||||
background: rgba(12, 12, 18, 0.46);
|
||||
box-shadow: var(--shadow2);
|
||||
}
|
||||
|
||||
.feat p {
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.footerline {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
.sitefoot {
|
||||
padding: 36px 0 26px;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.08);
|
||||
background: rgba(7, 7, 11, 0.35);
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.sitefoot__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.sitefoot__brand {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
font-family: var(--mono);
|
||||
}
|
||||
|
||||
.sitefoot__small {
|
||||
margin-top: 8px;
|
||||
color: rgba(243, 244, 246, 0.6);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.sitefoot__small a {
|
||||
color: rgba(243, 244, 246, 0.75);
|
||||
}
|
||||
|
||||
.sep {
|
||||
margin: 0 8px;
|
||||
color: rgba(243, 244, 246, 0.28);
|
||||
}
|
||||
|
||||
.sitefoot__right {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
color: rgba(243, 244, 246, 0.7);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.sitefoot__fineprint {
|
||||
margin-top: 18px;
|
||||
color: rgba(243, 244, 246, 0.46);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
.hero__grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.section__grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.grid {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.wrap {
|
||||
width: min(1100px, calc(100% - 28px));
|
||||
}
|
||||
.nav {
|
||||
display: none;
|
||||
}
|
||||
.cols {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.footerline {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.sitefoot__row {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
* {
|
||||
animation: none !important;
|
||||
transition: none !important;
|
||||
scroll-behavior: auto !important;
|
||||
}
|
||||
}
|
||||
|
||||
301
docs/index.html
301
docs/index.html
@ -1,301 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>gog — Google in your terminal</title>
|
||||
<meta
|
||||
name="description"
|
||||
content="gog: a single CLI for Gmail, Calendar, Drive, Contacts, Tasks, Sheets, Docs, Slides, and People."
|
||||
/>
|
||||
<meta name="theme-color" content="#0b0b11" />
|
||||
<meta property="og:title" content="gog — Google in your terminal" />
|
||||
<meta
|
||||
property="og:description"
|
||||
content="One CLI for Gmail, Calendar, Drive, Contacts, Tasks, Sheets, Docs, Slides, and People."
|
||||
/>
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content="https://gogcli.sh/" />
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,700&family=DM+Sans:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<link rel="stylesheet" href="./assets/site.css" />
|
||||
<link rel="stylesheet" href="./assets/site.more.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a class="skip" href="#main">Skip to content</a>
|
||||
|
||||
<div class="bg" aria-hidden="true">
|
||||
<div class="bg__mesh"></div>
|
||||
<div class="bg__grid"></div>
|
||||
<div class="bg__grain"></div>
|
||||
</div>
|
||||
|
||||
<header class="top">
|
||||
<div class="wrap top__row">
|
||||
<a class="brand" href="/">
|
||||
<span class="brand__mark" aria-hidden="true"></span>
|
||||
<span class="brand__name">gog</span>
|
||||
<span class="brand__tag">gogcli</span>
|
||||
</a>
|
||||
<nav class="nav">
|
||||
<a href="#install">Install</a>
|
||||
<a href="#quickstart">Quickstart</a>
|
||||
<a href="#features">Features</a>
|
||||
<a href="#examples">Examples</a>
|
||||
<a class="nav__cta" href="https://github.com/steipete/gogcli">GitHub</a>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main id="main" class="main">
|
||||
<section class="hero">
|
||||
<div class="wrap hero__grid">
|
||||
<div class="hero__copy">
|
||||
<p class="kicker">Google Workspace. One binary.</p>
|
||||
<h1>
|
||||
<span class="hero__word">Google</span>
|
||||
<span class="hero__word">in your</span>
|
||||
<span class="hero__word hero__word--mono">terminal</span>
|
||||
</h1>
|
||||
<p class="lede">
|
||||
<strong>gog</strong> unifies Gmail, Calendar, Drive, Contacts, Tasks, Sheets, Docs, Slides, and People
|
||||
under one CLI — with JSON output and sane defaults.
|
||||
</p>
|
||||
|
||||
<div class="pills" aria-label="Supported services">
|
||||
<span class="pill pill--b">Gmail</span>
|
||||
<span class="pill pill--g">Calendar</span>
|
||||
<span class="pill pill--r">Drive</span>
|
||||
<span class="pill pill--y">Contacts</span>
|
||||
<span class="pill pill--g">Tasks</span>
|
||||
<span class="pill pill--g">Sheets</span>
|
||||
<span class="pill pill--b">Docs</span>
|
||||
<span class="pill pill--r">Slides</span>
|
||||
<span class="pill pill--y">People</span>
|
||||
</div>
|
||||
|
||||
<div class="hero__actions">
|
||||
<a class="btn btn--primary" href="#install">Install</a>
|
||||
<a class="btn btn--ghost" href="https://github.com/steipete/gogcli#quick-start">Readme</a>
|
||||
</div>
|
||||
|
||||
<p class="note">
|
||||
Tip: set a default in <code>gog auth manage</code> or export <code>GOG_ACCOUNT=you@gmail.com</code> once, stop repeating <code>--account</code>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="hero__panel">
|
||||
<div class="card term" role="region" aria-label="Terminal demo">
|
||||
<div class="term__bar" aria-hidden="true">
|
||||
<span class="dots">
|
||||
<span class="dot dot--r"></span>
|
||||
<span class="dot dot--y"></span>
|
||||
<span class="dot dot--g"></span>
|
||||
</span>
|
||||
<span class="term__title">gogcli.sh</span>
|
||||
</div>
|
||||
<div class="term__body">
|
||||
<pre class="term__pre"><code id="demo">
|
||||
$ brew install gogcli
|
||||
$ gog auth credentials ~/Downloads/client_secret.json
|
||||
$ gog auth add you@gmail.com
|
||||
|
||||
$ export GOG_ACCOUNT=you@gmail.com
|
||||
$ gog gmail labels list
|
||||
$ gog calendar calendars --max 5 --json | jq '.calendars[].summary'
|
||||
$ gog drive ls --query "mimeType='application/pdf'" --max 3
|
||||
</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card meta">
|
||||
<div class="meta__item">
|
||||
<div class="meta__k">Output</div>
|
||||
<div class="meta__v">tables / <code>--plain</code> / <code>--json</code></div>
|
||||
</div>
|
||||
<div class="meta__item">
|
||||
<div class="meta__k">Accounts</div>
|
||||
<div class="meta__v">multi-account + <code>gog auth manage</code></div>
|
||||
</div>
|
||||
<div class="meta__item">
|
||||
<div class="meta__k">Secrets</div>
|
||||
<div class="meta__v">OS keyring (Keychain / Secret Service / CredMan)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="install" class="section">
|
||||
<div class="wrap section__grid">
|
||||
<div>
|
||||
<h2>Install</h2>
|
||||
<p class="muted">Homebrew, or build from source.</p>
|
||||
</div>
|
||||
|
||||
<div class="cols">
|
||||
<div class="card block">
|
||||
<h3>Homebrew</h3>
|
||||
<pre class="code"><code>brew install gogcli</code></pre>
|
||||
</div>
|
||||
<div class="card block">
|
||||
<h3>From source</h3>
|
||||
<pre class="code"><code>git clone https://github.com/steipete/gogcli.git
|
||||
cd gogcli
|
||||
make
|
||||
./bin/gog --help</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="quickstart" class="section">
|
||||
<div class="wrap section__grid">
|
||||
<div>
|
||||
<h2>Quickstart</h2>
|
||||
<p class="muted">
|
||||
You’ll need a Google Cloud “Desktop app” OAuth client JSON once. Then you can keep adding accounts.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="steps">
|
||||
<div class="step">
|
||||
<div class="step__n">1</div>
|
||||
<div class="step__b">
|
||||
<h3>Store credentials</h3>
|
||||
<p>Save your downloaded client JSON into gog’s config.</p>
|
||||
<pre class="code"><code>gog auth credentials ~/Downloads/client_secret_....json</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="step">
|
||||
<div class="step__n">2</div>
|
||||
<div class="step__b">
|
||||
<h3>Authorize an account</h3>
|
||||
<p>Browser flow by default. Use <code>--manual</code> for headless.</p>
|
||||
<pre class="code"><code>gog auth add you@gmail.com</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="step">
|
||||
<div class="step__n">3</div>
|
||||
<div class="step__b">
|
||||
<h3>Run commands</h3>
|
||||
<p>Use <code>--json</code> for scripting.</p>
|
||||
<pre class="code"><code>export GOG_ACCOUNT=you@gmail.com
|
||||
gog gmail search 'newer_than:7d' --max 10 --json | jq</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="callout">
|
||||
<div class="callout__icon" aria-hidden="true"></div>
|
||||
<div class="callout__body">
|
||||
<h3>Re-auth a service (e.g. Sheets)</h3>
|
||||
<p>
|
||||
If you add scopes later and Google doesn’t return a refresh token, re-run with
|
||||
<code>--force-consent</code>.
|
||||
</p>
|
||||
<pre class="code"><code>gog auth add you@gmail.com --services sheets --force-consent</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="features" class="section">
|
||||
<div class="wrap section__grid">
|
||||
<div>
|
||||
<h2>Features</h2>
|
||||
<p class="muted">High leverage commands, consistent UX, and clean output.</p>
|
||||
</div>
|
||||
<div class="grid">
|
||||
<div class="card feat">
|
||||
<h3>Gmail</h3>
|
||||
<p>Search threads, send mail, manage labels, drafts, filters, settings, and watch (Pub/Sub push).</p>
|
||||
</div>
|
||||
<div class="card feat">
|
||||
<h3>Calendar</h3>
|
||||
<p>List/create/update events, respond to invites, detect conflicts, and check free/busy.</p>
|
||||
</div>
|
||||
<div class="card feat">
|
||||
<h3>Drive</h3>
|
||||
<p>List/search/upload/download, export Docs formats, permissions, folders, URLs.</p>
|
||||
</div>
|
||||
<div class="card feat">
|
||||
<h3>Sheets / Docs / Slides</h3>
|
||||
<p>Read/write Sheets; export Docs/Slides/Sheets to PDF/DOCX/PPTX/XLSX/CSV via Drive.</p>
|
||||
</div>
|
||||
<div class="card feat">
|
||||
<h3>Contacts / People</h3>
|
||||
<p>Personal contacts, “other contacts”, Workspace directory, and your profile.</p>
|
||||
</div>
|
||||
<div class="card feat">
|
||||
<h3>Tasks</h3>
|
||||
<p>Tasklists + tasks: add/update/done/undo/delete/clear with paging and JSON output.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="examples" class="section">
|
||||
<div class="wrap section__grid">
|
||||
<div>
|
||||
<h2>Examples</h2>
|
||||
<p class="muted">A few commands you’ll actually use.</p>
|
||||
</div>
|
||||
<div class="cols">
|
||||
<div class="card block">
|
||||
<h3>Find unread mail</h3>
|
||||
<pre class="code"><code>gog gmail search 'is:unread newer_than:7d' --max 20</code></pre>
|
||||
<p class="muted">Pipe JSON to jq for scripts.</p>
|
||||
<pre class="code"><code>gog gmail search 'newer_than:7d' --max 50 --json | jq '.threads[] | .subject'</code></pre>
|
||||
</div>
|
||||
<div class="card block">
|
||||
<h3>Export a Sheet as PDF</h3>
|
||||
<pre class="code"><code>gog sheets export <spreadsheetId> --format pdf --out ./sheet.pdf</code></pre>
|
||||
<p class="muted">Docs and Slides are similar.</p>
|
||||
<pre class="code"><code>gog docs export <docId> --format docx --out ./doc.docx
|
||||
gog slides export <presentationId> --format pptx --out ./deck.pptx</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footerline">
|
||||
<a class="btn btn--primary" href="https://github.com/steipete/gogcli">Go to GitHub</a>
|
||||
<a class="btn btn--ghost" href="https://github.com/steipete/gogcli/blob/main/CHANGELOG.md">Changelog</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer class="sitefoot">
|
||||
<div class="wrap sitefoot__row">
|
||||
<div class="sitefoot__left">
|
||||
<div class="sitefoot__brand">
|
||||
<span class="brand__mark brand__mark--small" aria-hidden="true"></span>
|
||||
<span>gog</span>
|
||||
</div>
|
||||
<div class="sitefoot__small">
|
||||
<span>Built by <a href="https://steipete.me">Peter Steinberger</a>.</span>
|
||||
<span class="sep" aria-hidden="true">·</span>
|
||||
<a href="https://github.com/steipete/gogcli/blob/main/LICENSE">MIT</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sitefoot__right">
|
||||
<a href="https://github.com/steipete/gogcli">Source</a>
|
||||
<a href="https://github.com/steipete/gogcli#installation">Install</a>
|
||||
<a href="https://github.com/steipete/gogcli#commands">Commands</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wrap sitefoot__fineprint">
|
||||
<span>Not affiliated with Google. Google is a trademark of Google LLC.</span>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="./assets/site.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
38
docs/index.md
Normal file
38
docs/index.md
Normal file
@ -0,0 +1,38 @@
|
||||
---
|
||||
title: Overview
|
||||
permalink: /
|
||||
description: "gog is a single Go CLI for Gmail, Calendar, Drive, Docs, Sheets, Slides, Forms, Apps Script, Contacts, Tasks, and Workspace admin — built for terminals, scripts, CI, and coding agents."
|
||||
---
|
||||
|
||||
# gog
|
||||
|
||||
A script-friendly Google Workspace CLI. One binary, every major Google API, predictable output for terminals, shell pipelines, CI, and coding agents.
|
||||
|
||||
## Why gog
|
||||
|
||||
- **One CLI, every API.** Gmail, Calendar, Drive, Docs, Sheets, Slides, Forms, Apps Script, Contacts, People, Tasks, Classroom, Chat, Groups, Keep, and Workspace Admin under one binary.
|
||||
- **Stable output.** `--json` to stdout for scripts, `--plain` TSV when you need to `awk`, human progress on stderr so pipes stay clean.
|
||||
- **Multi-account, multi-client.** Many Google accounts and OAuth client projects in one config. OAuth, direct access tokens, ADC, and Workspace service accounts all supported.
|
||||
- **Built for agents.** Runtime allow/deny lists (`--enable-commands`, `--disable-commands`, `--gmail-no-send`) and baked safety-profile binaries for sandboxes that should not be able to broaden their own permissions.
|
||||
- **Read-only audits.** Drive `tree`, `du`, `inventory`; Contacts `dedupe` preview; raw API JSON dumps without ever mutating remote state.
|
||||
- **Generated reference.** Every command has a Markdown page produced from `gog schema --json`.
|
||||
|
||||
## Pick your path
|
||||
|
||||
- **Trying it.** Read [Install](install.md), then [Quickstart](quickstart.md). Five minutes from `brew install` to your first authenticated query.
|
||||
- **Wiring up an agent.** Read [Safety Profiles](safety-profiles.md) and the bundled [`gog` agent skill](https://github.com/steipete/gogcli/blob/main/.agents/skills/gog/SKILL.md). Lock the binary down before you hand it to a model.
|
||||
- **Running Workspace at scale.** Read [Auth Clients](auth-clients.md) for service accounts, named OAuth clients, and domain-wide delegation.
|
||||
- **Backing up an account.** Read [Backup](backup.md) before pointing `gog backup push` at a busy mailbox.
|
||||
- **Looking up a flag.** Open the [Command Index](commands/) — every subcommand has a generated page.
|
||||
|
||||
## Status
|
||||
|
||||
`gog` is actively developed; the [CHANGELOG](https://github.com/steipete/gogcli/blob/main/CHANGELOG.md) has the most recent shipping log. The API surface is intentionally not 1:1 with `gmcli`/`gccli`/`gdcli` and there is no migration tooling — `gog` is the new CLI, not a port.
|
||||
|
||||
## Out of scope
|
||||
|
||||
- MCP server (this is a CLI).
|
||||
- Hosted runtime, web UI, or GUI.
|
||||
- Importing legacy `~/.gmcli`, `~/.gccli`, `~/.gdcli` state.
|
||||
|
||||
Released under the [MIT license](https://github.com/steipete/gogcli/blob/main/LICENSE). Not affiliated with Google. Google is a trademark of Google LLC.
|
||||
102
docs/install.md
102
docs/install.md
@ -1,13 +1,9 @@
|
||||
# Install and Runtime Packages
|
||||
|
||||
read_when:
|
||||
- Updating release packages, Docker images, or install instructions.
|
||||
- Debugging version mismatches between source, Homebrew, and downloaded assets.
|
||||
# Install
|
||||
|
||||
`gog` ships as a single binary. The visible version is injected at build time:
|
||||
release builds use the tag, while local builds use `git describe`.
|
||||
|
||||
## Homebrew
|
||||
## Homebrew (macOS, Linux)
|
||||
|
||||
```bash
|
||||
brew install gogcli
|
||||
@ -15,39 +11,24 @@ gog --version
|
||||
```
|
||||
|
||||
The Homebrew formula lives in `steipete/homebrew-tap` and installs the `gog`
|
||||
binary. Release verification should install or upgrade the tap formula and run:
|
||||
binary. Release verification should run:
|
||||
|
||||
```bash
|
||||
brew test steipete/tap/gogcli
|
||||
gog --version
|
||||
```
|
||||
|
||||
## GitHub Releases
|
||||
## Docker / GHCR
|
||||
|
||||
Release assets are uploaded by GoReleaser:
|
||||
|
||||
- `gogcli_<version>_darwin_amd64.tar.gz`
|
||||
- `gogcli_<version>_darwin_arm64.tar.gz`
|
||||
- `gogcli_<version>_linux_amd64.tar.gz`
|
||||
- `gogcli_<version>_linux_arm64.tar.gz`
|
||||
- `gogcli_<version>_windows_amd64.zip`
|
||||
- `gogcli_<version>_windows_arm64.zip`
|
||||
- `checksums.txt`
|
||||
|
||||
Windows users download the matching ZIP, extract `gog.exe`, and add the
|
||||
directory to `PATH`.
|
||||
|
||||
## Docker
|
||||
|
||||
Release tags publish a GitHub Container Registry image:
|
||||
Release tags publish a non-root GitHub Container Registry image:
|
||||
|
||||
```bash
|
||||
docker run --rm ghcr.io/steipete/gogcli:latest version
|
||||
docker run --rm ghcr.io/steipete/gogcli:v0.15.0 version
|
||||
```
|
||||
|
||||
Authenticated container runs should mount a persistent config directory and use
|
||||
the encrypted file keyring:
|
||||
Authenticated container runs should mount a persistent config directory and
|
||||
use the encrypted file keyring:
|
||||
|
||||
```bash
|
||||
docker volume create gogcli-config
|
||||
@ -60,10 +41,35 @@ docker run --rm -it \
|
||||
auth add you@gmail.com --services gmail,calendar,drive
|
||||
```
|
||||
|
||||
Keep `GOG_KEYRING_PASSWORD` in the shell session or CI secret store. Do not bake
|
||||
it into images, scripts, or checked-in profiles.
|
||||
Keep `GOG_KEYRING_PASSWORD` in the shell session or your CI secret store. Do
|
||||
not bake it into images, scripts, or checked-in profiles.
|
||||
|
||||
## Source Builds
|
||||
## Windows
|
||||
|
||||
Download the matching ZIP from the
|
||||
[latest release](https://github.com/steipete/gogcli/releases):
|
||||
|
||||
- `gogcli_<version>_windows_amd64.zip`
|
||||
- `gogcli_<version>_windows_arm64.zip`
|
||||
|
||||
Extract `gog.exe` and put its directory on `PATH`.
|
||||
|
||||
## GitHub releases (raw binaries)
|
||||
|
||||
Release assets are uploaded by GoReleaser:
|
||||
|
||||
- `gogcli_<version>_darwin_amd64.tar.gz`
|
||||
- `gogcli_<version>_darwin_arm64.tar.gz`
|
||||
- `gogcli_<version>_linux_amd64.tar.gz`
|
||||
- `gogcli_<version>_linux_arm64.tar.gz`
|
||||
- `gogcli_<version>_windows_amd64.zip`
|
||||
- `gogcli_<version>_windows_arm64.zip`
|
||||
- `checksums.txt`
|
||||
|
||||
Browse the [releases page](https://github.com/steipete/gogcli/releases) for
|
||||
the latest tag and the full asset list.
|
||||
|
||||
## Build from source
|
||||
|
||||
```bash
|
||||
git clone https://github.com/steipete/gogcli.git
|
||||
@ -74,9 +80,45 @@ make
|
||||
|
||||
Source builds require the Go version declared in `go.mod`.
|
||||
|
||||
## Related Command Pages
|
||||
## Safety-profile binaries
|
||||
|
||||
When `gog` is going to be invoked by an agent, sandbox, or other caller that
|
||||
should not be able to broaden its own permissions, build a safety-profile
|
||||
binary instead of the default one. See [Safety Profiles](safety-profiles.md).
|
||||
|
||||
```bash
|
||||
./build-safe.sh safety-profiles/agent-safe.yaml -o bin/gog-agent-safe
|
||||
./build-safe.sh safety-profiles/readonly.yaml -o bin/gog-readonly
|
||||
```
|
||||
|
||||
## Verify the install
|
||||
|
||||
```bash
|
||||
gog --version
|
||||
gog auth keyring # report current keyring backend
|
||||
gog --help # discover top-level commands
|
||||
```
|
||||
|
||||
After running [`gog auth credentials`](commands/gog-auth-credentials.md) and
|
||||
[`gog auth add`](commands/gog-auth-add.md), `gog auth doctor --check` reports
|
||||
keyring health, refresh-token validity, and Workspace-specific failure modes.
|
||||
|
||||
## Updating
|
||||
|
||||
- **Homebrew:** `brew upgrade gogcli`.
|
||||
- **Docker:** pull a new tag (`ghcr.io/steipete/gogcli:vX.Y.Z`).
|
||||
- **GitHub release archives:** download the new tarball/ZIP and replace the
|
||||
binary.
|
||||
- **Source builds:** `git pull && make` — the version string comes from
|
||||
`git describe`.
|
||||
|
||||
Refresh tokens and OAuth clients are forward-compatible across point releases;
|
||||
no migration step is required for normal upgrades.
|
||||
|
||||
## Related command pages
|
||||
|
||||
- [`gog version`](commands/gog-version.md)
|
||||
- [`gog auth keyring`](commands/gog-auth-keyring.md)
|
||||
- [`gog auth credentials`](commands/gog-auth-credentials.md)
|
||||
- [`gog auth add`](commands/gog-auth-add.md)
|
||||
- [`gog auth doctor`](commands/gog-auth-doctor.md)
|
||||
|
||||
131
docs/quickstart.md
Normal file
131
docs/quickstart.md
Normal file
@ -0,0 +1,131 @@
|
||||
---
|
||||
title: Quickstart
|
||||
description: "Five minutes from a clean machine to a working gog setup with one Google account."
|
||||
---
|
||||
|
||||
# Quickstart
|
||||
|
||||
Five minutes from a clean machine to authenticated Gmail, Calendar, and Drive
|
||||
queries. For a deeper look at OAuth clients, service accounts, and named
|
||||
profiles, read [Auth Clients](auth-clients.md) after this.
|
||||
|
||||
## 1. Install
|
||||
|
||||
```bash
|
||||
brew install gogcli
|
||||
gog --version
|
||||
```
|
||||
|
||||
Other options (Docker, Windows ZIPs, source builds) are documented on
|
||||
[Install](install.md).
|
||||
|
||||
## 2. Get an OAuth client
|
||||
|
||||
`gog` talks to Google APIs as you, using your own Cloud project. The one-time
|
||||
setup is:
|
||||
|
||||
1. Open <https://console.cloud.google.com/projectcreate> and create a project.
|
||||
2. Enable the APIs you intend to use: Gmail, Calendar, Drive, Docs, Sheets,
|
||||
Slides, Forms, Apps Script, People (Contacts), Tasks, Classroom — whatever
|
||||
you actually need. The [API library](https://console.cloud.google.com/apis/library)
|
||||
is the fastest way to enable several at once.
|
||||
3. Configure the [OAuth consent screen](https://console.cloud.google.com/auth/branding)
|
||||
for "External" + your email; that is enough for personal use.
|
||||
4. Create a **Desktop app** OAuth client at
|
||||
<https://console.cloud.google.com/auth/clients> and download the JSON.
|
||||
|
||||
Personal `gmail.com` accounts work for normal user APIs (Gmail, Calendar,
|
||||
Drive, Docs, Sheets, Slides, Forms, Apps Script, Contacts/People, Tasks,
|
||||
Classroom). Workspace-only APIs (Admin Directory, Cloud Identity Groups, Chat,
|
||||
Keep with domain-wide delegation) require a managed domain — see
|
||||
[Auth Clients](auth-clients.md).
|
||||
|
||||
> External + Testing OAuth apps issue refresh tokens that expire after seven
|
||||
> days. Publish the OAuth app for long-lived tokens, or be ready to re-run
|
||||
> `gog auth add` weekly.
|
||||
|
||||
## 3. Store the OAuth client
|
||||
|
||||
```bash
|
||||
gog auth credentials ~/Downloads/client_secret_*.json
|
||||
```
|
||||
|
||||
The file is copied to your per-user config (`$XDG_CONFIG_HOME/gogcli/` or the
|
||||
OS-equivalent) with mode `0600`.
|
||||
|
||||
## 4. Authorize an account
|
||||
|
||||
```bash
|
||||
gog auth add you@gmail.com --services gmail,calendar,drive,docs,sheets,contacts
|
||||
```
|
||||
|
||||
A browser tab opens, you grant the requested scopes, and `gog` stores a
|
||||
refresh token in your OS keyring (Keychain on macOS, Secret Service on Linux,
|
||||
Credential Manager on Windows). Headless? Add `--manual` for a paste-the-URL
|
||||
flow, or `--remote --step 1`/`--step 2` for fully split server runs.
|
||||
|
||||
Verify:
|
||||
|
||||
```bash
|
||||
gog auth list --check
|
||||
gog auth doctor --check
|
||||
```
|
||||
|
||||
## 5. Set a default account
|
||||
|
||||
```bash
|
||||
export GOG_ACCOUNT=you@gmail.com
|
||||
# or persist a default with gog auth alias
|
||||
gog auth alias set default you@gmail.com
|
||||
```
|
||||
|
||||
Now you can drop `--account` from every command.
|
||||
|
||||
## 6. Run real commands
|
||||
|
||||
```bash
|
||||
# Gmail
|
||||
gog gmail search 'newer_than:7d' --max 10
|
||||
gog gmail get <messageId> --sanitize-content --json
|
||||
|
||||
# Calendar
|
||||
gog calendar events --today
|
||||
gog calendar create --summary "Review" \
|
||||
--from "2026-05-06T10:00:00+02:00" \
|
||||
--to "2026-05-06T10:30:00+02:00"
|
||||
|
||||
# Drive
|
||||
gog drive ls --max 20
|
||||
gog drive tree --parent <folderId> --depth 2
|
||||
gog drive du --parent <folderId> --max 20 --json
|
||||
|
||||
# Docs / Sheets / Slides
|
||||
gog docs cat <docId> --tab "Notes"
|
||||
gog sheets get <spreadsheetId> 'Sheet1!A1:D20' --json
|
||||
gog slides create-from-markdown "Weekly update" --content-file slides.md
|
||||
|
||||
# Profile
|
||||
gog me
|
||||
```
|
||||
|
||||
`--json` produces a stable JSON envelope on stdout; `--plain` produces TSV.
|
||||
Human-facing progress, hints, and warnings always go to stderr, so pipes stay
|
||||
parseable.
|
||||
|
||||
## 7. Shell completion (optional)
|
||||
|
||||
```bash
|
||||
gog completion bash >> ~/.bash_completion
|
||||
gog completion zsh > "${fpath[1]}/_gog"
|
||||
gog completion fish > ~/.config/fish/completions/gog.fish
|
||||
```
|
||||
|
||||
## Where next
|
||||
|
||||
- [Auth Clients](auth-clients.md) — named clients, service accounts, ADC,
|
||||
Workspace domain-wide delegation, OIDC subject migration.
|
||||
- [Safety Profiles](safety-profiles.md) — runtime allow/deny lists and baked
|
||||
agent-safe binaries.
|
||||
- [Gmail Workflows](gmail-workflows.md) and [Drive Audits](drive-audits.md) for
|
||||
the two surfaces most people start automating.
|
||||
- [Command Index](commands/) — generated reference for every subcommand.
|
||||
@ -2,72 +2,125 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
import { css, faviconSvg, js } from "./docs-site-assets.mjs";
|
||||
|
||||
const root = process.cwd();
|
||||
const docsDir = path.join(root, "docs");
|
||||
const outDir = path.join(root, "dist", "docs-site");
|
||||
const repoEditBase = "https://github.com/steipete/gogcli/edit/main/docs";
|
||||
const repoBase = "https://github.com/steipete/gogcli";
|
||||
const repoEditBase = `${repoBase}/edit/main/docs`;
|
||||
const cname = readCname();
|
||||
const siteBase = cname ? `https://${cname}` : "";
|
||||
|
||||
const productName = "gog";
|
||||
const productTagline = "Google Workspace in your terminal";
|
||||
const productDescription =
|
||||
"A single Go CLI for Gmail, Calendar, Drive, Docs, Sheets, Slides, Forms, Apps Script, Contacts, Tasks, and Workspace admin — built for terminals, scripts, CI, and coding agents.";
|
||||
const brewInstall = "brew install gogcli";
|
||||
|
||||
const sections = [
|
||||
["Start", ["README.md", "install.md", "auth-clients.md", "spec.md", "dates.md"]],
|
||||
["Commands", rels("commands")],
|
||||
["Start", ["index.md", "install.md", "quickstart.md", "auth-clients.md", "safety-profiles.md"]],
|
||||
["Gmail", ["gmail-workflows.md", "gmail-autoreply.md", "watch.md", "email-tracking.md", "email-tracking-worker.md"]],
|
||||
["Workspace", ["raw-api.md", "raw-audit.md", "drive-audits.md", "contacts-dedupe.md", "contacts-json-update.md", "docs-editing.md", "sheets-tables.md", "sheets-formatting.md", "slides-markdown.md", "slides-template-replacement.md", "backup.md", "sedmat.md"]],
|
||||
["Safety", ["safety-profiles.md", "RELEASING.md"]],
|
||||
["Drive & Files", ["drive-audits.md", "raw-api.md", "raw-audit.md"]],
|
||||
["Docs, Sheets, Slides", ["docs-editing.md", "sedmat.md", "sheets-tables.md", "sheets-formatting.md", "slides-markdown.md", "slides-template-replacement.md"]],
|
||||
["Contacts", ["contacts-dedupe.md", "contacts-json-update.md"]],
|
||||
["Backup", ["backup.md"]],
|
||||
["Reference", ["dates.md", "spec.md", "RELEASING.md", "commands/README.md"]],
|
||||
];
|
||||
|
||||
// Skip these from page generation (internal notes, generated subpages we don't want as their own
|
||||
// nav-less HTML files, etc.). Generated `commands/*.md` ARE built (deep-linkable) but only the
|
||||
// commands index appears in the sidebar.
|
||||
const buildExcludes = [/^refactor\//, /^commands\.generated\.md$/];
|
||||
|
||||
fs.rmSync(outDir, { recursive: true, force: true });
|
||||
fs.mkdirSync(outDir, { recursive: true });
|
||||
|
||||
const pages = allMarkdown(docsDir).map((file) => {
|
||||
const allPages = allMarkdown(docsDir).map((file) => {
|
||||
const rel = path.relative(docsDir, file).replaceAll(path.sep, "/");
|
||||
const markdown = fs.readFileSync(file, "utf8");
|
||||
const title = firstHeading(markdown) || titleize(path.basename(rel, ".md"));
|
||||
return { file, rel, title, outRel: outPath(rel), markdown };
|
||||
const raw = fs.readFileSync(file, "utf8");
|
||||
const { frontmatter, body } = parseFrontmatter(raw);
|
||||
const cleaned = stripStrayDirectives(body);
|
||||
const title = frontmatter.title || firstHeading(cleaned) || titleize(path.basename(rel, ".md"));
|
||||
return { file, rel, title, outRel: outPath(rel, frontmatter), markdown: cleaned, frontmatter };
|
||||
});
|
||||
|
||||
const pages = allPages.filter((page) => !buildExcludes.some((re) => re.test(page.rel)));
|
||||
const pageMap = new Map(pages.map((page) => [page.rel, page]));
|
||||
const nav = sections
|
||||
.map(([name, relList]) => ({
|
||||
name,
|
||||
pages: relList.map((rel) => pageMap.get(rel)).filter(Boolean),
|
||||
}))
|
||||
.filter((section) => section.pages.length > 0);
|
||||
const orderedPages = nav.flatMap((section) => section.pages);
|
||||
const sectionByRel = new Map();
|
||||
for (const section of nav) {
|
||||
for (const page of section.pages) sectionByRel.set(page.rel, section.name);
|
||||
const permalinkMap = new Map();
|
||||
for (const page of pages) {
|
||||
if (page.frontmatter.permalink) {
|
||||
permalinkMap.set(normalizePermalink(page.frontmatter.permalink), page);
|
||||
}
|
||||
}
|
||||
|
||||
const nav = sections
|
||||
.map(([name, rels]) => ({
|
||||
name,
|
||||
pages: rels.map((rel) => pageMap.get(rel)).filter(Boolean),
|
||||
}))
|
||||
.filter((section) => section.pages.length);
|
||||
|
||||
const sectionByRel = new Map();
|
||||
for (const section of nav) for (const page of section.pages) sectionByRel.set(page.rel, section.name);
|
||||
const orderedPages = nav.flatMap((s) => s.pages);
|
||||
|
||||
for (const page of pages) {
|
||||
const html = markdownToHtml(page.markdown, page.rel);
|
||||
const toc = tocFromHtml(html);
|
||||
const idx = orderedPages.findIndex((candidate) => candidate.rel === page.rel);
|
||||
const idx = orderedPages.findIndex((p) => p.rel === page.rel);
|
||||
const prev = idx > 0 ? orderedPages[idx - 1] : null;
|
||||
const next = idx >= 0 && idx < orderedPages.length - 1 ? orderedPages[idx + 1] : null;
|
||||
const sectionName = sectionByRel.get(page.rel) || "Reference";
|
||||
const pageOut = path.join(outDir, page.outRel);
|
||||
fs.mkdirSync(path.dirname(pageOut), { recursive: true });
|
||||
fs.writeFileSync(
|
||||
pageOut,
|
||||
layout({ page, html, toc, prev, next, sectionName: sectionByRel.get(page.rel) || "Docs" }),
|
||||
"utf8",
|
||||
);
|
||||
fs.writeFileSync(pageOut, layout({ page, html, toc, prev, next, sectionName }), "utf8");
|
||||
}
|
||||
|
||||
for (const name of ["CNAME"]) {
|
||||
const src = path.join(docsDir, name);
|
||||
if (fs.existsSync(src)) fs.copyFileSync(src, path.join(outDir, name));
|
||||
}
|
||||
fs.writeFileSync(path.join(outDir, "favicon.svg"), faviconSvg(), "utf8");
|
||||
fs.writeFileSync(path.join(outDir, ".nojekyll"), "", "utf8");
|
||||
if (cname) fs.writeFileSync(path.join(outDir, "CNAME"), cname, "utf8");
|
||||
validateLinks(outDir);
|
||||
console.log(`built docs site: ${path.relative(root, outDir)}`);
|
||||
|
||||
function rels(dir) {
|
||||
const full = path.join(docsDir, dir);
|
||||
if (!fs.existsSync(full)) return [];
|
||||
return fs
|
||||
.readdirSync(full)
|
||||
.filter((name) => name.endsWith(".md"))
|
||||
.sort((a, b) => (a === "README.md" ? -1 : b === "README.md" ? 1 : a.localeCompare(b)))
|
||||
.map((name) => `${dir}/${name}`);
|
||||
function readCname() {
|
||||
for (const candidate of [path.join(docsDir, "CNAME"), path.join(root, "CNAME")]) {
|
||||
if (fs.existsSync(candidate)) return fs.readFileSync(candidate, "utf8").trim();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function parseFrontmatter(raw) {
|
||||
const match = raw.match(/^---\n([\s\S]*?)\n---\n?/);
|
||||
if (!match) return { frontmatter: {}, body: raw };
|
||||
const fm = {};
|
||||
for (const line of match[1].split("\n")) {
|
||||
const m = line.match(/^([A-Za-z0-9_-]+):\s*(.*?)\s*$/);
|
||||
if (!m) continue;
|
||||
let value = m[2];
|
||||
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
||||
value = value.slice(1, -1);
|
||||
}
|
||||
fm[m[1]] = value;
|
||||
}
|
||||
return { frontmatter: fm, body: raw.slice(match[0].length) };
|
||||
}
|
||||
|
||||
function stripStrayDirectives(body) {
|
||||
return body
|
||||
.replace(/\r\n/g, "\n")
|
||||
.split("\n")
|
||||
.filter((line) => !/^\s*\{:\s*[^}]*\}\s*$/.test(line))
|
||||
.map((line) => line.replace(/\s*\{:\s*[^}]*\}\s*$/, ""))
|
||||
.join("\n");
|
||||
}
|
||||
|
||||
function normalizePermalink(value) {
|
||||
let v = value.trim();
|
||||
if (!v) return "/";
|
||||
if (!v.startsWith("/")) v = `/${v}`;
|
||||
if (v.length > 1 && v.endsWith("/")) v = v.slice(0, -1);
|
||||
return v;
|
||||
}
|
||||
|
||||
function allMarkdown(dir) {
|
||||
@ -81,7 +134,13 @@ function allMarkdown(dir) {
|
||||
.sort();
|
||||
}
|
||||
|
||||
function outPath(rel) {
|
||||
function outPath(rel, frontmatter = {}) {
|
||||
if (frontmatter.permalink) {
|
||||
const permalink = normalizePermalink(frontmatter.permalink);
|
||||
if (permalink === "/") return "index.html";
|
||||
return `${permalink.slice(1)}/index.html`;
|
||||
}
|
||||
if (rel === "index.md") return "index.html";
|
||||
if (rel === "README.md") return "index.html";
|
||||
if (rel.endsWith("/README.md")) return rel.replace(/README\.md$/, "index.html");
|
||||
return rel.replace(/\.md$/, ".html");
|
||||
@ -101,6 +160,7 @@ function markdownToHtml(markdown, currentRel) {
|
||||
let paragraph = [];
|
||||
let list = null;
|
||||
let fence = null;
|
||||
let blockquote = [];
|
||||
|
||||
const flushParagraph = () => {
|
||||
if (!paragraph.length) return;
|
||||
@ -112,30 +172,33 @@ function markdownToHtml(markdown, currentRel) {
|
||||
html.push(`</${list}>`);
|
||||
list = null;
|
||||
};
|
||||
const flushBlockquote = () => {
|
||||
if (!blockquote.length) return;
|
||||
const inner = markdownToHtml(blockquote.join("\n"), currentRel);
|
||||
html.push(`<blockquote>${inner}</blockquote>`);
|
||||
blockquote = [];
|
||||
};
|
||||
const splitRow = (line) => {
|
||||
const trimmed = line.replace(/^\s*\|/, "").replace(/\|\s*$/, "");
|
||||
let trimmed = line.trim();
|
||||
if (trimmed.startsWith("|")) trimmed = trimmed.slice(1);
|
||||
if (trimmed.endsWith("|") && !trimmed.endsWith("\\|")) trimmed = trimmed.slice(0, -1);
|
||||
const cells = [];
|
||||
let cell = "";
|
||||
let escaped = false;
|
||||
for (const ch of trimmed) {
|
||||
if (escaped) {
|
||||
cell += ch;
|
||||
escaped = false;
|
||||
let current = "";
|
||||
for (let idx = 0; idx < trimmed.length; idx++) {
|
||||
const char = trimmed[idx];
|
||||
if (char === "\\" && trimmed[idx + 1] === "|") {
|
||||
current += "\\|";
|
||||
idx += 1;
|
||||
continue;
|
||||
}
|
||||
if (ch === "\\") {
|
||||
escaped = true;
|
||||
cell += ch;
|
||||
if (char === "|") {
|
||||
cells.push(current.trim().replace(/\\\|/g, "|"));
|
||||
current = "";
|
||||
continue;
|
||||
}
|
||||
if (ch === "|") {
|
||||
cells.push(cell.trim());
|
||||
cell = "";
|
||||
continue;
|
||||
}
|
||||
cell += ch;
|
||||
current += char;
|
||||
}
|
||||
cells.push(cell.trim());
|
||||
cells.push(current.trim().replace(/\\\|/g, "|"));
|
||||
return cells;
|
||||
};
|
||||
const isDivider = (line) => /^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)+\|?\s*$/.test(line);
|
||||
@ -146,6 +209,7 @@ function markdownToHtml(markdown, currentRel) {
|
||||
if (fenceMatch) {
|
||||
flushParagraph();
|
||||
closeList();
|
||||
flushBlockquote();
|
||||
if (fence) {
|
||||
html.push(`<pre><code class="language-${escapeAttr(fence.lang)}">${escapeHtml(fence.lines.join("\n"))}</code></pre>`);
|
||||
fence = null;
|
||||
@ -158,11 +222,24 @@ function markdownToHtml(markdown, currentRel) {
|
||||
fence.lines.push(line);
|
||||
continue;
|
||||
}
|
||||
if (/^>\s?/.test(line)) {
|
||||
flushParagraph();
|
||||
closeList();
|
||||
blockquote.push(line.replace(/^>\s?/, ""));
|
||||
continue;
|
||||
}
|
||||
flushBlockquote();
|
||||
if (!line.trim()) {
|
||||
flushParagraph();
|
||||
closeList();
|
||||
continue;
|
||||
}
|
||||
if (/^\s*---+\s*$/.test(line)) {
|
||||
flushParagraph();
|
||||
closeList();
|
||||
html.push("<hr>");
|
||||
continue;
|
||||
}
|
||||
const heading = line.match(/^(#{1,4})\s+(.+)$/);
|
||||
if (heading) {
|
||||
flushParagraph();
|
||||
@ -171,36 +248,35 @@ function markdownToHtml(markdown, currentRel) {
|
||||
const text = heading[2].trim();
|
||||
const id = slug(text);
|
||||
const inner = inline(text, currentRel);
|
||||
const anchor = level === 1 ? "" : `<a class="anchor" href="#${id}" aria-label="Anchor link">#</a>`;
|
||||
html.push(`<h${level} id="${id}">${anchor}${inner}</h${level}>`);
|
||||
if (level === 1) {
|
||||
html.push(`<h1 id="${id}">${inner}</h1>`);
|
||||
} else {
|
||||
html.push(`<h${level} id="${id}"><a class="anchor" href="#${id}" aria-label="Anchor link">#</a>${inner}</h${level}>`);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (line.trimStart().startsWith("|") && line.includes("|", line.indexOf("|") + 1) && isDivider(lines[i + 1] || "")) {
|
||||
flushParagraph();
|
||||
closeList();
|
||||
const header = splitRow(line);
|
||||
const aligns = splitRow(lines[i + 1]).map((cell) => {
|
||||
const left = cell.startsWith(":");
|
||||
const right = cell.endsWith(":");
|
||||
return right && left ? "center" : right ? "right" : left ? "left" : "";
|
||||
});
|
||||
i += 1;
|
||||
const rows = [];
|
||||
while (i + 1 < lines.length && lines[i + 1].trimStart().startsWith("|")) {
|
||||
i += 1;
|
||||
rows.push(splitRow(lines[i]));
|
||||
}
|
||||
const th = header.map((cell) => `<th>${inline(cell, currentRel)}</th>`).join("");
|
||||
const tb = rows
|
||||
.map((row) => `<tr>${row.map((cell) => `<td>${inline(cell, currentRel)}</td>`).join("")}</tr>`)
|
||||
.join("");
|
||||
const th = header.map((c, idx) => `<th${aligns[idx] ? ` style="text-align:${aligns[idx]}"` : ""}>${inline(c, currentRel)}</th>`).join("");
|
||||
const tb = rows.map((r) => `<tr>${r.map((c, idx) => `<td${aligns[idx] ? ` style="text-align:${aligns[idx]}"` : ""}>${inline(c, currentRel)}</td>`).join("")}</tr>`).join("");
|
||||
html.push(`<table><thead><tr>${th}</tr></thead><tbody>${tb}</tbody></table>`);
|
||||
continue;
|
||||
}
|
||||
const bullet = line.match(/^\s*-\s+(.+)$/);
|
||||
const numbered = line.match(/^\s*\d+\.\s+(.+)$/);
|
||||
const quote = line.match(/^>\s+(.+)$/);
|
||||
if (quote) {
|
||||
flushParagraph();
|
||||
closeList();
|
||||
html.push(`<blockquote>${inline(quote[1], currentRel)}</blockquote>`);
|
||||
continue;
|
||||
}
|
||||
if (bullet || numbered) {
|
||||
flushParagraph();
|
||||
const tag = bullet ? "ul" : "ol";
|
||||
@ -216,6 +292,7 @@ function markdownToHtml(markdown, currentRel) {
|
||||
}
|
||||
flushParagraph();
|
||||
closeList();
|
||||
flushBlockquote();
|
||||
return html.join("\n");
|
||||
}
|
||||
|
||||
@ -227,79 +304,155 @@ function inline(text, currentRel) {
|
||||
});
|
||||
out = escapeHtml(out)
|
||||
.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>")
|
||||
.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_, label, href) => `<a href="${escapeAttr(rewriteHref(href, currentRel))}">${label}</a>`);
|
||||
.replace(/(^|[^*])\*([^*\s][^*]*?)\*(?!\*)/g, "$1<em>$2</em>")
|
||||
.replace(/(^|[^_])_([^_\s][^_]*?)_(?!_)/g, "$1<em>$2</em>")
|
||||
.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_, label, href) => `<a href="${escapeAttr(rewriteHref(href, currentRel))}">${label}</a>`)
|
||||
.replace(/<(https?:\/\/[^\s<>]+)>/g, '<a href="$1">$1</a>');
|
||||
out = out.replace(/\\\|/g, "|");
|
||||
out = out.replace(/<br>/g, "<br>");
|
||||
return out.replace(/\u0000(\d+)\u0000/g, (_, index) => stash[Number(index)]);
|
||||
return out.replace(/\u0000(\d+)\u0000/g, (_, i) => stash[Number(i)]);
|
||||
}
|
||||
|
||||
function rewriteHref(href, currentRel) {
|
||||
if (/^(https?:|mailto:|#)/.test(href)) return href;
|
||||
if (/^(https?:|mailto:|tel:|#)/.test(href)) return href;
|
||||
const [raw, hash = ""] = href.split("#");
|
||||
if (!raw) return `#${hash}`;
|
||||
if (!raw) return hash ? `#${hash}` : "";
|
||||
if (raw.startsWith("/")) {
|
||||
const target = permalinkMap.get(normalizePermalink(raw));
|
||||
if (target) {
|
||||
const currentOut = pageMap.get(currentRel)?.outRel || outPath(currentRel);
|
||||
const out = hrefToOutRel(target.outRel, currentOut);
|
||||
return hash ? `${out}#${hash}` : out;
|
||||
}
|
||||
return href;
|
||||
}
|
||||
if (!raw.endsWith(".md")) return href;
|
||||
const target = path.posix.normalize(path.posix.join(path.posix.dirname(currentRel), raw));
|
||||
const rewritten = path.posix.relative(path.posix.dirname(outPath(currentRel)), outPath(target)) || "index.html";
|
||||
const from = path.posix.dirname(currentRel);
|
||||
const target = path.posix.normalize(path.posix.join(from, raw));
|
||||
let rewritten = pageMap.get(target)?.outRel || outPath(target);
|
||||
const currentOut = pageMap.get(currentRel)?.outRel || outPath(currentRel);
|
||||
rewritten = hrefToOutRel(rewritten, currentOut);
|
||||
return `${rewritten}${hash ? `#${hash}` : ""}`;
|
||||
}
|
||||
|
||||
function tocFromHtml(html) {
|
||||
const items = [];
|
||||
const re = /<h([23]) id="([^"]+)">([\s\S]*?)<\/h[23]>/g;
|
||||
let match;
|
||||
while ((match = re.exec(html))) {
|
||||
const text = match[3]
|
||||
let m;
|
||||
while ((m = re.exec(html))) {
|
||||
const text = m[3]
|
||||
.replace(/<a class="anchor"[^>]*>.*?<\/a>/, "")
|
||||
.replace(/<[^>]+>/g, "")
|
||||
.trim();
|
||||
items.push({ level: Number(match[1]), id: match[2], text });
|
||||
items.push({ level: Number(m[1]), id: m[2], text });
|
||||
}
|
||||
if (items.length < 2) return "";
|
||||
return `<nav class="toc" aria-label="On this page"><h2>On This Page</h2>${items
|
||||
.map((item) => `<a class="toc-l${item.level}" href="#${item.id}">${escapeHtml(item.text)}</a>`)
|
||||
return `<nav class="toc" aria-label="On this page"><h2>On this page</h2>${items
|
||||
.map((i) => `<a class="toc-l${i.level}" href="#${i.id}">${escapeHtml(i.text)}</a>`)
|
||||
.join("")}</nav>`;
|
||||
}
|
||||
|
||||
function isHomePage(page) {
|
||||
if (page.frontmatter.permalink && normalizePermalink(page.frontmatter.permalink) === "/") return true;
|
||||
return page.rel === "index.md" || page.rel === "README.md";
|
||||
}
|
||||
|
||||
function homeHero(page) {
|
||||
const description = page.frontmatter.description || productDescription;
|
||||
const installRel = pageMap.get("install.md")?.outRel
|
||||
? hrefToOutRel(pageMap.get("install.md").outRel, page.outRel)
|
||||
: "install.html";
|
||||
const quickstartRel = pageMap.get("quickstart.md")?.outRel
|
||||
? hrefToOutRel(pageMap.get("quickstart.md").outRel, page.outRel)
|
||||
: "quickstart.html";
|
||||
const services = ["Gmail", "Calendar", "Drive", "Docs", "Sheets", "Slides", "Forms", "Contacts", "Tasks", "Apps Script", "Admin"];
|
||||
return `<header class="home-hero">
|
||||
<p class="eyebrow">Google Workspace · One CLI</p>
|
||||
<h1>${escapeHtml(productTagline)}</h1>
|
||||
<p class="lede">${escapeHtml(description)}</p>
|
||||
<div class="home-cta">
|
||||
<a class="btn btn-primary" href="${quickstartRel}">Quickstart</a>
|
||||
<a class="btn btn-ghost" href="${repoBase}" rel="noopener">GitHub</a>
|
||||
<div class="home-install" aria-label="Install with Homebrew">
|
||||
<span class="prompt" aria-hidden="true">$</span>
|
||||
<code>${escapeHtml(brewInstall)}</code>
|
||||
</div>
|
||||
</div>
|
||||
<div class="home-services" aria-label="Supported services">
|
||||
${services.map((s) => `<span>${escapeHtml(s)}</span>`).join("")}
|
||||
</div>
|
||||
<p class="muted"><a href="${installRel}">Other install options →</a></p>
|
||||
</header>`;
|
||||
}
|
||||
|
||||
function standardHero(page, sectionName, editUrl) {
|
||||
return `<header class="hero">
|
||||
<div class="hero-text">
|
||||
<p class="eyebrow">${escapeHtml(sectionName)}</p>
|
||||
<h1>${escapeHtml(page.title)}</h1>
|
||||
</div>
|
||||
<div class="hero-meta">
|
||||
<a class="repo" href="${repoBase}" rel="noopener">GitHub</a>
|
||||
<a class="edit" href="${escapeAttr(editUrl)}" rel="noopener">Edit page</a>
|
||||
</div>
|
||||
</header>`;
|
||||
}
|
||||
|
||||
function layout({ page, html, toc, prev, next, sectionName }) {
|
||||
const depth = page.outRel.split("/").length - 1;
|
||||
const rootPrefix = depth ? "../".repeat(depth) : "";
|
||||
const editUrl = `${repoEditBase}/${page.rel}`;
|
||||
const home = isHomePage(page);
|
||||
const prevNext = !home && (prev || next) ? pageNavHtml(prev, next, page.outRel) : "";
|
||||
const heroBlock = home ? homeHero(page) : standardHero(page, sectionName, editUrl);
|
||||
const articleClass = home ? "doc doc-home" : "doc";
|
||||
const tocBlock = home ? "" : toc;
|
||||
const titleSuffix = home ? `${productName} — ${productTagline}` : `${page.title} — ${productName}`;
|
||||
const description = page.frontmatter.description || (home ? productDescription : `${page.title} — ${productName} CLI documentation.`);
|
||||
const canonicalUrl = pageCanonicalUrl(page);
|
||||
const socialMeta = [
|
||||
["link", "rel", "canonical", "href", canonicalUrl],
|
||||
["meta", "property", "og:type", "content", "website"],
|
||||
["meta", "property", "og:site_name", "content", productName],
|
||||
["meta", "property", "og:title", "content", titleSuffix],
|
||||
["meta", "property", "og:description", "content", description],
|
||||
["meta", "property", "og:url", "content", canonicalUrl],
|
||||
["meta", "name", "twitter:card", "content", "summary_large_image"],
|
||||
["meta", "name", "twitter:title", "content", titleSuffix],
|
||||
["meta", "name", "twitter:description", "content", description],
|
||||
].map(tagHtml).join("\n ");
|
||||
return `<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>${escapeHtml(page.title)} - gog docs</title>
|
||||
<meta name="description" content="gog CLI documentation for Google Workspace automation.">
|
||||
<title>${escapeHtml(titleSuffix)}</title>
|
||||
<meta name="description" content="${escapeAttr(description)}">
|
||||
${socialMeta}
|
||||
<link rel="icon" href="${rootPrefix}favicon.svg" type="image/svg+xml">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
||||
<style>${css()}</style>
|
||||
</head>
|
||||
<body>
|
||||
<body${home ? ' class="home"' : ""}>
|
||||
<button class="nav-toggle" type="button" aria-label="Toggle navigation" aria-expanded="false">
|
||||
<span></span><span></span><span></span>
|
||||
<span aria-hidden="true"></span><span aria-hidden="true"></span><span aria-hidden="true"></span>
|
||||
</button>
|
||||
<div class="shell">
|
||||
<aside class="sidebar">
|
||||
<a class="brand" href="${rootPrefix}index.html" aria-label="gog docs home">
|
||||
<a class="brand" href="${hrefToOutRel("index.html", page.outRel)}" aria-label="${productName} docs home">
|
||||
<span class="mark" aria-hidden="true"><i></i><i></i><i></i><i></i></span>
|
||||
<span><strong>gog</strong><small>Google CLI docs</small></span>
|
||||
<span><strong>${escapeHtml(productName)}</strong><small>Google CLI docs</small></span>
|
||||
</a>
|
||||
<label class="search"><span>Search</span><input id="doc-search" type="search" placeholder="gmail get, auth, sheets"></label>
|
||||
<nav>${navHtml(page.rel, rootPrefix)}</nav>
|
||||
<label class="search"><span>Search</span><input id="doc-search" type="search" placeholder="gmail, calendar, sheets"></label>
|
||||
<nav>${navHtml(page)}</nav>
|
||||
</aside>
|
||||
<main>
|
||||
<header class="hero">
|
||||
<div>
|
||||
<p class="eyebrow">${escapeHtml(sectionName)}</p>
|
||||
<h1>${escapeHtml(page.title)}</h1>
|
||||
</div>
|
||||
<div class="hero-links">
|
||||
<a href="https://github.com/steipete/gogcli" rel="noopener">GitHub</a>
|
||||
<a href="${escapeAttr(editUrl)}" rel="noopener">Edit</a>
|
||||
</div>
|
||||
</header>
|
||||
<div class="doc-grid">
|
||||
<article class="doc">${html}${pageNavHtml(prev, next, rootPrefix)}</article>
|
||||
${toc}
|
||||
${heroBlock}
|
||||
<div class="doc-grid${home ? " doc-grid-home" : ""}">
|
||||
<article class="${articleClass}">${html}${prevNext}</article>
|
||||
${tocBlock}
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
@ -308,274 +461,109 @@ function layout({ page, html, toc, prev, next, sectionName }) {
|
||||
</html>`;
|
||||
}
|
||||
|
||||
function navHtml(currentRel, rootPrefix) {
|
||||
function pageCanonicalUrl(page) {
|
||||
if (!siteBase) return page.outRel;
|
||||
if (page.outRel === "index.html") return `${siteBase}/`;
|
||||
const rel = page.outRel.endsWith("/index.html") ? page.outRel.slice(0, -"index.html".length) : page.outRel;
|
||||
return `${siteBase}/${rel}`;
|
||||
}
|
||||
|
||||
function tagHtml([tag, k1, v1, k2, v2]) {
|
||||
return tag === "link" ? `<link ${k1}="${v1}" ${k2}="${escapeAttr(v2)}">` : `<meta ${k1}="${v1}" ${k2}="${escapeAttr(v2)}">`;
|
||||
}
|
||||
|
||||
function pageNavHtml(prev, next, currentOutRel) {
|
||||
const cell = (page, dir) => {
|
||||
if (!page) return "";
|
||||
return `<a class="page-nav-${dir}" href="${hrefToOutRel(page.outRel, currentOutRel)}"><small>${dir === "prev" ? "Previous" : "Next"}</small><span>${escapeHtml(page.title)}</span></a>`;
|
||||
};
|
||||
return `<nav class="page-nav" aria-label="Pager">${cell(prev, "prev")}${cell(next, "next")}</nav>`;
|
||||
}
|
||||
|
||||
function navHtml(currentPage) {
|
||||
return nav
|
||||
.map((section) => {
|
||||
const pages = section.pages
|
||||
.map((page) => {
|
||||
const href = rootPrefix + page.outRel;
|
||||
const active = page.rel === currentRel ? " aria-current=\"page\"" : "";
|
||||
return `<a${active} data-title="${escapeAttr(page.title.toLowerCase())}" href="${href}">${escapeHtml(shortTitle(page))}</a>`;
|
||||
})
|
||||
.join("");
|
||||
return `<section><h2>${escapeHtml(section.name)}</h2>${pages}</section>`;
|
||||
})
|
||||
.map((section) => `<section><h2>${escapeHtml(section.name)}</h2>${section.pages.map((page) => {
|
||||
const href = hrefToOutRel(page.outRel, currentPage.outRel);
|
||||
const active = page.rel === currentPage.rel ? " active" : "";
|
||||
return `<a class="nav-link${active}" href="${href}">${escapeHtml(navTitle(page))}</a>`;
|
||||
}).join("")}</section>`)
|
||||
.join("");
|
||||
}
|
||||
|
||||
function shortTitle(page) {
|
||||
if (page.rel === "README.md") return "Overview";
|
||||
function navTitle(page) {
|
||||
if (page.rel === "index.md") return "Overview";
|
||||
if (page.rel === "commands/README.md") return "Command Index";
|
||||
return page.title.replace(/^`gog\s*/, "").replace(/`$/, "");
|
||||
}
|
||||
|
||||
function pageNavHtml(prev, next, rootPrefix) {
|
||||
if (!prev && !next) return "";
|
||||
return `<nav class="page-nav">${prev ? `<a href="${rootPrefix + prev.outRel}">Previous<br><strong>${escapeHtml(prev.title)}</strong></a>` : "<span></span>"}${next ? `<a href="${rootPrefix + next.outRel}">Next<br><strong>${escapeHtml(next.title)}</strong></a>` : "<span></span>"}</nav>`;
|
||||
function hrefToOutRel(targetOutRel, currentOutRel) {
|
||||
const currentDir = path.posix.dirname(currentOutRel);
|
||||
if (targetOutRel.endsWith("/index.html")) {
|
||||
const targetDir = targetOutRel.slice(0, -"index.html".length);
|
||||
const rel = path.posix.relative(currentDir, targetDir || ".") || ".";
|
||||
return rel.endsWith("/") ? rel : `${rel}/`;
|
||||
}
|
||||
if (targetOutRel === "index.html") {
|
||||
const rel = path.posix.relative(currentDir, ".") || ".";
|
||||
return rel.endsWith("/") ? rel : `${rel}/`;
|
||||
}
|
||||
return path.posix.relative(currentDir, targetOutRel) || path.posix.basename(targetOutRel);
|
||||
}
|
||||
|
||||
function slug(text) {
|
||||
return text
|
||||
.toLowerCase()
|
||||
.replace(/<[^>]+>/g, "")
|
||||
.replace(/`/g, "")
|
||||
.replace(/[^a-z0-9]+/g, "-")
|
||||
.replace(/^-|-$/g, "");
|
||||
return text.toLowerCase().replace(/`/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
||||
}
|
||||
|
||||
function escapeHtml(value) {
|
||||
return String(value ?? "")
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """);
|
||||
return String(value ?? "").replace(/[&<>"']/g, (char) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[char]);
|
||||
}
|
||||
|
||||
function escapeAttr(value) {
|
||||
return escapeHtml(value).replace(/'/g, "'");
|
||||
return escapeHtml(value);
|
||||
}
|
||||
|
||||
function css() {
|
||||
return `
|
||||
:root {
|
||||
--bg: #fbfbfa;
|
||||
--panel: #ffffff;
|
||||
--ink: #18202a;
|
||||
--muted: #667085;
|
||||
--line: #e6e8ec;
|
||||
--blue: #1a73e8;
|
||||
--red: #ea4335;
|
||||
--yellow: #fbbc04;
|
||||
--green: #34a853;
|
||||
--code: #f6f8fb;
|
||||
--shadow: 0 18px 44px rgba(24,32,42,.08);
|
||||
color-scheme: light;
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
html { scroll-behavior: smooth; }
|
||||
body {
|
||||
margin: 0;
|
||||
background: var(--bg);
|
||||
color: var(--ink);
|
||||
font: 15px/1.62 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
||||
}
|
||||
a { color: var(--blue); text-decoration: none; }
|
||||
a:hover { text-decoration: underline; }
|
||||
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
||||
.shell { display: grid; grid-template-columns: 292px minmax(0, 1fr); min-height: 100vh; }
|
||||
.sidebar {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
height: 100vh;
|
||||
overflow: auto;
|
||||
border-right: 1px solid var(--line);
|
||||
background: rgba(255,255,255,.86);
|
||||
padding: 22px 18px;
|
||||
}
|
||||
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); margin-bottom: 22px; }
|
||||
.brand:hover { text-decoration: none; }
|
||||
.brand strong { display: block; font-size: 21px; line-height: 1; letter-spacing: -.02em; }
|
||||
.brand small { color: var(--muted); font-size: 12px; }
|
||||
.mark { display: grid; grid-template-columns: repeat(2, 12px); grid-template-rows: repeat(2, 12px); gap: 3px; }
|
||||
.mark i:nth-child(1) { background: var(--blue); }
|
||||
.mark i:nth-child(2) { background: var(--red); }
|
||||
.mark i:nth-child(3) { background: var(--yellow); }
|
||||
.mark i:nth-child(4) { background: var(--green); }
|
||||
.mark i { border-radius: 3px; display: block; }
|
||||
.search { display: block; margin-bottom: 18px; }
|
||||
.search span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
|
||||
.search input {
|
||||
width: 100%;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
padding: 9px 10px;
|
||||
color: var(--ink);
|
||||
background: var(--panel);
|
||||
}
|
||||
.sidebar section { margin: 20px 0; }
|
||||
.sidebar h2 { color: var(--muted); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; margin: 0 0 7px; }
|
||||
.sidebar a {
|
||||
display: block;
|
||||
color: #3f4a59;
|
||||
padding: 5px 8px;
|
||||
border-radius: 7px;
|
||||
font-size: 13px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.sidebar a[aria-current="page"], .sidebar a:hover { color: var(--ink); background: #f0f4fb; text-decoration: none; }
|
||||
main { padding: 34px min(5vw, 64px) 64px; min-width: 0; }
|
||||
.hero {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 24px;
|
||||
align-items: flex-start;
|
||||
margin: 0 auto 26px;
|
||||
max-width: 1180px;
|
||||
}
|
||||
.eyebrow { color: var(--muted); text-transform: uppercase; letter-spacing: .11em; font-size: 12px; margin: 0 0 8px; }
|
||||
h1 { font-size: clamp(34px, 5vw, 58px); line-height: 1; letter-spacing: -.045em; margin: 0; max-width: 880px; }
|
||||
.hero-links { display: flex; gap: 8px; flex-wrap: wrap; }
|
||||
.hero-links a {
|
||||
color: var(--ink);
|
||||
border: 1px solid var(--line);
|
||||
background: var(--panel);
|
||||
border-radius: 8px;
|
||||
padding: 8px 11px;
|
||||
box-shadow: 0 8px 20px rgba(24,32,42,.04);
|
||||
}
|
||||
.doc-grid {
|
||||
max-width: 1180px;
|
||||
margin: 0 auto;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 220px;
|
||||
gap: 30px;
|
||||
align-items: start;
|
||||
}
|
||||
.doc {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 10px;
|
||||
box-shadow: var(--shadow);
|
||||
padding: min(5vw, 48px);
|
||||
min-width: 0;
|
||||
}
|
||||
.doc h1 { font-size: 36px; margin-bottom: 18px; }
|
||||
.doc h2 { font-size: 24px; margin: 38px 0 12px; padding-top: 4px; }
|
||||
.doc h3 { font-size: 18px; margin: 28px 0 10px; }
|
||||
.doc p, .doc li { color: #344054; }
|
||||
.doc blockquote {
|
||||
margin: 18px 0;
|
||||
padding: 12px 16px;
|
||||
border-left: 4px solid var(--blue);
|
||||
background: #f7faff;
|
||||
color: #344054;
|
||||
}
|
||||
.doc pre {
|
||||
overflow: auto;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--line);
|
||||
background: var(--code);
|
||||
padding: 15px;
|
||||
}
|
||||
.doc code { font-size: .92em; }
|
||||
.doc :not(pre) > code {
|
||||
background: var(--code);
|
||||
border: 1px solid #e8ebf1;
|
||||
border-radius: 5px;
|
||||
padding: 1px 5px;
|
||||
}
|
||||
.doc table {
|
||||
display: block;
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
border-collapse: collapse;
|
||||
margin: 18px 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
.doc th, .doc td { border: 1px solid var(--line); padding: 8px 10px; vertical-align: top; }
|
||||
.doc th { background: #f8fafc; text-align: left; }
|
||||
.anchor { color: #b5bdc9; margin-right: 7px; }
|
||||
.toc {
|
||||
position: sticky;
|
||||
top: 24px;
|
||||
color: var(--muted);
|
||||
font-size: 13px;
|
||||
max-height: calc(100vh - 48px);
|
||||
overflow: auto;
|
||||
}
|
||||
.toc h2 { color: var(--ink); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
|
||||
.toc a { display: block; color: var(--muted); padding: 5px 0; }
|
||||
.toc-l3 { padding-left: 12px !important; }
|
||||
.page-nav {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 12px;
|
||||
margin-top: 42px;
|
||||
border-top: 1px solid var(--line);
|
||||
padding-top: 20px;
|
||||
}
|
||||
.page-nav a {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
padding: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.page-nav a:last-child { text-align: right; }
|
||||
.page-nav strong { color: var(--ink); }
|
||||
.nav-toggle { display: none; }
|
||||
@media (max-width: 960px) {
|
||||
.shell { display: block; }
|
||||
.sidebar {
|
||||
position: fixed;
|
||||
inset: 0 auto 0 0;
|
||||
width: min(320px, 86vw);
|
||||
transform: translateX(-100%);
|
||||
transition: transform .18s ease;
|
||||
z-index: 10;
|
||||
function validateLinks(outputDir) {
|
||||
const failures = [];
|
||||
// Generated command pages embed literal placeholders like `(url)` / `(path)` from help text.
|
||||
// These are not real links, so skip them rather than fail the build.
|
||||
const placeholderHrefs = /^(url|path|file|dir|name)$/i;
|
||||
for (const file of allHtml(outputDir)) {
|
||||
const html = fs.readFileSync(file, "utf8");
|
||||
for (const match of html.matchAll(/href="([^"]+)"/g)) {
|
||||
const href = match[1];
|
||||
if (/^(#|https?:|mailto:|tel:|javascript:)/.test(href)) continue;
|
||||
if (placeholderHrefs.test(href)) continue;
|
||||
const [rawPath, anchor = ""] = href.split("#");
|
||||
const targetPath = rawPath
|
||||
? path.resolve(path.dirname(file), rawPath)
|
||||
: file;
|
||||
const target = fs.existsSync(targetPath) && fs.statSync(targetPath).isDirectory()
|
||||
? path.join(targetPath, "index.html")
|
||||
: targetPath;
|
||||
if (!fs.existsSync(target)) {
|
||||
failures.push(`${path.relative(outputDir, file)}: ${href} -> missing ${path.relative(outputDir, target)}`);
|
||||
continue;
|
||||
}
|
||||
if (anchor) {
|
||||
const targetHtml = fs.readFileSync(target, "utf8");
|
||||
if (!targetHtml.includes(`id="${anchor}"`) && !targetHtml.includes(`name="${anchor}"`)) {
|
||||
failures.push(`${path.relative(outputDir, file)}: ${href} -> missing anchor`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
body.nav-open .sidebar { transform: translateX(0); }
|
||||
.nav-toggle {
|
||||
display: grid;
|
||||
position: fixed;
|
||||
top: 12px;
|
||||
left: 12px;
|
||||
z-index: 20;
|
||||
gap: 4px;
|
||||
border: 1px solid var(--line);
|
||||
background: var(--panel);
|
||||
border-radius: 8px;
|
||||
padding: 10px;
|
||||
if (failures.length) {
|
||||
throw new Error(`broken docs links:\n${failures.join("\n")}`);
|
||||
}
|
||||
.nav-toggle span { width: 18px; height: 2px; background: var(--ink); display: block; }
|
||||
main { padding: 70px 18px 42px; }
|
||||
.hero { display: block; }
|
||||
.hero-links { margin-top: 18px; }
|
||||
.doc-grid { display: block; }
|
||||
.toc { display: none; }
|
||||
.doc { padding: 24px; }
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
function js() {
|
||||
return `
|
||||
const toggle = document.querySelector(".nav-toggle");
|
||||
toggle?.addEventListener("click", () => {
|
||||
const open = document.body.classList.toggle("nav-open");
|
||||
toggle.setAttribute("aria-expanded", String(open));
|
||||
});
|
||||
document.querySelectorAll(".sidebar a").forEach((link) => {
|
||||
link.addEventListener("click", () => document.body.classList.remove("nav-open"));
|
||||
});
|
||||
const search = document.getElementById("doc-search");
|
||||
search?.addEventListener("input", () => {
|
||||
const q = search.value.trim().toLowerCase();
|
||||
document.querySelectorAll(".sidebar nav a").forEach((link) => {
|
||||
const haystack = (link.dataset.title || "") + " " + link.textContent.toLowerCase();
|
||||
link.hidden = q !== "" && !haystack.includes(q);
|
||||
});
|
||||
});
|
||||
`;
|
||||
function allHtml(dir) {
|
||||
return fs
|
||||
.readdirSync(dir, { withFileTypes: true })
|
||||
.flatMap((entry) => {
|
||||
const full = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) return allHtml(full);
|
||||
return entry.name.endsWith(".html") ? [full] : [];
|
||||
})
|
||||
.sort();
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ const commandsDir = path.join(docsDir, "commands");
|
||||
|
||||
const requiredFeatureDocs = [
|
||||
"install.md",
|
||||
"quickstart.md",
|
||||
"auth-clients.md",
|
||||
"safety-profiles.md",
|
||||
"raw-api.md",
|
||||
@ -50,7 +51,8 @@ for (const command of commands) {
|
||||
}
|
||||
}
|
||||
|
||||
const docsReadme = fs.readFileSync(path.join(docsDir, "README.md"), "utf8");
|
||||
const navSourcePath = path.join(root, "scripts", "build-docs-site.mjs");
|
||||
const navSource = fs.readFileSync(navSourcePath, "utf8");
|
||||
const missingFeaturePages = [];
|
||||
const unlinkedFeaturePages = [];
|
||||
const brokenLinks = checkMarkdownLinks(docsDir);
|
||||
@ -61,7 +63,7 @@ for (const rel of requiredFeatureDocs) {
|
||||
missingFeaturePages.push(`docs/${rel}`);
|
||||
continue;
|
||||
}
|
||||
if (!docsReadme.includes(`(${rel})`)) {
|
||||
if (!navSource.includes(`"${rel}"`)) {
|
||||
unlinkedFeaturePages.push(`docs/${rel}`);
|
||||
}
|
||||
}
|
||||
@ -69,7 +71,7 @@ for (const rel of requiredFeatureDocs) {
|
||||
if (missingCommandPages.length || missingFeaturePages.length || unlinkedFeaturePages.length || brokenLinks.length) {
|
||||
for (const name of missingCommandPages) console.error(`missing command doc: ${name}`);
|
||||
for (const name of missingFeaturePages) console.error(`missing feature doc: ${name}`);
|
||||
for (const name of unlinkedFeaturePages) console.error(`feature doc not linked from docs/README.md: ${name}`);
|
||||
for (const name of unlinkedFeaturePages) console.error(`feature doc not in scripts/build-docs-site.mjs sidebar: ${name}`);
|
||||
for (const item of brokenLinks) console.error(`broken docs link: ${item}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
199
scripts/docs-site-assets.mjs
Normal file
199
scripts/docs-site-assets.mjs
Normal file
@ -0,0 +1,199 @@
|
||||
export function css() {
|
||||
return `
|
||||
:root{--ink:#0f1115;--text:#1f2328;--muted:#6b7280;--subtle:#9aa1ab;--bg:#fafafa;--paper:#ffffff;--accent:#1a73e8;--accent-soft:rgba(26,115,232,.09);--accent-strong:#1558b9;--g-blue:#4285f4;--g-red:#ea4335;--g-yellow:#fbbc04;--g-green:#34a853;--line:#e5e7eb;--line-soft:#eef0f3;--code-bg:#0f172a;--code-fg:#e6edf3}
|
||||
*{box-sizing:border-box}
|
||||
html{scroll-behavior:smooth;scroll-padding-top:24px}
|
||||
body{margin:0;background:var(--bg);color:var(--text);font-family:"Inter",ui-sans-serif,system-ui,-apple-system,Segoe UI,sans-serif;line-height:1.65;overflow-x:hidden;-webkit-font-smoothing:antialiased;font-feature-settings:"cv02","cv03","cv04","cv11"}
|
||||
::selection{background:var(--accent);color:#fff}
|
||||
a{color:var(--accent);text-decoration:none;transition:color .12s}
|
||||
a:hover{text-decoration:underline;text-underline-offset:.2em}
|
||||
.shell{display:grid;grid-template-columns:268px minmax(0,1fr);min-height:100vh}
|
||||
.sidebar{position:sticky;top:0;height:100vh;overflow:auto;padding:24px 22px;background:var(--paper);border-right:1px solid var(--line);scrollbar-width:thin;scrollbar-color:var(--line) transparent}
|
||||
.sidebar::-webkit-scrollbar{width:6px}
|
||||
.sidebar::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px}
|
||||
.brand{display:flex;align-items:center;gap:11px;color:var(--ink);text-decoration:none;margin-bottom:24px}
|
||||
.brand:hover{text-decoration:none}
|
||||
.brand .mark{display:grid;grid-template-columns:repeat(2,12px);grid-template-rows:repeat(2,12px);gap:3px;flex:0 0 27px}
|
||||
.brand .mark i{display:block;border-radius:3px}
|
||||
.brand .mark i:nth-child(1){background:var(--g-blue)}
|
||||
.brand .mark i:nth-child(2){background:var(--g-red)}
|
||||
.brand .mark i:nth-child(3){background:var(--g-yellow)}
|
||||
.brand .mark i:nth-child(4){background:var(--g-green)}
|
||||
.brand strong{display:block;font-size:1.05rem;line-height:1.1;font-weight:600;letter-spacing:0}
|
||||
.brand small{display:block;color:var(--muted);font-size:.74rem;margin-top:3px;font-weight:400}
|
||||
.search{display:block;margin:0 0 22px}
|
||||
.search span{display:block;color:var(--muted);font-size:.7rem;font-weight:600;text-transform:uppercase;letter-spacing:0;margin-bottom:7px}
|
||||
.search input{width:100%;border:1px solid var(--line);background:var(--paper);border-radius:8px;padding:9px 12px;font:inherit;font-size:.9rem;color:var(--text);outline:none;transition:border-color .15s,box-shadow .15s}
|
||||
.search input:focus{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
|
||||
nav section{margin:0 0 18px}
|
||||
nav h2{font-size:.68rem;color:var(--muted);text-transform:uppercase;letter-spacing:0;margin:0 0 6px;font-weight:600}
|
||||
.nav-link{display:block;color:var(--text);text-decoration:none;border-radius:6px;padding:5px 10px;margin:1px 0;font-size:.9rem;line-height:1.4;transition:background .12s,color .12s}
|
||||
.nav-link:hover{background:var(--line-soft);color:var(--ink);text-decoration:none}
|
||||
.nav-link.active{background:var(--accent-soft);color:var(--accent);font-weight:600}
|
||||
main{min-width:0;padding:32px clamp(20px,4.5vw,56px) 80px;max-width:1180px;margin:0 auto;width:100%}
|
||||
.hero{display:flex;align-items:flex-end;justify-content:space-between;gap:22px;border-bottom:1px solid var(--line);padding:8px 0 22px;margin-bottom:8px;flex-wrap:wrap}
|
||||
.hero-text{min-width:0;flex:1 1 320px}
|
||||
.eyebrow{margin:0 0 8px;color:var(--muted);font-weight:600;text-transform:uppercase;letter-spacing:0;font-size:.7rem}
|
||||
.hero h1{font-size:2.25rem;line-height:1.1;letter-spacing:0;margin:0;font-weight:700;color:var(--ink)}
|
||||
.hero-meta{display:flex;gap:8px;flex:0 0 auto;flex-wrap:wrap}
|
||||
.repo,.edit,.btn-ghost{border:1px solid var(--line);color:var(--text);text-decoration:none;border-radius:7px;padding:6px 11px;font-weight:500;font-size:.83rem;background:var(--paper);transition:border-color .15s,color .15s,background .15s}
|
||||
.repo:hover,.edit:hover,.btn-ghost:hover{border-color:var(--ink);color:var(--ink);text-decoration:none}
|
||||
.edit{color:var(--muted)}
|
||||
.home-hero{padding:14px 0 28px;margin-bottom:8px;border-bottom:1px solid var(--line)}
|
||||
.home-hero h1{font-size:3.25rem;line-height:1.04;letter-spacing:0;margin:0 0 .35em;font-weight:700;color:var(--ink)}
|
||||
.home-hero .lede{font-size:1.18rem;line-height:1.55;color:#3b4147;margin:0 0 1.2em;max-width:60ch}
|
||||
.home-cta{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin:0 0 18px}
|
||||
.home-cta .btn{display:inline-flex;align-items:center;gap:7px;border-radius:8px;padding:10px 16px;font-weight:600;font-size:.92rem;text-decoration:none;transition:background .15s,border-color .15s,color .15s,transform .12s}
|
||||
.home-cta .btn-primary{background:var(--accent);color:#fff;border:1px solid var(--accent)}
|
||||
.home-cta .btn-primary:hover{background:var(--accent-strong);border-color:var(--accent-strong);text-decoration:none}
|
||||
.home-cta .btn-ghost{padding:10px 16px}
|
||||
.home-install{display:flex;align-items:center;gap:0;background:var(--code-bg);color:var(--code-fg);border-radius:8px;padding:10px 12px;font:500 .9rem/1.2 "JetBrains Mono","SF Mono",ui-monospace,monospace;max-width:30em;border:1px solid #1f2937}
|
||||
.home-install .prompt{color:#64748b;user-select:none;margin-right:8px}
|
||||
.home-install code{flex:1;background:transparent;border:0;color:var(--code-fg);font:inherit;padding:0;white-space:pre}
|
||||
.home-install .copy{background:rgba(255,255,255,.08);color:var(--code-fg);border:1px solid rgba(255,255,255,.16);border-radius:6px;padding:4px 9px;font:500 .72rem/1 "Inter",sans-serif;cursor:pointer;transition:background .15s,border-color .15s}
|
||||
.home-install .copy:hover{background:rgba(255,255,255,.16)}
|
||||
.home-install .copy.copied{background:var(--accent);border-color:var(--accent)}
|
||||
.home-services{display:flex;flex-wrap:wrap;gap:6px;margin:6px 0 18px}
|
||||
.home-services span{display:inline-block;padding:3px 9px;border:1px solid var(--line);border-radius:999px;font-size:.78rem;color:var(--muted);background:var(--paper)}
|
||||
.doc-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:48px;margin-top:24px}
|
||||
.doc-grid-home{margin-top:8px}
|
||||
@media(min-width:1180px){.doc-grid{grid-template-columns:minmax(0,72ch) 200px;justify-content:start}.doc-grid-home{grid-template-columns:minmax(0,76ch);justify-content:start}}
|
||||
.doc{min-width:0;max-width:72ch;overflow-wrap:break-word}
|
||||
.doc-home{max-width:76ch}
|
||||
.doc h1{font-size:2.6rem;line-height:1.08;letter-spacing:0;margin:0 0 .4em;font-weight:700;color:var(--ink)}
|
||||
body:not(.home) .doc>h1:first-child{display:none}
|
||||
.doc h2{font-size:1.45rem;line-height:1.2;margin:2em 0 .5em;font-weight:600;letter-spacing:0;color:var(--ink);position:relative}
|
||||
.doc h3{font-size:1.1rem;margin:1.7em 0 .35em;position:relative;font-weight:600;color:var(--ink);letter-spacing:0}
|
||||
.doc h4{font-size:.98rem;margin:1.4em 0 .25em;color:var(--ink);position:relative;font-weight:600}
|
||||
.doc h2:first-child,.doc h3:first-child,.doc h4:first-child{margin-top:.2em}
|
||||
.doc :is(h2,h3,h4) .anchor{position:absolute;left:-1.05em;top:0;color:var(--subtle);opacity:0;text-decoration:none;font-weight:400;padding-right:.3em;transition:opacity .12s,color .12s}
|
||||
.doc :is(h2,h3,h4):hover .anchor{opacity:.7}
|
||||
.doc :is(h2,h3,h4) .anchor:hover{opacity:1;color:var(--accent);text-decoration:none}
|
||||
.doc p{margin:0 0 1.05em}
|
||||
.doc ul,.doc ol{padding-left:1.3rem;margin:0 0 1.15em}
|
||||
.doc li{margin:.25em 0}
|
||||
.doc li>p{margin:0 0 .4em}
|
||||
.doc strong{font-weight:600;color:var(--ink)}
|
||||
.doc em{font-style:italic}
|
||||
.doc code{font-family:"JetBrains Mono","SF Mono",ui-monospace,monospace;font-size:.84em;background:var(--line-soft);border:1px solid var(--line);border-radius:5px;padding:.08em .35em;color:#1c2128}
|
||||
.doc pre{position:relative;overflow:auto;background:var(--code-bg);color:var(--code-fg);border-radius:8px;padding:14px 18px;margin:1.3em 0;font-size:.85em;line-height:1.6;scrollbar-width:thin;scrollbar-color:#334155 transparent;border:1px solid #1f2937}
|
||||
.doc pre::-webkit-scrollbar{height:8px;width:8px}
|
||||
.doc pre::-webkit-scrollbar-thumb{background:#334155;border-radius:8px}
|
||||
.doc pre code{display:block;background:transparent;border:0;color:inherit;padding:0;font-size:1em;white-space:pre}
|
||||
.doc pre .copy{position:absolute;top:8px;right:8px;background:rgba(255,255,255,.06);color:var(--code-fg);border:1px solid rgba(255,255,255,.16);border-radius:6px;padding:3px 9px;font:500 .7rem/1 "Inter",sans-serif;cursor:pointer;opacity:0;transition:opacity .15s,background .15s,border-color .15s}
|
||||
.doc pre:hover .copy,.doc pre .copy:focus{opacity:1}
|
||||
.doc pre .copy:hover{background:rgba(255,255,255,.12)}
|
||||
.doc pre .copy.copied{background:var(--accent);border-color:var(--accent);opacity:1}
|
||||
.doc blockquote{margin:1.4em 0;padding:10px 16px;border-left:3px solid var(--accent);background:var(--accent-soft);border-radius:0 8px 8px 0;color:var(--text)}
|
||||
.doc blockquote p:last-child{margin-bottom:0}
|
||||
.doc table{width:100%;border-collapse:collapse;margin:1.2em 0;font-size:.92em}
|
||||
.doc th,.doc td{border-bottom:1px solid var(--line);padding:9px 10px;text-align:left;vertical-align:top}
|
||||
.doc th{font-weight:600;color:var(--ink);background:var(--line-soft);border-bottom:1px solid var(--line)}
|
||||
.doc hr{border:0;border-top:1px solid var(--line);margin:2.2em 0}
|
||||
.toc{position:sticky;top:24px;align-self:start;font-size:.84rem;padding-left:14px;border-left:1px solid var(--line);max-height:calc(100vh - 48px);overflow:auto;scrollbar-width:thin;scrollbar-color:var(--line) transparent}
|
||||
.toc::-webkit-scrollbar{width:5px}
|
||||
.toc::-webkit-scrollbar-thumb{background:var(--line);border-radius:5px}
|
||||
.toc h2{font-size:.66rem;color:var(--muted);text-transform:uppercase;letter-spacing:0;margin:0 0 10px;font-weight:600}
|
||||
.toc a{display:block;color:var(--muted);text-decoration:none;padding:4px 0 4px 10px;line-height:1.35;border-left:2px solid transparent;margin-left:-12px;transition:color .12s,border-color .12s}
|
||||
.toc a:hover{color:var(--ink);text-decoration:none}
|
||||
.toc a.active{color:var(--accent);border-left-color:var(--accent);font-weight:500}
|
||||
.toc-l3{padding-left:22px!important;font-size:.94em}
|
||||
@media(max-width:1179px){.toc{display:none}}
|
||||
.page-nav{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:48px;border-top:1px solid var(--line);padding-top:20px}
|
||||
.page-nav>a{display:block;border:1px solid var(--line);background:var(--paper);border-radius:9px;padding:13px 16px;text-decoration:none;color:var(--text);transition:border-color .15s,transform .15s,box-shadow .15s}
|
||||
.page-nav>a:hover{border-color:var(--accent);text-decoration:none;color:var(--ink)}
|
||||
.page-nav small{display:block;color:var(--muted);font-size:.7rem;text-transform:uppercase;letter-spacing:0;margin-bottom:5px;font-weight:600}
|
||||
.page-nav span{display:block;font-weight:600;line-height:1.3;color:var(--ink)}
|
||||
.page-nav-prev{text-align:left}
|
||||
.page-nav-next{text-align:right;grid-column:2}
|
||||
.page-nav-prev:only-child{grid-column:1}
|
||||
.nav-toggle{display:none;position:fixed;top:14px;right:14px;top:calc(14px + env(safe-area-inset-top, 0px));right:calc(14px + env(safe-area-inset-right, 0px));z-index:20;width:40px;height:40px;border-radius:9px;background:var(--paper);border:1px solid var(--line);color:var(--ink);cursor:pointer;padding:10px 9px;flex-direction:column;align-items:stretch;justify-content:space-between;box-shadow:0 4px 14px rgba(15,17,21,.08)}
|
||||
.nav-toggle span{display:block;width:100%;height:2px;flex:0 0 2px;background:currentColor;border-radius:2px;transition:transform .2s,opacity .2s}
|
||||
.nav-toggle[aria-expanded="true"] span:nth-child(1){transform:translateY(8px) rotate(45deg)}
|
||||
.nav-toggle[aria-expanded="true"] span:nth-child(2){opacity:0}
|
||||
.nav-toggle[aria-expanded="true"] span:nth-child(3){transform:translateY(-8px) rotate(-45deg)}
|
||||
@media(max-width:900px){
|
||||
.shell{display:block}
|
||||
.sidebar{position:fixed;inset:0 30% 0 0;max-width:320px;height:100vh;z-index:15;transform:translateX(-100%);transition:transform .25s ease;box-shadow:0 18px 40px rgba(15,17,21,.18);background:var(--paper);pointer-events:none}
|
||||
.sidebar.open{transform:translateX(0);pointer-events:auto}
|
||||
.nav-toggle{display:flex}
|
||||
main{padding:64px 18px 56px}
|
||||
.hero{padding-top:6px}
|
||||
.hero h1{font-size:1.8rem}
|
||||
.home-hero h1{font-size:2.45rem}
|
||||
.doc h1{font-size:2.1rem}
|
||||
.hero-meta{width:100%;justify-content:flex-start}
|
||||
.home-hero{padding-top:8px}
|
||||
.doc{padding:0}
|
||||
.doc-grid{margin-top:18px;gap:24px}
|
||||
.doc :is(h2,h3,h4) .anchor{display:none}
|
||||
}
|
||||
@media(max-width:520px){
|
||||
main{padding:60px 14px 48px}
|
||||
.doc pre{margin-left:-14px;margin-right:-14px;border-radius:0;border-left:0;border-right:0}
|
||||
.home-install{flex-wrap:wrap}
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
export function js() {
|
||||
return `
|
||||
const sidebar=document.querySelector('.sidebar');
|
||||
const toggle=document.querySelector('.nav-toggle');
|
||||
const mobileNav=window.matchMedia('(max-width: 900px)');
|
||||
const sidebarFocusable='a[href],button,input,select,textarea,[tabindex]';
|
||||
function setSidebarFocusable(enabled){
|
||||
sidebar?.querySelectorAll(sidebarFocusable).forEach((el)=>{
|
||||
if(enabled){
|
||||
if(el.dataset.sidebarTabindex!==undefined){
|
||||
if(el.dataset.sidebarTabindex)el.setAttribute('tabindex',el.dataset.sidebarTabindex);
|
||||
else el.removeAttribute('tabindex');
|
||||
delete el.dataset.sidebarTabindex;
|
||||
}
|
||||
}else if(el.dataset.sidebarTabindex===undefined){
|
||||
el.dataset.sidebarTabindex=el.getAttribute('tabindex')??'';
|
||||
el.setAttribute('tabindex','-1');
|
||||
}
|
||||
});
|
||||
}
|
||||
function setSidebarOpen(open){
|
||||
if(!sidebar||!toggle)return;
|
||||
sidebar.classList.toggle('open',open);
|
||||
toggle.setAttribute('aria-expanded',open?'true':'false');
|
||||
if(mobileNav.matches){
|
||||
sidebar.inert=!open;
|
||||
if(open)sidebar.removeAttribute('aria-hidden');
|
||||
else sidebar.setAttribute('aria-hidden','true');
|
||||
setSidebarFocusable(open);
|
||||
}else{
|
||||
sidebar.inert=false;
|
||||
sidebar.removeAttribute('aria-hidden');
|
||||
setSidebarFocusable(true);
|
||||
}
|
||||
}
|
||||
setSidebarOpen(false);
|
||||
toggle?.addEventListener('click',()=>setSidebarOpen(!sidebar?.classList.contains('open')));
|
||||
document.addEventListener('click',(e)=>{if(!sidebar?.classList.contains('open'))return;if(sidebar.contains(e.target)||toggle?.contains(e.target))return;setSidebarOpen(false)});
|
||||
document.addEventListener('keydown',(e)=>{if(e.key==='Escape')setSidebarOpen(false)});
|
||||
const syncSidebarForViewport=()=>setSidebarOpen(sidebar?.classList.contains('open')??false);
|
||||
if(mobileNav.addEventListener)mobileNav.addEventListener('change',syncSidebarForViewport);
|
||||
else mobileNav.addListener?.(syncSidebarForViewport);
|
||||
const input=document.getElementById('doc-search');
|
||||
input?.addEventListener('input',()=>{const q=input.value.trim().toLowerCase();document.querySelectorAll('nav section').forEach(sec=>{let any=false;sec.querySelectorAll('.nav-link').forEach(a=>{const m=!q||a.textContent.toLowerCase().includes(q);a.style.display=m?'block':'none';if(m)any=true});sec.style.display=any?'block':'none'})});
|
||||
function attachCopy(target,getText){const btn=document.createElement('button');btn.type='button';btn.className='copy';btn.textContent='Copy';btn.addEventListener('click',async()=>{try{await navigator.clipboard.writeText(getText());btn.textContent='Copied';btn.classList.add('copied');setTimeout(()=>{btn.textContent='Copy';btn.classList.remove('copied')},1400)}catch{btn.textContent='Failed';setTimeout(()=>{btn.textContent='Copy'},1400)}});target.appendChild(btn)}
|
||||
document.querySelectorAll('.doc pre').forEach(pre=>attachCopy(pre,()=>pre.querySelector('code')?.textContent??''));
|
||||
document.querySelectorAll('.home-install').forEach(el=>attachCopy(el,()=>el.querySelector('code')?.textContent??''));
|
||||
const tocLinks=document.querySelectorAll('.toc a');
|
||||
if(tocLinks.length){const map=new Map();tocLinks.forEach(a=>{const id=a.getAttribute('href').slice(1);const el=document.getElementById(id);if(el)map.set(el,a)});const setActive=l=>{tocLinks.forEach(x=>x.classList.remove('active'));l.classList.add('active')};const obs=new IntersectionObserver(entries=>{const visible=entries.filter(e=>e.isIntersecting).sort((a,b)=>a.boundingClientRect.top-b.boundingClientRect.top);if(visible.length){const link=map.get(visible[0].target);if(link)setActive(link)}},{rootMargin:'-15% 0px -65% 0px',threshold:0});map.forEach((_,el)=>obs.observe(el))}
|
||||
`;
|
||||
}
|
||||
|
||||
export function faviconSvg() {
|
||||
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="gog">
|
||||
<rect width="64" height="64" rx="12" fill="#0f1115"/>
|
||||
<rect x="14" y="14" width="14" height="14" rx="3" fill="#4285f4"/>
|
||||
<rect x="36" y="14" width="14" height="14" rx="3" fill="#ea4335"/>
|
||||
<rect x="14" y="36" width="14" height="14" rx="3" fill="#fbbc04"/>
|
||||
<rect x="36" y="36" width="14" height="14" rx="3" fill="#34a853"/>
|
||||
</svg>`;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user