@eox/pages-theme-eox 2.0.0-alpha.6 → 2.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,6 +21,45 @@ See also the [Vitepress Docs](https://vitepress.dev/guide/custom-theme#consuming
21
21
 
22
22
  This theme supports standard [VitePress Default Theme Configuration](https://vitepress.dev/reference/default-theme-config) with some specific adaptations.
23
23
 
24
+ ### LLMs Configuration (`llms.txt`)
25
+
26
+ This theme integrates [vitepress-plugin-llms](https://github.com/nmoodev/vitepress-plugin-llms) to automatically generate AI-friendly documentation (`llms.txt` and `llms-full.txt`), along with custom support for VitePress story routes and remote story manifests.
27
+
28
+ Generation is enabled by default. You can configure options via `brandConfig.llms` in your brand configuration:
29
+
30
+ ```javascript
31
+ // Example brandConfig:
32
+ export const config = {
33
+ // ... other brand settings ...
34
+ llms: {
35
+ // Upstream vitepress-plugin-llms options
36
+ domain: "https://yourdomain.com", // Base URL to resolve absolute links in llms.txt
37
+ copyButtons: true, // (Optional) Adds copy buttons to code blocks in documentation
38
+
39
+ // Theme-specific Story Routes config
40
+ stories: {
41
+ heading: "Stories", // (Optional) Heading used in llms.txt and route pages (default: "Stories")
42
+ path: "narratives/[narrative]", // (Optional) Story route pattern (e.g. "narratives/[narrative]" or "story"). Also accepts `storyPath`
43
+ manifest: "https://cdn.example.com/narratives.json", // (Optional) URL to stories manifest (auto-detected from gallery components if omitted)
44
+ concurrency: 8, // (Optional) Maximum concurrent story downloads (default: 8)
45
+ },
46
+ },
47
+ };
48
+ ```
49
+
50
+ #### Disabling LLMs
51
+
52
+ - To disable LLM documentation generation entirely: set `llms: false`.
53
+ - To generate general docs without stories: set `stories: false` inside `llms`:
54
+
55
+ ```javascript
56
+ export const config = {
57
+ llms: {
58
+ stories: false,
59
+ },
60
+ };
61
+ ```
62
+
24
63
  ### Navigation Bar
25
64
 
26
65
  The Navigation Bar follows the [Default Theme Nav](https://vitepress.dev/reference/default-theme-nav) structure with the following differences:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eox/pages-theme-eox",
3
- "version": "2.0.0-alpha.6",
3
+ "version": "2.0.0-alpha.7",
4
4
  "type": "module",
5
5
  "description": "Vitepress Theme with EOX branding",
6
6
  "main": "src/index.js",
@@ -13,7 +13,7 @@
13
13
  "format": "npx prettier --write .",
14
14
  "format:check": "npx prettier --check .",
15
15
  "test": "npm run test:unit && npm run test:component",
16
- "test:unit": "node --test src/helpers.test.js",
16
+ "test:unit": "node --test src/helpers.test.js src/llms/llms.test.js",
17
17
  "test:component": "cypress run --component",
18
18
  "release": "release-it"
19
19
  },
@@ -21,7 +21,8 @@
21
21
  "@eox/eslint-config": "^2.0.0",
22
22
  "@eox/feedback": "^1.1.1",
23
23
  "@eox/ui": "^1.0.1",
24
- "vitepress": "^1.6.3"
24
+ "vitepress": "^1.6.3",
25
+ "vitepress-plugin-llms": "^1.13.5"
25
26
  },
26
27
  "devDependencies": {
27
28
  "@release-it/conventional-changelog": "^10.0.6",
@@ -0,0 +1,64 @@
1
+ import llmstxt from "vitepress-plugin-llms";
2
+ import { createStoriesPlugin } from "./storiesPlugin.js";
3
+
4
+ const LLMS_DEFAULTS = {};
5
+
6
+ /**
7
+ * Normalizes a URL by stripping trailing slashes.
8
+ * @param {string | undefined | null} url
9
+ * @returns {string | null}
10
+ */
11
+ export const normalizeDomain = (url) => {
12
+ if (!url || typeof url !== "string") return null;
13
+ return url.replace(/\/+$/, "");
14
+ };
15
+
16
+ /**
17
+ * Resolve the llms option into Vite plugins and package-owned flags.
18
+ * @param {boolean | Record<string, any>} [option] The `llms` option
19
+ * @param {Record<string, any>} [brandConfig] Brand configuration object
20
+ * @returns {{ plugins: any[], copyButtons: boolean, stories: any, domain: string | null }}
21
+ */
22
+ export const resolveLlms = (option, brandConfig = {}) => {
23
+ if (option === false) {
24
+ return {
25
+ plugins: [],
26
+ copyButtons: false,
27
+ stories: null,
28
+ domain: null,
29
+ };
30
+ }
31
+
32
+ const {
33
+ copyButtons = false,
34
+ stories = null,
35
+ ...settings
36
+ } = option === true || option === undefined ? {} : option;
37
+
38
+ const rawDomain = settings.domain;
39
+ const domain = normalizeDomain(rawDomain);
40
+
41
+ const upstreamPlugins = llmstxt({
42
+ ...LLMS_DEFAULTS,
43
+ ...settings,
44
+ ...(domain ? { domain } : {}),
45
+ });
46
+
47
+ const plugins = [...upstreamPlugins];
48
+ if (stories !== false) {
49
+ plugins.push(
50
+ createStoriesPlugin({
51
+ storiesOption: stories,
52
+ brandConfig,
53
+ domain,
54
+ }),
55
+ );
56
+ }
57
+
58
+ return {
59
+ plugins,
60
+ copyButtons: Boolean(copyButtons),
61
+ stories,
62
+ domain,
63
+ };
64
+ };