A "stackql-deploy Template" menu for the resource pages of StackQL provider sites built with Docusaurus 3.x. Download saves a stackql-deploy resource file (<resource>.iql) built from the page's SQL examples; Copy puts the same template on the clipboard. The menu sits at the right of the breadcrumb row, beside the "Ask AI about this page" button of @stackql/docusaurus-plugin-aeo, and is hidden on mobile viewports.
The plugin replaces the StackqlDeployDropdown component and DocBreadcrumbs swizzle that each provider site carried in src/ (see Migrating a provider site).
npm install @stackql/docusaurus-plugin-stackql-deploy-templateyarn add @stackql/docusaurus-plugin-stackql-deploy-template// docusaurus.config.js
module.exports = {
// ...
plugins: [
'@stackql/docusaurus-plugin-aeo',
// after the AEO plugin: see "Placement" below
'@stackql/docusaurus-plugin-stackql-deploy-template',
],
};The plugin shares the site's MUI installation. These peer dependencies are required: @docusaurus/core ^3.0.0, react and react-dom ^18.0.0 || ^19.0.0, @mui/material and @mui/icons-material ^5.0.0 || ^6.0.0 || ^7.0.0, @emotion/react and @emotion/styled ^11.0.0.
The menu reads the page's example sections when the reader picks an item, and builds one stackql-deploy anchor per operation the page documents, in the order stackql-deploy runs them:
| Anchor | Built from |
|---|---|
/*+ exists */ |
a count over the conditions of the SELECT example |
/*+ create */ |
the INSERT example |
/*+ update */ |
the UPDATE example, or the REPLACE example when there is no UPDATE |
/*+ statecheck, retries=5, retry_delay=10 */ |
a count where each column the INSERT sets equals its value, plus the SELECT conditions |
/*+ exports */ |
the columns of the SELECT example (without region) |
/*+ delete */ |
the DELETE example, or the delete tab of the lifecycle methods |
The SELECT example is the get (all properties) or get tab, else the section's first tab. The INSERT example is the All Properties or create tab, else the first tab (never the Manifest tab when either exists). A page with no SELECT example has no exists, statecheck or exports.
Two page formats are read:
- Pages generated by
@stackql/provider-utilsmark required parameters with-- requiredcomments and have no anchors in their examples. The generated queries (exists,statecheck,exports) keep only the required conditions, without the comments; the INSERT, UPDATE and DELETE examples are used as written, optional parameters included, behind the anchor the plugin adds. Remove the optional parameters you do not set. - The
awsccpages carry the anchors in their examples and no comments. An example that starts with an anchor keeps it, and every condition is kept.
In the statecheck, a column is compared with the value the INSERT example gives it ('{{ name }}' for a string, {{ size }} for a number), or with {{ column }} when the INSERT does not set it.
The template logic is in src/template.js (CommonJS, no browser APIs), exported as @stackql/docusaurus-plugin-stackql-deploy-template/template; src/extract.js reads the sections from the rendered page.
With the default placement: 'breadcrumb-row', the plugin provides the DocBreadcrumbs theme component: the breadcrumbs on the left and a group of page actions on the right. The group holds the Ask AI button (when the site has one) and, on a resource page, the template menu. On pages that are not resource pages the group holds the Ask AI button alone, in the same position as on stackql.io.
@stackql/docusaurus-plugin-aeo provides DocBreadcrumbs too (its own row with the Ask AI button). Docusaurus uses the theme component of the plugin loaded last, and a plugin's component can wrap only the original theme component, not another plugin's, so the two rows cannot be nested. This plugin therefore renders the AEO plugin's button in its own row and must load after it:
- list it after
@stackql/docusaurus-plugin-aeoinplugins, or underthemes(Docusaurus loadsthemesafterplugins); - the build fails with an error naming both plugins when it is listed before the AEO plugin (unless the AEO plugin's Ask AI button is disabled or has
placement: 'none').
The Ask AI button is the site's @theme/AskAiButton component, from the AEO plugin or a site swizzle; with askAi: 'auto' and no such component the group has the template menu only.
A site-level src/theme/DocBreadcrumbs override takes precedence over both plugins. Remove it (see below), or render @theme/StackqlDeployTemplate in it yourself.
- The menu renders only on resource pages: routes matching
resourceRoute(default/services/<service>/<resource>), whose last segment names the downloaded file. - It is hidden below 997px, the Docusaurus desktop breakpoint (the Ask AI button uses the same one): a downloaded
.iqlfile is of little use on a phone or tablet.showOnMobile: trueshows it on every viewport.
| Option | Default | Description |
|---|---|---|
placement |
'breadcrumb-row' |
'breadcrumb-row': the menu in the breadcrumb row as above. 'none': the plugin registers no theme components (no menu, no DocBreadcrumbs override). |
askAi |
'auto' |
'auto': the Ask AI button in the row when @theme/AskAiButton exists. true: the same, and the build fails when it does not. false: never. |
showOnMobile |
false |
Show the menu below 997px. |
resourceRoute |
'/services/[^/]+/([^/]+)' |
Regular expression (source string) a resource page's route matches; the first capture group is the resource name, used for the file name. |
plugins: [
'@stackql/docusaurus-plugin-aeo',
['@stackql/docusaurus-plugin-stackql-deploy-template', { showOnMobile: false }],
],The visible strings go through translate(), so docusaurus write-translations extracts them into i18n/<locale>/code.json:
| id | Default |
|---|---|
stackqlDeployTemplate.button |
stackql-deploy Template |
stackqlDeployTemplate.download |
Download |
stackqlDeployTemplate.copy |
Copy |
stackqlDeployTemplate.copied |
Copied! |
In the site's website/ directory:
- Delete
src/components/StackqlDeployDropdown/andsrc/theme/DocBreadcrumbs/. - Delete the
.breadcrumbs-with-actionsrules fromsrc/css/global.css. - Add the dependency (
yarn add @stackql/docusaurus-plugin-stackql-deploy-template) and list the plugin after@stackql/docusaurus-plugin-aeoindocusaurus.config.js. yarn build, then check a resource page: the Ask AI button and the template menu at the right of the breadcrumb row on a desktop viewport, neither on a mobile one.
npm test runs every test/*.test.js file with Node's test runner: the template for both page formats (test/template.test.js, including the awscc template the site component built, as a fixture), section extraction against a minimal DOM (test/extract.test.js), options and the plugin order check (test/options.test.js), and the theme components rendered in Node (test/theme.test.js). There are no dev dependencies: the tests use the peer dependencies and the Babel setup that comes with @docusaurus/core.
MIT