Skip to content

Commit 750bc7b

Browse files
superdav42claude
andcommitted
Fix sidebar translation key conflicts in hooks generation
Add unique _category_.json files with keys after generating hooks to prevent Docusaurus translation key conflicts. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3e0fae5 commit 750bc7b

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

scripts/generate-hooks.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ JSONEOF
4545
find "$DOCS_DIR/docs/developer/hooks/" -name "*.md" -exec sed -i "s|$MAIN_PLUGIN_DIR/||g" {} +
4646
find "$DOCS_DIR/docs/developer/hooks/" -name "*.md" -exec sed -i -E \
4747
's|Defined in `(.+)` at line ([0-9]+)|Defined in [`\1`](https://github.com/Ultimate-Multisite/ultimate-multisite/blob/main/\1#L\2) at line \2|g' {} +
48+
# Add unique sidebar keys to prevent translation conflicts
49+
echo '{"label":"hooks","key":"developer-hooks"}' > "$DOCS_DIR/docs/developer/hooks/_category_.json"
50+
[[ -d "$DOCS_DIR/docs/developer/hooks/Actions" ]] && echo '{"label":"Actions","key":"developer-actions"}' > "$DOCS_DIR/docs/developer/hooks/Actions/_category_.json"
51+
[[ -d "$DOCS_DIR/docs/developer/hooks/Filters" ]] && echo '{"label":"Filters","key":"developer-filters"}' > "$DOCS_DIR/docs/developer/hooks/Filters/_category_.json"
4852
echo "Main plugin hooks copied to docs/developer/hooks/"
4953
else
5054
echo "WARNING: No hooks generated for main plugin"
@@ -132,6 +136,11 @@ JSONEOF
132136
find "$hooks_dir" -name "*.md" -exec sed -i -E \
133137
"s|Defined in \`(.+)\` at line ([0-9]+)|Defined in [\`\1\`](https://github.com/Ultimate-Multisite/$repo_name/blob/main/\1#L\2) at line \2|g" {} +
134138

139+
# Add unique sidebar keys to prevent translation conflicts
140+
echo "{\"label\":\"hooks\",\"key\":\"${doc_slug}-hooks\"}" > "$hooks_dir/_category_.json"
141+
[[ -d "$hooks_dir/Actions" ]] && echo "{\"label\":\"Actions\",\"key\":\"${doc_slug}-actions\"}" > "$hooks_dir/Actions/_category_.json"
142+
[[ -d "$hooks_dir/Filters" ]] && echo "{\"label\":\"Filters\",\"key\":\"${doc_slug}-filters\"}" > "$hooks_dir/Filters/_category_.json"
143+
135144
hook_count=$(find "$hooks_dir" -name "*.md" -not -name "index.md" | wc -l)
136145
echo " $hook_count hooks copied to addons/$doc_slug/hooks/"
137146
addon_count=$((addon_count + 1))

0 commit comments

Comments
 (0)