Skip to content

Commit 73c1ced

Browse files
committed
feat(docs-site): add centralized version variable system
Add a version management system to acton-docs-site matching the pattern from acton-service/acton-docs. This enables displaying the package version in the logo and using Markdoc variables for dependency strings. - Add src/lib/version.ts as single source of truth for VERSION - Add src/lib/config.ts for site configuration (repository URLs) - Add src/markdoc/config.js with version variables ($version.acton, $dep.ipc, $dep.ipcMessagepack) - Update Logo.tsx to display version next to package name - Update nodes.js fence transform to substitute variables in code blocks - Update FAQ and IPC setup docs to use version variables
1 parent 5624ae3 commit 73c1ced

File tree

7 files changed

+122
-5
lines changed

7 files changed

+122
-5
lines changed

acton-docs-site/src/app/docs/faq/page.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Yes! Enable the `ipc` feature and use Unix Domain Sockets:
7878

7979
```toml
8080
[dependencies]
81-
acton-reactive = { version = "0.1", features = ["ipc"] }
81+
{% $dep.ipc %}
8282
```
8383

8484
See the [IPC Communication](/docs/ipc) guide for details.
@@ -401,7 +401,7 @@ If you're using IPC heavily, MessagePack is faster and smaller than JSON:
401401

402402
```toml
403403
[dependencies]
404-
acton-reactive = { version = "0.1", features = ["ipc-messagepack"] }
404+
{% $dep.ipcMessagepack %}
405405
```
406406

407407
---

acton-docs-site/src/app/docs/ipc-setup/page.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ Add the `ipc` feature to your `Cargo.toml`:
6464

6565
```toml
6666
[dependencies]
67-
acton-reactive = { version = "0.1", features = ["ipc"] }
67+
{% $dep.ipc %}
6868
```
6969

7070
For MessagePack serialization (smaller messages):
7171

7272
```toml
7373
[dependencies]
74-
acton-reactive = { version = "0.1", features = ["ipc-messagepack"] }
74+
{% $dep.ipcMessagepack %}
7575
```
7676

7777
### Feature Comparison

acton-docs-site/src/components/Logo.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { VERSION } from '@/lib/version'
2+
13
function LogomarkPaths() {
24
return (
35
<g fill="none" stroke="#38BDF8" strokeLinejoin="round" strokeWidth={2}>
@@ -19,7 +21,7 @@ export function Logomark(props: React.ComponentPropsWithoutRef<'svg'>) {
1921

2022
export function Logo(props: React.ComponentPropsWithoutRef<'svg'>) {
2123
return (
22-
<svg aria-hidden="true" viewBox="0 0 200 36" fill="none" {...props}>
24+
<svg aria-hidden="true" viewBox="0 0 260 36" fill="none" {...props}>
2325
<LogomarkPaths />
2426
<text
2527
x="40"
@@ -32,6 +34,17 @@ export function Logo(props: React.ComponentPropsWithoutRef<'svg'>) {
3234
>
3335
acton-reactive
3436
</text>
37+
<text
38+
x="180"
39+
y="24"
40+
fill="currentColor"
41+
fontFamily="ui-sans-serif, system-ui, sans-serif"
42+
fontSize="14"
43+
fontWeight="400"
44+
opacity="0.6"
45+
>
46+
v{VERSION}
47+
</text>
3548
</svg>
3649
)
3750
}

acton-docs-site/src/lib/config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Centralized configuration for site-wide constants
3+
* This ensures DRY principle by having a single source of truth
4+
*/
5+
6+
export const siteConfig = {
7+
/**
8+
* GitHub repository URL
9+
* Used in: header links, hero CTA buttons, documentation links
10+
*/
11+
repositoryUrl: 'https://github.com/govcraft/acton-reactive',
12+
13+
/**
14+
* Repository name (derived from URL)
15+
*/
16+
repositoryName: 'govcraft/acton-reactive',
17+
} as const

acton-docs-site/src/lib/version.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* Version information for acton-reactive
3+
* This should match the version in the root Cargo.toml workspace.package.version
4+
*/
5+
export const VERSION = '0.7.0'
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import nodes from './nodes.js'
2+
import tags from './tags.js'
3+
import { siteConfig } from '../lib/config'
4+
5+
// Extract version from workspace Cargo.toml
6+
// This should be kept in sync with the workspace version
7+
const ACTON_VERSION = '0.7.0'
8+
9+
// Helper function to build dependency string
10+
function buildDep(features) {
11+
return `acton-reactive = { version = "${ACTON_VERSION}", features = [${features.map(f => `"${f}"`).join(', ')}] }`
12+
}
13+
14+
const config = {
15+
nodes,
16+
tags,
17+
functions: {
18+
// Markdoc function to build cargo dependency with current version
19+
dep: {
20+
transform(parameters) {
21+
const features = parameters[0] || []
22+
if (typeof features === 'string') {
23+
return `acton-reactive = { version = "${ACTON_VERSION}", features = ["${features}"] }`
24+
}
25+
return buildDep(features)
26+
}
27+
},
28+
// Function to build GitHub URLs
29+
githubUrl: {
30+
transform(parameters) {
31+
const path = parameters[0] || ''
32+
return siteConfig.repositoryUrl + path
33+
}
34+
}
35+
},
36+
variables: {
37+
version: {
38+
acton: ACTON_VERSION,
39+
},
40+
github: {
41+
repositoryUrl: siteConfig.repositoryUrl,
42+
repositoryName: siteConfig.repositoryName,
43+
},
44+
dep: {
45+
base: `acton-reactive = "${ACTON_VERSION}"`,
46+
ipc: `acton-reactive = { version = "${ACTON_VERSION}", features = ["ipc"] }`,
47+
ipcMessagepack: `acton-reactive = { version = "${ACTON_VERSION}", features = ["ipc-messagepack"] }`,
48+
},
49+
},
50+
}
51+
52+
export default config

acton-docs-site/src/markdoc/nodes.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,36 @@ const nodes = {
5656
language: {
5757
type: String,
5858
},
59+
content: {
60+
type: String,
61+
},
62+
},
63+
transform(node, config) {
64+
const attributes = node.transformAttributes(config)
65+
const children = node.children[0]
66+
67+
// Get the fence content
68+
let content = children?.attributes?.content || ''
69+
70+
// Replace {% $variable.path %} with actual values from config.variables
71+
if (config.variables) {
72+
content = content.replace(/\{%\s*\$([a-zA-Z0-9._]+)\s*%\}/g, (match, path) => {
73+
const parts = path.split('.')
74+
let value = config.variables
75+
76+
for (const part of parts) {
77+
if (value && typeof value === 'object') {
78+
value = value[part]
79+
} else {
80+
return match // Return original if path not found
81+
}
82+
}
83+
84+
return value !== undefined ? String(value) : match
85+
})
86+
}
87+
88+
return new Tag(this.render, attributes, [content])
5989
},
6090
},
6191
}

0 commit comments

Comments
 (0)