@stackql/docusaurus-plugin-aeo 0.2.0 → 0.3.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0
4
+
5
+ Focused UX upgrade to the Ask AI button (feature 3). No changes to features 1, 2, or 4.
6
+
7
+ ### Changed (breaking)
8
+
9
+ - Default Ask AI button placement moved from doc / blog footer to the breadcrumb row at the top of each page. On doc pages the button sits right-aligned in the breadcrumb row; on blog posts (which have no breadcrumbs) it sits right-aligned above the post title.
10
+ - `askAi.placement` no longer accepts `'doc-footer'`. Valid values are `'breadcrumb-row'` (the new default) and `'none'`. The v0.1.x-v0.2.x `DocItem/Footer` and `BlogPostItem/Footer` swizzles have been deleted; there is no config flag that restores them. Consumers who want footer placement (or any other custom location) should set `askAi.placement: 'none'` and swizzle `@theme/AskAiButton` manually.
11
+ - Ask AI button restyled as a solid pill dropdown (themed background, rounded-full corners, animated caret). The trigger reads "Ask AI about this page". The menu is a right-aligned card with rounded corners and a subtle shadow.
12
+
13
+ ### Changed
14
+
15
+ - Provider icons replaced with real brand SVGs sourced from [simple-icons](https://simpleicons.org) where available - Claude, Perplexity, Gemini. OpenAI / ChatGPT was removed from simple-icons in 2024 following a takedown; the ChatGPT menu row renders a neutral chat-bubble glyph instead. No build failure; the missing icon is logged as a warning when verbose.
16
+
17
+ ### Added
18
+
19
+ - `simple-icons` (`^16.22.0`, CC0-1.0) as a runtime dependency. Bundle-size impact is bounded by webpack tree-shaking: the icons module uses named ESM imports so only the three referenced icons end up in the production bundle.
20
+
21
+ Even though placement changes are breaking, this is 0.3.0 (not 1.0.0) - the project is still pre-1.0 and the README never promised a stable placement option set.
22
+
23
+ ### Migration
24
+
25
+ Bump the plugin version. If `askAi.placement: 'doc-footer'` is set in plugin options, remove it (or change it to `'breadcrumb-row'` for explicitness). No other config changes needed. After rebuild, the button appears at the top of each doc and blog page.
26
+
3
27
  ## 0.2.0
4
28
 
5
29
  - Added: `llmsTxt.instanceSections` option for per-content-plugin-instance llms.txt section grouping. Use case: consumers with multiple content-docs instances (e.g. human docs + AI reference) can split them into named sections. Map keys are `"${pluginName}@${pluginId}"`; values are `{ title, order? }`. Unmapped instances are collected into a single appended "Other" section. `llms-full.txt` mirrors the same section structure as `llms.txt`.
package/README.md CHANGED
@@ -170,7 +170,12 @@ Behavior:
170
170
 
171
171
  ## Feature 3: "Ask AI" button
172
172
 
173
- A swizzle-friendly dropdown is injected above the existing `DocItem/Footer` and `BlogPostItem/Footer`. Each item opens the corresponding AI surface in a new tab with a prefilled prompt that references the current page's `.md` companion.
173
+ A solid pill dropdown reading "Ask AI about this page" is injected at the top of every doc and blog-post content area, right-aligned in the breadcrumb row. Each item in the dropdown opens the corresponding AI surface in a new tab with a prefilled prompt that references the current page's `.md` companion.
174
+
175
+ Placement specifics:
176
+
177
+ - **Doc pages** - the button sits on the same row as the breadcrumb trail, flex-aligned to the right edge of the content area.
178
+ - **Blog posts** - blog posts have no breadcrumbs, so the button sits at the very top of the post, right-aligned above the post title (the closest visual equivalent to the docs breadcrumb-row position).
174
179
 
175
180
  Providers and URL patterns:
176
181
 
@@ -189,6 +194,10 @@ Read https://your-site.example/path/to/page.md and help me with the following qu
189
194
 
190
195
  The trailing space is intentional - the cursor lands ready for the user to type.
191
196
 
197
+ Provider icons are real brand SVGs sourced from [simple-icons](https://simpleicons.org). Three of four (Claude, Perplexity, Gemini) come from the upstream catalog directly. OpenAI / ChatGPT was removed from simple-icons in 2024 following a takedown, so the ChatGPT row shows a neutral chat-bubble glyph as a placeholder.
198
+
199
+ **Trademark note.** Brand logos are trademarks of their respective owners; their inclusion via simple-icons does not imply endorsement. Consumers using the Ask AI button in commercial contexts should review each provider's brand-usage policy.
200
+
192
201
  Options:
193
202
 
194
203
  | Option | Default | Description |
@@ -196,17 +205,19 @@ Options:
196
205
  | `askAi.enabled` | `true` | When `false`, the theme components are not registered. |
197
206
  | `askAi.providerOrder` | `['claude', 'chatgpt', 'perplexity', 'gemini']` | Order of items in the dropdown. Drop entries to hide them. |
198
207
  | `askAi.promptTemplate` | `'Read {pageUrl}.md and help me with the following question about it: '` | Prompt sent to each provider. `{pageUrl}` is the page's canonical URL (no trailing slash). If feature 1 is disabled, the consumer should remove the `.md` from the template. |
199
- | `askAi.placement` | `'doc-footer'` | `'doc-footer'` injects above doc and blog footers. `'none'` does not register any theme components - swizzle manually if you want to place the button elsewhere. |
208
+ | `askAi.placement` | `'breadcrumb-row'` | `'breadcrumb-row'` puts the button at the top of every doc/blog page (docs breadcrumb row, or above the blog title). `'none'` does not register any theme components - swizzle the button into your preferred location manually. |
200
209
 
201
- Styling uses CSS modules and reads from Docusaurus's theme tokens (`--ifm-color-primary`, etc.) so dark/light mode work automatically.
210
+ Styling uses CSS modules and reads from Docusaurus's theme tokens (`--ifm-color-primary`, `--ifm-color-primary-darker`, `--ifm-color-emphasis-300`, etc.) so dark/light mode work automatically without extra rules.
202
211
 
203
- Swizzle to move the button:
212
+ ### Customizing placement
204
213
 
205
- ```bash
206
- npm run swizzle @stackql/docusaurus-plugin-aeo AskAiButton -- --wrap
214
+ To put the button somewhere other than the breadcrumb row - sidebar, header, a specific page region - set `askAi.placement: 'none'` to disable the bundled swizzles, then import and place the component manually wherever you want:
215
+
216
+ ```jsx
217
+ import AskAiButton from '@theme/AskAiButton';
207
218
  ```
208
219
 
209
- The component lives at `@theme/AskAiButton`. Import and place it wherever you want.
220
+ Wrap an existing theme component (e.g. `@theme/Layout`) the same way Docusaurus documents for any swizzle.
210
221
 
211
222
  ## Feature 4: `/ai/*` routing convention
212
223
 
@@ -342,7 +353,7 @@ The `sitemapExclude` helper, by contrast, does work with globs because `@docusau
342
353
  enabled: true,
343
354
  providerOrder: ['claude', 'chatgpt', 'perplexity', 'gemini'],
344
355
  promptTemplate: 'Read {pageUrl}.md and help me with the following question about it: ',
345
- placement: 'doc-footer', // 'doc-footer' | 'none'
356
+ placement: 'breadcrumb-row', // 'breadcrumb-row' | 'none'
346
357
  },
347
358
 
348
359
  // Feature 4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackql/docusaurus-plugin-aeo",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "AEO (Answer Engine Optimization) helpers for Docusaurus: .md companion files, llms.txt / llms-full.txt, an Ask AI dropdown, and /ai/* route conventions.",
5
5
  "main": "src/index.js",
6
6
  "exports": {
@@ -25,7 +25,8 @@
25
25
  "react-dom": "^18.0.0 || ^19.0.0"
26
26
  },
27
27
  "dependencies": {
28
- "gray-matter": "^4.0.3"
28
+ "gray-matter": "^4.0.3",
29
+ "simple-icons": "^16.22.0"
29
30
  },
30
31
  "overrides": {
31
32
  "serialize-javascript": "^7.0.5",
package/src/index.js CHANGED
@@ -51,7 +51,7 @@ function normalizeOptions(raw) {
51
51
  enabled: askAi.enabled !== false,
52
52
  providerOrder: askAi.providerOrder || DEFAULT_PROVIDER_ORDER,
53
53
  promptTemplate: askAi.promptTemplate || DEFAULT_PROMPT_TEMPLATE,
54
- placement: askAi.placement || 'doc-footer',
54
+ placement: askAi.placement || 'breadcrumb-row',
55
55
  },
56
56
  aiRoutes: {
57
57
  validate: aiRoutes.validate === true,
@@ -126,9 +126,12 @@ function validateOptions(opts) {
126
126
  if (typeof opts.askAi.promptTemplate !== 'string') {
127
127
  errs.push('askAi.promptTemplate must be a string');
128
128
  }
129
- if (!['doc-footer', 'none'].includes(opts.askAi.placement)) {
129
+ if (!['breadcrumb-row', 'none'].includes(opts.askAi.placement)) {
130
+ // 'doc-footer' was the v0.1.x-v0.2.x default and is no longer
131
+ // accepted in v0.3.0. The wrappers that implemented it have been
132
+ // removed. See CHANGELOG for migration notes.
130
133
  errs.push(
131
- `askAi.placement must be "doc-footer" or "none", got "${opts.askAi.placement}"`,
134
+ `askAi.placement must be "breadcrumb-row" or "none", got "${opts.askAi.placement}"`,
132
135
  );
133
136
  }
134
137
 
@@ -1,55 +1,72 @@
1
- // Hand-rolled minimal SVGs for the four supported AI providers. Glyphs only;
2
- // outer wrapper supplies size and color. Using `currentColor` so the icon
3
- // inherits theme colors via CSS.
1
+ // Brand icons for the four supported AI providers.
2
+ //
3
+ // Three of four come from simple-icons (siClaude, siPerplexity,
4
+ // siGooglegemini). OpenAI / ChatGPT was removed from simple-icons in
5
+ // 2024 following a takedown, so for that one we ship a neutral inline
6
+ // chat-bubble glyph. The same fallback path is reused for any future
7
+ // icon that disappears from upstream.
8
+ //
9
+ // All icons render as a 24x24 viewBox SVG with `fill="currentColor"`,
10
+ // so the menu CSS can size them via font-size or width/height and tint
11
+ // them via the surrounding text color. ESM `import` is used so webpack
12
+ // can tree-shake unused simple-icons exports out of the bundle.
4
13
 
5
- const React = require('react');
14
+ import React from 'react';
15
+ import { siClaude, siPerplexity, siGooglegemini } from 'simple-icons';
6
16
 
7
- function svg(children, viewBox = '0 0 24 24') {
17
+ function svg(children) {
8
18
  return React.createElement(
9
19
  'svg',
10
20
  {
11
21
  xmlns: 'http://www.w3.org/2000/svg',
12
22
  width: '1em',
13
23
  height: '1em',
14
- viewBox,
24
+ viewBox: '0 0 24 24',
15
25
  fill: 'currentColor',
26
+ role: 'img',
16
27
  'aria-hidden': 'true',
17
28
  },
18
29
  children,
19
30
  );
20
31
  }
21
32
 
22
- const ClaudeIcon = () =>
23
- svg(
24
- React.createElement('path', {
25
- d: 'M5.5 17.5 9.6 6.6h2.6l4.1 10.9h-2.4l-.9-2.5h-3.9l-.9 2.5H5.5Zm4.6-4.5h2.8l-1.4-4-1.4 4Zm6.4 4.5V6.6h2.2v10.9h-2.2Z',
26
- }),
27
- );
33
+ function fromSimpleIcons(si) {
34
+ if (!si || typeof si.path !== 'string') {
35
+ return GenericAiIcon;
36
+ }
37
+ return function BrandIcon() {
38
+ return svg(React.createElement('path', { d: si.path }));
39
+ };
40
+ }
28
41
 
29
- const ChatGptIcon = () =>
30
- svg(
42
+ // Neutral chat-bubble glyph - used when a brand icon isn't available
43
+ // upstream. Not a brand mark, no trademark concerns.
44
+ function GenericAiIcon() {
45
+ return svg(
31
46
  React.createElement('path', {
32
- d: 'M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2Zm4.6 12.4-3.9 2.3a1.5 1.5 0 0 1-1.4 0L7.4 14.4a1.5 1.5 0 0 1-.7-1.3V8.6a1.5 1.5 0 0 1 .7-1.3l3.9-2.3a1.5 1.5 0 0 1 1.4 0l3.9 2.3a1.5 1.5 0 0 1 .7 1.3v4.5a1.5 1.5 0 0 1-.7 1.3ZM12 8.5l-3.2 1.8v3.4L12 15.5l3.2-1.8v-3.4Z',
47
+ d: 'M4 4h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-8l-5 4v-4H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Zm3 6h2v2H7v-2Zm4 0h2v2h-2v-2Zm4 0h2v2h-2v-2Z',
33
48
  }),
34
49
  );
50
+ }
35
51
 
36
- const PerplexityIcon = () =>
37
- svg(
38
- React.createElement('path', {
39
- d: 'M12 2 3 7v10l9 5 9-5V7l-9-5Zm0 2.3 6.7 3.7L12 11.7 5.3 8 12 4.3ZM5 9.7l6 3.3v6.6l-6-3.3V9.7Zm14 0v6.6l-6 3.3V13l6-3.3Z',
40
- }),
41
- );
52
+ const icons = {
53
+ claude: fromSimpleIcons(siClaude),
54
+ // simple-icons dropped OpenAI/ChatGPT in 2024; fall back to a neutral
55
+ // chat-bubble glyph rather than failing the build or shipping a guess
56
+ // at the wordmark.
57
+ chatgpt: GenericAiIcon,
58
+ perplexity: fromSimpleIcons(siPerplexity),
59
+ gemini: fromSimpleIcons(siGooglegemini),
60
+ };
42
61
 
43
- const GeminiIcon = () =>
44
- svg(
45
- React.createElement('path', {
46
- d: 'M12 2 9.5 9.5 2 12l7.5 2.5L12 22l2.5-7.5L22 12l-7.5-2.5L12 2Z',
47
- }),
48
- );
62
+ if (typeof console !== 'undefined') {
63
+ for (const [name, icon] of Object.entries(icons)) {
64
+ if (icon === GenericAiIcon && name !== 'chatgpt') {
65
+ console.warn(
66
+ `[plugin-aeo] AskAiButton: brand icon for "${name}" missing from simple-icons; using generic AI glyph`,
67
+ );
68
+ }
69
+ }
70
+ }
49
71
 
50
- module.exports = {
51
- claude: ClaudeIcon,
52
- chatgpt: ChatGptIcon,
53
- perplexity: PerplexityIcon,
54
- gemini: GeminiIcon,
55
- };
72
+ export default icons;
@@ -81,7 +81,21 @@ export default function AskAiButton(props) {
81
81
  onClick={toggle}
82
82
  >
83
83
  <span>Ask AI about this page</span>
84
- <span className={styles.caret}>{open ? '▲' : '▼'}</span>
84
+ <span
85
+ className={`${styles.caret}${open ? ` ${styles.caretOpen}` : ''}`}
86
+ aria-hidden="true"
87
+ >
88
+ {/* Inline chevron-down so we don't depend on a font glyph. */}
89
+ <svg
90
+ xmlns="http://www.w3.org/2000/svg"
91
+ width="0.75em"
92
+ height="0.75em"
93
+ viewBox="0 0 24 24"
94
+ fill="currentColor"
95
+ >
96
+ <path d="M6 9l6 6 6-6H6z" />
97
+ </svg>
98
+ </span>
85
99
  </button>
86
100
  {open && (
87
101
  <ul className={styles.menu} role="menu">
@@ -1,50 +1,58 @@
1
1
  .wrapper {
2
2
  position: relative;
3
3
  display: inline-block;
4
- margin: 1.5rem 0;
5
4
  }
6
5
 
7
6
  .trigger {
8
7
  display: inline-flex;
9
8
  align-items: center;
10
9
  gap: 0.5rem;
11
- padding: 0.5rem 1rem;
10
+ padding: 0.4rem 0.9rem;
12
11
  background: var(--ifm-color-primary);
13
12
  color: var(--ifm-color-primary-contrast-foreground, #fff);
14
- border: 1px solid var(--ifm-color-primary-dark);
15
- border-radius: var(--ifm-button-border-radius, 0.4rem);
16
- font: inherit;
17
- font-weight: 600;
13
+ border: none;
14
+ border-radius: 999px;
15
+ font-size: 0.875rem;
16
+ font-weight: 500;
17
+ line-height: 1.2;
18
18
  cursor: pointer;
19
- transition: background-color 0.15s ease, transform 0.05s ease;
19
+ white-space: nowrap;
20
+ transition: background-color 0.15s ease;
20
21
  }
21
22
 
22
23
  .trigger:hover {
23
- background: var(--ifm-color-primary-dark);
24
+ background: var(--ifm-color-primary-darker, var(--ifm-color-primary-dark));
24
25
  }
25
26
 
26
- .trigger:active {
27
- transform: translateY(1px);
27
+ .trigger:focus-visible {
28
+ outline: 2px solid var(--ifm-color-primary-light, currentColor);
29
+ outline-offset: 2px;
28
30
  }
29
31
 
30
32
  .caret {
33
+ display: inline-block;
31
34
  font-size: 0.7em;
32
- opacity: 0.85;
35
+ opacity: 0.9;
36
+ transition: transform 0.15s ease;
37
+ }
38
+
39
+ .caretOpen {
40
+ transform: rotate(180deg);
33
41
  }
34
42
 
35
43
  .menu {
36
44
  position: absolute;
37
- top: calc(100% + 0.25rem);
38
- left: 0;
39
- z-index: 50;
40
- min-width: 12rem;
45
+ top: calc(100% + 0.4rem);
46
+ right: 0;
47
+ z-index: 100;
48
+ min-width: 200px;
41
49
  margin: 0;
42
50
  padding: 0.25rem 0;
43
51
  list-style: none;
44
52
  background: var(--ifm-background-surface-color, var(--ifm-background-color));
45
53
  border: 1px solid var(--ifm-color-emphasis-300);
46
- border-radius: var(--ifm-button-border-radius, 0.4rem);
47
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
54
+ border-radius: 0.5rem;
55
+ box-shadow: 0 6px 24px -8px rgba(0, 0, 0, 0.18);
48
56
  }
49
57
 
50
58
  .item {
@@ -54,21 +62,26 @@
54
62
  .itemLink {
55
63
  display: flex;
56
64
  align-items: center;
57
- gap: 0.6rem;
65
+ gap: 0.65rem;
58
66
  padding: 0.5rem 0.85rem;
59
- color: var(--ifm-font-color-base);
67
+ color: var(--ifm-color-content, var(--ifm-font-color-base));
60
68
  text-decoration: none;
61
- font-size: 0.95em;
69
+ font-size: 0.875rem;
62
70
  }
63
71
 
64
72
  .itemLink:hover {
65
73
  background: var(--ifm-color-emphasis-100);
74
+ color: var(--ifm-color-content, var(--ifm-font-color-base));
66
75
  text-decoration: none;
67
76
  }
68
77
 
69
78
  .icon {
70
79
  display: inline-flex;
71
80
  align-items: center;
72
- font-size: 1.1em;
73
- color: var(--ifm-color-primary);
81
+ justify-content: center;
82
+ width: 18px;
83
+ height: 18px;
84
+ font-size: 18px;
85
+ color: var(--ifm-color-content, var(--ifm-font-color-base));
86
+ flex: 0 0 auto;
74
87
  }
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import Title from '@theme-init/BlogPostItem/Header/Title';
3
+ import AskAiButton from '@theme/AskAiButton';
4
+ import styles from './styles.module.css';
5
+
6
+ // Mirror the docs breadcrumb-row placement: render a flex row above the
7
+ // post title with the Ask AI button right-aligned. Blog posts have no
8
+ // breadcrumbs, so the title block is the closest visual analog to the
9
+ // docs "above the H1, top of content" position.
10
+ export default function TitleWrapper(props) {
11
+ return (
12
+ <>
13
+ <div className={styles.row}>
14
+ <AskAiButton />
15
+ </div>
16
+ <Title {...props} />
17
+ </>
18
+ );
19
+ }
@@ -0,0 +1,8 @@
1
+ .row {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: flex-end;
5
+ flex-wrap: wrap;
6
+ gap: 0.75rem;
7
+ margin-bottom: 0.5rem;
8
+ }
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ // See note in the AskAiButton swizzle: @theme-init resolves to the
3
+ // initial component from the theme chain (theme-classic), avoiding the
4
+ // recursion that @theme-original produces when a plugin (not a theme)
5
+ // is the only contributor in the wrapper layer.
6
+ import DocBreadcrumbs from '@theme-init/DocBreadcrumbs';
7
+ import AskAiButton from '@theme/AskAiButton';
8
+ import styles from './styles.module.css';
9
+
10
+ export default function DocBreadcrumbsWrapper(props) {
11
+ return (
12
+ <div className={styles.row}>
13
+ <DocBreadcrumbs {...props} />
14
+ <AskAiButton />
15
+ </div>
16
+ );
17
+ }
@@ -0,0 +1,8 @@
1
+ .row {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: space-between;
5
+ flex-wrap: wrap;
6
+ gap: 0.75rem;
7
+ margin-bottom: 1rem;
8
+ }
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- // See note in src/theme/DocItem/Footer/index.jsx - @theme-init avoids the
3
- // SSR recursion that @theme-original triggers when a plugin (not a theme)
4
- // contributes the wrapper.
5
- import Footer from '@theme-init/BlogPostItem/Footer';
6
- import AskAiButton from '@theme/AskAiButton';
7
-
8
- export default function FooterWrapper(props) {
9
- return (
10
- <>
11
- <AskAiButton />
12
- <Footer {...props} />
13
- </>
14
- );
15
- }
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- // Use @theme-init (the initial component from the theme chain, before any
3
- // wrappers) instead of @theme-original. When a plugin contributes both the
4
- // wrapper and is the only contributor in the wrapper layer,
5
- // @theme-original/X resolves back to this wrapper file and renders infinitely
6
- // on every SSR pass. @theme-init/X always resolves to the un-wrapped origin.
7
- import Footer from '@theme-init/DocItem/Footer';
8
- import AskAiButton from '@theme/AskAiButton';
9
-
10
- export default function FooterWrapper(props) {
11
- return (
12
- <>
13
- <AskAiButton />
14
- <Footer {...props} />
15
- </>
16
- );
17
- }