Skip to content

Commit c1ba2ab

Browse files
zackkatzclaude
andcommitted
feat: Add @SInCE version tags for browsing hooks by version
- Add tagsBasePath: 'since' to docusaurus.config.js for /since/ URL structure - Update addTagsToHooks() to extract version numbers from @SInCE annotations - Tags now use just the version number (e.g., "1.0") instead of prefixed format - Since section in hook docs now links to tag pages (e.g., /docs/product/since/1-0/) - Removed action/filter type tags to focus only on version tags URLs like /docs/gravityactions/since/1-0/ now show all hooks added in that version. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 268ade0 commit c1ba2ab

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

docusaurus.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const product_docs_plugins = config_products
3232
id: product.id,
3333
path: `./docs/${product.id}`,
3434
routeBasePath: `docs/${product.id}`,
35-
tagsBasePath: 'tags',
35+
tagsBasePath: 'since',
3636
},
3737
]);
3838

scripts/generate-hooks.mjs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ function lowercaseDirectory(dir, name) {
189189
}
190190

191191
/**
192-
* Add tags to hook markdown files based on @since versions and hook type
192+
* Add tags to hook markdown files based on @since versions
193+
* Also converts the Since section to link to the tag pages
193194
*/
194195
function addTagsToHooks(outputDir) {
195196
const dirs = ['actions', 'filters'];
@@ -208,9 +209,6 @@ function addTagsToHooks(outputDir) {
208209
const sinceMatch = content.match(/### Since\n\n((?:- .+\n?)+)/);
209210
const tags = [];
210211

211-
// Add hook type as a tag
212-
tags.push(subdir === 'actions' ? 'action' : 'filter');
213-
214212
if (sinceMatch) {
215213
// Extract all versions (handles multiple "- version" lines)
216214
const versions = sinceMatch[1].match(/- ([^\n]+)/g);
@@ -222,10 +220,23 @@ function addTagsToHooks(outputDir) {
222220
// Extract just the version number (e.g., "1.18: Added feature" -> "1.18")
223221
const versionMatch = version.match(/^([\d.]+)/);
224222
if (versionMatch) {
225-
tags.push(`since-${versionMatch[1]}`);
223+
tags.push(versionMatch[1]);
226224
}
227225
}
228226
}
227+
228+
// Convert Since section to use links to tag pages
229+
// Replace "- 1.0" with "- [1.0](../../since/1-0/)"
230+
// Path is ../../ because docs are in actions/ or filters/ subdirs
231+
let newSinceSection = sinceMatch[0];
232+
for (const tag of tags) {
233+
const tagSlug = tag.replace(/\./g, '-');
234+
newSinceSection = newSinceSection.replace(
235+
new RegExp(`- ${tag.replace(/\./g, '\\.')}(?!\\])`, 'g'),
236+
`- [${tag}](../../since/${tagSlug}/)`
237+
);
238+
}
239+
content = content.replace(sinceMatch[0], newSinceSection);
229240
}
230241

231242
// Add tags to frontmatter if we have any
@@ -235,9 +246,10 @@ function addTagsToHooks(outputDir) {
235246
// Insert tags into frontmatter (before the closing ---)
236247
if (content.match(/^---\n[\s\S]*?\n---/)) {
237248
content = content.replace(/^(---\n[\s\S]*?)(---)/, `$1${tagsYaml}\n$2`);
238-
fs.writeFileSync(filePath, content);
239249
}
240250
}
251+
252+
fs.writeFileSync(filePath, content);
241253
}
242254
}
243255
}

0 commit comments

Comments
 (0)