Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions packages/docusaurus-theme/css/code.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Code block syntax theme.
*
* Colors are driven by CSS variables (see vars.css for light, vars-dark.css for dark),
* so a consuming site can retune any hue by overriding a single --code-* variable, and
* the change hot-reloads with no server restart.
*
* Pair this with the prism-react-renderer theme exported from
* '@netfoundry/docusaurus-theme/node' (prismTheme), which maps the code block's base
* foreground/background to --code-fg / --code-bg and leaves every token color to these rules.
*/

/* Soft rounding on the whole block */
div[class*='codeBlockContainer'] {
border-radius: 10px;
overflow: hidden;
}

.token.comment,
.token.prolog,
.token.cdata,
.token.doctype {
color: var(--code-comment);
font-style: italic;
}
.token.punctuation { color: var(--code-punctuation); }
.token.namespace { opacity: 0.7; }

.token.keyword,
.token.atrule,
.token.important,
.token.rule { color: var(--code-keyword); }

.token.string,
.token.char,
.token.attr-value,
.token.regex,
.token.inserted { color: var(--code-string); }

.token.function,
.token.deleted { color: var(--code-function); }

.token.number,
.token.boolean,
.token.constant,
.token.symbol { color: var(--code-number); }

.token.class-name,
.token.tag,
.token.selector,
.token.builtin { color: var(--code-class); }

.token.operator,
.token.entity,
.token.url { color: var(--code-operator); }

.token.property,
.token.attr-name { color: var(--code-property); }

/* Command-line flags (e.g. -k, --username) and shell variables: muted accent */
.token.variable,
.token.parameter { color: var(--code-flag); }

.token.bold { font-weight: 600; }
.token.italic { font-style: italic; }
3 changes: 3 additions & 0 deletions packages/docusaurus-theme/css/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
/* Legacy design system variables and comprehensive styling */
@import "./legacy.css";

/* Code block syntax theme (token colors driven by the --code-* vars) */
@import "./code.css";

/* ── Footer social link hover ───────────────────────────────────────────── */
footer a[class*="footerSocialLink"] {
transition: all 0.2s ease;
Expand Down
17 changes: 17 additions & 0 deletions packages/docusaurus-theme/css/vars-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,21 @@ html[data-theme="dark"] {
.container {
/*background: orange;*/
}
}

/* Code block syntax palette (dark): Tokyo Night inspired.
Token rules that consume these live in code.css. */
html[data-theme="dark"] {
--code-bg: #1a1b26;
--code-fg: #a9b1d6;
--code-comment: #565f89;
--code-punctuation: #9aa5ce;
--code-keyword: #bb9af7; /* violet */
--code-string: #9ece6a; /* green */
--code-function: #7aa2f7; /* blue */
--code-number: #ff9e64; /* orange */
--code-class: #2ac3de; /* cyan */
--code-operator: #89ddff; /* sky */
--code-property: #7dcfff; /* light sky */
--code-flag: #7f9cc0; /* soft steel blue, for CLI flags */
}
19 changes: 19 additions & 0 deletions packages/docusaurus-theme/css/vars.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,23 @@
.container {
/*background: sandybrown;*/
}
}

/* Code block syntax palette (light): high-contrast, GitHub Light inspired.
Token rules that consume these live in code.css. */
:root {
--code-bg: #f6f8fa;
--code-fg: #1f2328;
--code-comment: #6e7781;
--code-punctuation: #57606a;
--code-keyword: #cf222e; /* red */
--code-string: #0a3069; /* navy */
--code-function: #8250df; /* violet */
--code-number: #0550ae; /* blue */
--code-class: #116329; /* green */
--code-operator: #57606a; /* slate */
--code-property: #953800; /* amber */
--code-flag: #4c6b8a; /* steel blue, for CLI flags */
--prism-background-color: var(--code-bg);
--prism-color: var(--code-fg);
}
2 changes: 1 addition & 1 deletion packages/docusaurus-theme/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@netfoundry/docusaurus-theme",
"version": "0.15.2",
"version": "0.16.0",
"description": "NetFoundry Docusaurus theme with shared layout, footer, and styling",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-theme/src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
* Import from '@netfoundry/docusaurus-theme/node' in Node.js contexts.
*/
export * from './docusaurus-envhelper';
export * from './prism';
40 changes: 40 additions & 0 deletions packages/docusaurus-theme/src/prism.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Prism (code block) theme for docusaurus.config.ts `themeConfig.prism`.
*
* Intentionally minimal: it only maps the base foreground/background to the --code-fg /
* --code-bg CSS variables. Every token color is driven by css/code.css (auto-loaded via
* theme.css), so the whole syntax palette lives in CSS and hot-reloads with no server restart.
* Light and dark palettes are selected in CSS via [data-theme], so the same object is used for
* both `theme` and `darkTheme`.
*
* Usage:
* import {prismTheme} from '@netfoundry/docusaurus-theme/node';
* // ...
* prism: { theme: prismTheme, darkTheme: prismTheme, additionalLanguages: [...] }
*/
export const prismTheme = {
plain: {
color: 'var(--code-fg)',
backgroundColor: 'var(--code-bg)',
},
styles: [] as Array<{types: string[]; style: Record<string, string>}>,
};

/**
* Recommended Prism languages to load beyond the prism-react-renderer defaults
* (typescript, yaml, json, markup, css, etc. are already bundled).
*
* `additionalLanguages` is a site-level themeConfig option, so each site must still
* reference this in its own config. Keeping the list here makes it the single source of truth:
* prism: { theme: prismTheme, darkTheme: prismTheme, additionalLanguages: prismAdditionalLanguages }
* Sites can spread and extend it: [...prismAdditionalLanguages, 'rust'].
*/
export const prismAdditionalLanguages = [
'bash',
'go',
'python',
'java',
'csharp',
'docker',
'scala',
];
2 changes: 2 additions & 0 deletions packages/test-site/docs/code-theme/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
label: "Code theme"
position: 9
48 changes: 48 additions & 0 deletions packages/test-site/docs/code-theme/bash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
sidebar_label: "Bash"
---

# Theme test: Bash

```bash
#!/usr/bin/env bash
# provision a quickstart overlay and a first service
set -euo pipefail

CTRL_ADDR="${CTRL_ADDR:-quickstart.demo.openziti.io}"
PORT=1280
RETRIES=5

log() {
local level="$1"; shift
printf '[%s] %s\n' "${level^^}" "$*" >&2
}

wait_for_controller() {
local url="https://${CTRL_ADDR}:${PORT}/edge/client/v1/version"
for ((i = 1; i <= RETRIES; i++)); do
if curl -sk -o /dev/null -w '%{http_code}' "$url" | grep -q '^200$'; then
log info "controller ready after ${i} attempt(s)"
return 0
fi
sleep 2
done
log error "controller never came up"
return 1
}

main() {
ziti run quickstart --zac --ctrl-address "$CTRL_ADDR" &
local pid=$!
trap 'kill "$pid" 2>/dev/null || true' EXIT

wait_for_controller || exit 1

ziti login "localhost:${PORT}" --username admin --password "${ZITI_PWD:-admin}"
local routers
routers=$(ziti list edge-routers 'name contains "quickstart"' --output-json | jq '.data | length')
log info "found ${routers} matching router(s)"
}

main "$@"
```
59 changes: 59 additions & 0 deletions packages/test-site/docs/code-theme/config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
sidebar_label: "Config (YAML / JSON / Docker)"
---

# Theme test: config formats

## YAML

```yaml
# controller web listener with the console bound
web:
- name: client-management
bindPoints:
- interface: 0.0.0.0:1280
address: quickstart.demo.openziti.io:1280
options:
idleTimeout: 5000ms
minTLSVersion: TLS1.2
apis:
- binding: edge-management
- binding: spa
options:
location: ./console
indexFile: index.html
enabled: true # serve the admin console at /zac/
```

## JSON

```json
{
"protocols": ["tcp"],
"addresses": ["first-service.ziti"],
"portRanges": [{ "low": 1280, "high": 1280 }],
"encryptionRequired": true,
"tags": {
"owner": "get-started",
"createdAt": "2026-07-06T00:00:00Z",
"retries": 3,
"ephemeral": false
}
}
```

## Dockerfile

```dockerfile
FROM golang:1.26 AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /out/ziti ./cmd/ziti

FROM gcr.io/distroless/static:nonroot
COPY --from=build /out/ziti /usr/local/bin/ziti
EXPOSE 1280 3022
ENTRYPOINT ["ziti", "run", "quickstart", "--zac"]
```
62 changes: 62 additions & 0 deletions packages/test-site/docs/code-theme/go.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
sidebar_label: "Go"
---

# Theme test: Go

```go
// Package overlay dials a Ziti service and echoes a request over it.
package overlay

import (
"context"
"errors"
"fmt"
"time"

"github.com/openziti/sdk-golang/ziti"
)

const (
defaultTimeout = 5 * time.Second
maxRetries = 3
)

// ErrNoService is returned when the named service cannot be reached.
var ErrNoService = errors.New("overlay: service unavailable")

// Client wraps a Ziti context and a small retry policy.
type Client struct {
ctx ziti.Context
service string
retries int
}

// Dialer is anything that can open a connection by service name.
type Dialer interface {
Dial(service string) (context.Context, error)
}

// NewClient builds a Client, defaulting retries when unset.
func NewClient(ctx ziti.Context, service string, opts ...func(*Client)) *Client {
c := &Client{ctx: ctx, service: service, retries: maxRetries}
for _, opt := range opts {
opt(c)
}
return c
}

func (c *Client) Fetch(ctx context.Context) (n int, err error) {
for attempt := 1; attempt <= c.retries; attempt++ {
conn, dialErr := c.ctx.Dial(c.service)
if dialErr != nil {
err = fmt.Errorf("attempt %d: %w", attempt, ErrNoService)
time.Sleep(time.Duration(attempt) * 250 * time.Millisecond)
continue
}
defer conn.Close()
return conn.Write([]byte("GET /health\r\n"))
}
return 0, err
}
```
Loading
Loading