Skip to content

Commit 7b8fc1e

Browse files
authored
Merge pull request #167 from fcendesu/codex/analytics-integration
feat(config): add optional analytics integration
2 parents 5ca2c20 + 5bc1337 commit 7b8fc1e

11 files changed

Lines changed: 352 additions & 1 deletion

File tree

‎assets/themes/atlas/templates/partials/head_assets.html‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
{{ site_font_faces_css | safe }}
2020
</style>
2121
{% endif %}
22+
{% if site_analytics_head_html %}
23+
{{ site_analytics_head_html | safe }}
24+
{% endif %}
2225
<link rel="stylesheet" href="{{ asset_url(path='style.css') }}?v={{ site_asset_version }}" />
2326
<link rel="stylesheet" href="{{ asset_url(path='palette.css') }}?v={{ site_asset_version }}" />
2427
{% if site_has_custom_css %}

‎assets/themes/journal/templates/partials/head_assets.html‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
{{ site_font_faces_css | safe }}
2020
</style>
2121
{% endif %}
22+
{% if site_analytics_head_html %}
23+
{{ site_analytics_head_html | safe }}
24+
{% endif %}
2225
<link rel="stylesheet" href="{{ asset_url(path='style.css') }}?v={{ site_asset_version }}" />
2326
<link rel="stylesheet" href="{{ asset_url(path='palette.css') }}?v={{ site_asset_version }}" />
2427
{% if site_has_custom_css %}

‎docs/cli.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ Project validation:
4949
rustipo check
5050
```
5151

52+
Analytics configuration is opt-in. For the first built-in integration, Rustipo supports Plausible
53+
with an optional self-hosted script override:
54+
55+
```toml
56+
[site.analytics.plausible]
57+
domain = "docs.example.com"
58+
# Optional for self-hosted Plausible:
59+
# script_src = "https://stats.example.com/js/script.js"
60+
```
61+
62+
Built-in themes render the analytics snippet automatically when configured.
63+
5264
Theme discovery:
5365

5466
```bash
@@ -155,6 +167,7 @@ Current behavior:
155167
- `site.typography.heading_font`
156168
- `site.typography.mono_font`
157169
- Exposes `site_font_faces_css` to templates for optional font-face injection
170+
- Exposes `site_analytics_head_html` to templates for opt-in analytics snippet output
158171
- Auto-includes `static/custom.css` in template context when present (`site_has_custom_css`)
159172
- Writes rendered pages to `dist/` using pretty URL output paths
160173
- Writes generated palette variables to `dist/palette.css`

‎docs/implemented-features.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@
232232
- `site_favicon_ico`
233233
- `site_apple_touch_icon`
234234
- `site_asset_version`
235+
- `site_analytics_head_html`
235236
- `site_style`
236237
- `content_width`
237238
- `top_gap`
@@ -269,6 +270,8 @@
269270
- resolution order:
270271
- `page_summary`
271272
- `site_description`
273+
- opt-in Plausible analytics snippet support in built-in themes
274+
- optional self-hosted Plausible `script_src` override
272275
- `route`
273276
- `section_name`
274277
- `section_title`

‎docs/theme-contract.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ Rustipo injects common site variables into template contexts, including:
198198
- `next_url`
199199
- favicon helpers: `site_favicon`, `site_favicon_svg`, `site_favicon_ico`, `site_apple_touch_icon`
200200
- asset helper: `site_asset_version` (stable cache-busting fingerprint for generated asset URLs)
201+
- analytics helper: `site_analytics_head_html` (optional provider-agnostic head snippet for configured analytics)
201202
- style helpers from config:
202203
- `site_style.content_width`
203204
- `site_style.top_gap`
@@ -216,6 +217,25 @@ Rustipo injects common site variables into template contexts, including:
216217

217218
If both values are empty, Rustipo leaves `page_description` unset so themes can omit the tag cleanly.
218219

220+
`site_analytics_head_html` is the stable hook for built-in analytics integrations. In `v0.15`,
221+
Rustipo supports opt-in Plausible analytics via:
222+
223+
```toml
224+
[site.analytics.plausible]
225+
domain = "docs.example.com"
226+
# Optional for self-hosted Plausible:
227+
# script_src = "https://stats.example.com/js/script.js"
228+
```
229+
230+
When present, Rustipo renders a ready-to-include head snippet. Themes can inherit the built-in
231+
head partial behavior or explicitly render:
232+
233+
```html
234+
{% if site_analytics_head_html %}
235+
{{ site_analytics_head_html | safe }}
236+
{% endif %}
237+
```
238+
219239
Rustipo also registers small Tera helpers for theme authors:
220240

221241
- `slugify` filter

‎docs/theme-tera.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Rustipo injects common values such as:
7878
- `site_title`
7979
- `site_description`
8080
- `site_asset_version`
81+
- `site_analytics_head_html`
8182
- `site_taxonomies`
8283
- `site_style.*`
8384

@@ -88,6 +89,19 @@ Rustipo injects common values such as:
8889

8990
If both are empty, `page_description` is omitted.
9091

92+
`site_analytics_head_html` is the stable convenience value for built-in analytics output. In
93+
`v0.15`, Rustipo supports opt-in Plausible configuration from `config.toml`:
94+
95+
```toml
96+
[site.analytics.plausible]
97+
domain = "docs.example.com"
98+
# Optional for self-hosted Plausible:
99+
# script_src = "https://stats.example.com/js/script.js"
100+
```
101+
102+
When configured, `site_analytics_head_html` contains a ready-to-render `<script defer ...>`
103+
snippet. Built-in themes already include it in their shared head partials.
104+
91105
Rustipo also injects stable navigation and page-state values:
92106

93107
- `page_kind`

‎site/content/reference/cli.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ order: 1
88

99
Rustipo currently centers on a small CLI surface that covers the full authoring loop.
1010

11+
## Config-Driven Extras
12+
13+
### Analytics
14+
15+
Rustipo supports opt-in Plausible analytics from `config.toml`:
16+
17+
```toml
18+
[site.analytics.plausible]
19+
domain = "docs.example.com"
20+
# Optional for self-hosted Plausible:
21+
# script_src = "https://stats.example.com/js/script.js"
22+
```
23+
24+
Built-in themes render that snippet automatically through their shared head partials.
25+
1126
## Core Commands
1227

1328
### `rustipo new <site-name>`

‎src/commands/new/scaffold.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ pub const HEAD_ASSETS_PARTIAL: &str = r#"{% if site_favicon_svg %}<link rel="ico
107107
{{ site_font_faces_css | safe }}
108108
</style>
109109
{% endif %}
110+
{% if site_analytics_head_html %}
111+
{{ site_analytics_head_html | safe }}
112+
{% endif %}
110113
<link rel="stylesheet" href="{{ asset_url(path='style.css') }}?v={{ site_asset_version }}" />
111114
<link rel="stylesheet" href="{{ asset_url(path='palette.css') }}?v={{ site_asset_version }}" />
112115
{% if site_has_custom_css %}

0 commit comments

Comments
 (0)