Skip to content

Commit dbb7ad8

Browse files
committed
feat(docs): add Foundation; group it and Query Filters under Libraries
- Add GravityKit/Foundation as a documented product (scanned from src/) - New "Libraries" category + navbar heading under Free Add-Ons - Move Query Filters from GravityKit Products to Libraries - generate-hooks: add replaceIgnoreHooks so Foundation documents its own gk/foundation/* hooks while every other product keeps ignoring them - Homepage: skip product-card icons when no static/img/{id}.svg exists Foundation generates 137 hooks (39 actions, 98 filters) with no hook leakage into other products. Production build passes. Claude-Session: https://claude.ai/code/session_01WGs3aAJqYoXNEVCiru5obx
1 parent 8245551 commit dbb7ad8

4 files changed

Lines changed: 55 additions & 3 deletions

File tree

docusaurus.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ const products_with_docs = config_products
3636
// every page.
3737
const product_ids_with_docs = new Set(products_with_docs.map((p) => p.id));
3838

39+
// Product icons live at static/img/{id}.svg. Not every product has one (e.g.
40+
// Foundation, Query Filters), so build a set of ids that do. The homepage uses
41+
// this to skip rendering a broken icon for products without an artwork file.
42+
const product_icon_dir = fileURLToPath(new URL('./static/img', import.meta.url));
43+
const product_ids_with_icons = fs.existsSync(product_icon_dir)
44+
? fs
45+
.readdirSync(product_icon_dir)
46+
.filter((file) => file.endsWith('.svg'))
47+
.map((file) => file.replace(/\.svg$/, ''))
48+
: [];
49+
3950
// Read actual plugin versions from repository files
4051
const product_versions = readAllProductVersions(config_products);
4152

@@ -129,6 +140,16 @@ const gravitykit_nav = {
129140
className: 'dropdown-heading-item',
130141
},
131142
...getFreeProducts(),
143+
{
144+
type: 'html',
145+
value: '<hr class="dropdown-separator">',
146+
},
147+
{
148+
type: 'html',
149+
value: '<span class="dropdown-heading">Libraries</span>',
150+
className: 'dropdown-heading-item',
151+
},
152+
...getProductsByCategory('libraries'),
132153
],
133154
};
134155

@@ -274,6 +295,12 @@ const config = {
274295
tagline: 'Comprehensive documentation for all GravityKit products',
275296
favicon: 'img/favicon-192.png',
276297

298+
// Build-time data made available to pages via siteConfig.customFields.
299+
customFields: {
300+
// Product ids that have a static/img/{id}.svg icon file.
301+
productIdsWithIcons: product_ids_with_icons,
302+
},
303+
277304
// Client modules - runs on every page load
278305
clientModules: [
279306
'./src/clientModules/docsbot.js',

repos-config.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@
6363
"label": "MCPs",
6464
"description": "Model Context Protocol servers that connect AI assistants to your WordPress site.",
6565
"position": 6
66+
},
67+
"libraries": {
68+
"label": "Libraries",
69+
"description": "Shared developer libraries that power GravityKit products.",
70+
"position": 7
6671
}
6772
},
6873
"products": [
@@ -278,12 +283,22 @@
278283
"category": "gravitykit",
279284
"purchaseUrl": "https://www.gravitykit.com/products/gravitysearch/"
280285
},
286+
{
287+
"id": "foundation",
288+
"repo": "GravityKit/Foundation",
289+
"label": "Foundation",
290+
"description": "The shared framework powering every GravityKit product: licensing, settings, admin UI, translations, and plugin updates.",
291+
"category": "libraries",
292+
"srcDir": "src",
293+
"replaceIgnoreHooks": true,
294+
"ignoreHooks": ["deprecated_*", "private_*", "_internal_*"]
295+
},
281296
{
282297
"id": "query-filters",
283298
"repo": "GravityKit/Query-Filters",
284299
"label": "Query Filters",
285300
"description": "Advanced filtering for Gravity Forms' GF_Query and form fields — the shared library behind Advanced Filter, GravityExport, GravityCalendar, GravityCharts, and GravityBoard.",
286-
"category": "gravitykit"
301+
"category": "libraries"
287302
},
288303
{
289304
"id": "gravityflow",

scripts/generate-hooks.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,14 @@ function generateHooksDocs(product, config, options) {
711711
hooksConfig.ignoreFiles = [...hooksConfig.ignoreFiles, ...product.ignoreFiles];
712712
}
713713
if (product.ignoreHooks) {
714-
hooksConfig.ignoreHooks = [...hooksConfig.ignoreHooks, ...product.ignoreHooks];
714+
// By default a product's ignoreHooks are appended to the shared defaults.
715+
// A product that needs to document hooks the defaults would strip (e.g.
716+
// Foundation documenting its own gk/foundation/* hooks) sets
717+
// replaceIgnoreHooks: true to replace the defaults entirely. This keeps
718+
// every other product still ignoring those hooks.
719+
hooksConfig.ignoreHooks = product.replaceIgnoreHooks
720+
? [...product.ignoreHooks]
721+
: [...hooksConfig.ignoreHooks, ...product.ignoreHooks];
715722
}
716723

717724
const configPath = path.join(tempWorkDir, 'wp-hooks-doc.json');

src/pages/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,16 @@ function HomepageHeader() {
129129
* @returns {JSX.Element}
130130
*/
131131
function ProductCard({ product, showImage = true }) {
132+
const { siteConfig } = useDocusaurusContext();
132133
const imagePath = useBaseUrl(`/img/${product.id}.svg`);
134+
const iconIds = siteConfig.customFields?.productIdsWithIcons || [];
135+
const hasIcon = iconIds.includes(product.id);
133136

134137
return (
135138
<div className={clsx('col col--4 margin-bottom--lg')}>
136139
<div className="card">
137140
<div className="card__header">
138-
{showImage && (
141+
{showImage && hasIcon && (
139142
<Link to={product.link}>
140143
<img
141144
src={imagePath}

0 commit comments

Comments
 (0)