repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

opencode/skills/presenterm/references/d2-integration.md

Raw

D2 Integration in presenterm

D2 diagrams render in presenterm with +render attribute:

```d2 +render
direction: right
Producer -> Broker -> Consumer
```
## Key Differences from Standalone D2

| Feature | Standalone D2 | presenterm |
| ------- | -------------- | ---------- |
| Syntax | Full D2 | Full D2 |
| Rendering | `d2 input.d2 out.svg` | Automatic via `+render` |
| Layout | CLI flag or in-file | CLI flag or in-file |
| Themes | `--theme` flag | presenterm handles via slide theme |

## Terminal Sizing Tips

presenterm presentations have constrained viewport width:

1. **Keep diagrams small** — 5-10 nodes maximum
2. **Use `direction: right`** for wide diagrams, `direction: down` for tall
3. **Split complex architectures** across multiple slides
4. **Match diagram colors to slide theme**:
   - Dark slides → `style.fill: "#2A2A2A"`, `style.font-color: "#FFFFFF"`
   - Light slides → `style.fill: "#FFFFFF"`, `style.font-color: "#000000"`

## Presenterm-Specific Notes

### Theme Coordination

```d2
direction: right

service: My Service {
    style.fill: ${theme_fill}
    style.font-color: ${theme_foreground}
}

# Match presenterm's dark theme colors
vars: {
    theme_fill: "#2A2A2A"
    theme_foreground: "#e6e6e6"
}

Scale Appropriately

```d2 +render
direction: right

# Keep it simple - max 5-7 nodes per diagram
api -> db -> cache
```
## Full D2 Reference

For complete D2 syntax (shapes, connections, containers, SQL tables, styling), see the **d2 skill**:

Load the d2 skill for full syntax reference including:

## Example: Architecture Diagram

```markdown
```d2 +render
direction: right

Backend: Backend Services {
    api: API Server { shape: hexagon }
    worker: Background Worker { shape: hexagon }
    db: Database { shape: cylinder }
    api -> worker: enqueue
    worker -> db: persist
}

Frontend: Web App {
    ui: React UI
    state: State Store
}

Frontend.ui -> Backend.api: REST calls {
        style.stroke-dash: 3
    }
## Installation (for rendering)

presenterm uses the `d2` CLI to render diagrams:

```bash
# Install D2
curl -fsSL https://d2lang.com/install.sh | sh -s --

# Verify
d2 --version

Without d2 installed, +render blocks will show as code instead of diagrams.

Markdown source
# D2 Integration in presenterm

D2 diagrams render in presenterm with `+render` attribute:

````markdown
```d2 +render
direction: right
Producer -> Broker -> Consumer
```
````

````
## Key Differences from Standalone D2

| Feature | Standalone D2 | presenterm |
| ------- | -------------- | ---------- |
| Syntax | Full D2 | Full D2 |
| Rendering | `d2 input.d2 out.svg` | Automatic via `+render` |
| Layout | CLI flag or in-file | CLI flag or in-file |
| Themes | `--theme` flag | presenterm handles via slide theme |

## Terminal Sizing Tips

presenterm presentations have constrained viewport width:

1. **Keep diagrams small** — 5-10 nodes maximum
2. **Use `direction: right`** for wide diagrams, `direction: down` for tall
3. **Split complex architectures** across multiple slides
4. **Match diagram colors to slide theme**:
   - Dark slides → `style.fill: "#2A2A2A"`, `style.font-color: "#FFFFFF"`
   - Light slides → `style.fill: "#FFFFFF"`, `style.font-color: "#000000"`

## Presenterm-Specific Notes

### Theme Coordination

```d2
direction: right

service: My Service {
    style.fill: ${theme_fill}
    style.font-color: ${theme_foreground}
}

# Match presenterm's dark theme colors
vars: {
    theme_fill: "#2A2A2A"
    theme_foreground: "#e6e6e6"
}
````

### Scale Appropriately

````markdown
```d2 +render
direction: right

# Keep it simple - max 5-7 nodes per diagram
api -> db -> cache
```
````

```
## Full D2 Reference

For complete D2 syntax (shapes, connections, containers, SQL tables, styling), see the **d2 skill**:
```

Load the d2 skill for full syntax reference including:

- Shape types (rectangle, circle, diamond, cylinder, etc.)
- Connection types (arrows, lines, labels, chaining)
- Container/nested syntax
- SQL table diagrams
- UML class diagrams
- Sequence diagrams
- Styling (fill, stroke, font, animations)
- Variables and classes
- Layout engines (dagre, ELK, TALA)

````
## Example: Architecture Diagram

```markdown
```d2 +render
direction: right

Backend: Backend Services {
    api: API Server { shape: hexagon }
    worker: Background Worker { shape: hexagon }
    db: Database { shape: cylinder }
    api -> worker: enqueue
    worker -> db: persist
}

Frontend: Web App {
    ui: React UI
    state: State Store
}

Frontend.ui -> Backend.api: REST calls {
        style.stroke-dash: 3
    }
````

````
## Installation (for rendering)

presenterm uses the `d2` CLI to render diagrams:

```bash
# Install D2
curl -fsSL https://d2lang.com/install.sh | sh -s --

# Verify
d2 --version
````

Without `d2` installed, `+render` blocks will show as code instead of diagrams.