Skip to content

Commit effe184

Browse files
mnenciagbartolini
authored andcommitted
feat(sidebar): use autogenerated sidebar configuration
Replace manual sidebar entries with Docusaurus autogenerated sidebar using document metadata and category files, simplifying maintenance and reducing manual configuration overhead. The import script now creates autogenerated sidebar config for new versions on first import, preserving any later customizations. Closes #20 Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
1 parent 248fa45 commit effe184

4 files changed

Lines changed: 39 additions & 76 deletions

File tree

scripts/import_docs.sh

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ if [[ "$IS_MAIN" == true ]]; then
108108
echo "Copying imported docs -> ./website/docs"
109109
mkdir -p ./website/docs
110110
rsync -av --delete "$SOURCE_PATH/" --exclude "css" ./website/docs/
111+
111112
echo "Updated ./docs from main — import completed."
112113
exit 0
113114
fi
@@ -120,10 +121,29 @@ TARGET_DIRECTORY="./website/versioned_docs/version-${VERSION_DIR}"
120121
echo "Copying imported docs -> ${TARGET_DIRECTORY}"
121122
rsync -av --delete "$SOURCE_PATH/" --exclude "css" "${TARGET_DIRECTORY}"
122123

124+
# Create autogenerated sidebar configuration for this version if it doesn't exist
125+
SIDEBAR_TARGET_DIR="./website/versioned_sidebars"
126+
SIDEBAR_TARGET_FILE="$SIDEBAR_TARGET_DIR/version-${VERSION_DIR}-sidebars.json"
127+
128+
if [[ ! -f "$SIDEBAR_TARGET_FILE" ]]; then
129+
echo "Creating autogenerated sidebar config for version ${VERSION_DIR}"
130+
mkdir -p "$SIDEBAR_TARGET_DIR"
131+
cat > "$SIDEBAR_TARGET_FILE" <<'SIDEBAR_EOF'
132+
{
133+
"docs": [
134+
{
135+
"type": "autogenerated",
136+
"dirName": "."
137+
}
138+
]
139+
}
140+
SIDEBAR_EOF
141+
else
142+
echo "Sidebar config for version ${VERSION_DIR} already exists, keeping it"
143+
fi
144+
123145
# Add the new version to versions.json if not already present
124-
if ! grep -q "\"${VERSION_DIR}\"" versions.json 2>/dev/null; then
125-
# Import the new version in the correct folder
126-
cp "./website/sidebar_config.json" "./website/versioned_sidebars/version-${VERSION_DIR}-sidebars.json"
146+
if ! grep -q "\"${VERSION_DIR}\"" "$VERSIONS_JSON" 2>/dev/null; then
127147
jq --arg version "$VERSION_DIR" \
128148
'. = [$version] + . | unique' \
129149
"$VERSIONS_JSON" > "${VERSIONS_JSON}.tmp" && \
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"label": "Appendixes",
3+
"position": 600,
4+
"link": {
5+
"type": "generated-index"
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"label": "CNCF Projects Integrations",
3+
"position": 590,
4+
"link": {
5+
"type": "generated-index"
6+
}
7+
}

website/sidebar_config.json

Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,8 @@
11
{
22
"docs": [
3-
"index",
4-
"before_you_start",
5-
"use_cases",
6-
"architecture",
7-
"installation_upgrade",
8-
"quickstart",
9-
"image_catalog",
10-
"bootstrap",
11-
"database_import",
12-
"security",
13-
"instance_manager",
14-
"scheduling",
15-
"resource_management",
16-
"failure_modes",
17-
"rolling_update",
18-
"replication",
19-
"logical_replication",
20-
"backup",
21-
"wal_archiving",
22-
"recovery",
23-
"service_management",
24-
"postgresql_conf",
25-
"declarative_role_management",
26-
"declarative_database_management",
27-
"tablespaces",
28-
"operator_conf",
29-
"cluster_conf",
30-
"storage",
31-
"labels_annotations",
32-
"monitoring",
33-
"logging",
34-
"certificates",
35-
"ssl_connections",
36-
"applications",
37-
"connection_pooling",
38-
"replica_cluster",
39-
"kubernetes_upgrade",
40-
"postgres_upgrades",
41-
"kubectl-plugin",
42-
"failover",
43-
"troubleshooting",
44-
"fencing",
45-
"declarative_hibernation",
46-
"postgis",
47-
"e2e",
48-
"container_images",
49-
"imagevolume_extensions",
50-
"cnpg_i",
51-
"operator_capability_levels",
52-
"controller",
53-
"samples",
54-
"networking",
55-
"benchmarking",
56-
"faq",
57-
"cloudnative-pg.v1",
58-
"supported_releases",
59-
"preview_version",
60-
"release_notes",
613
{
62-
"type": "category",
63-
"label": "CNCF Projects Integrations",
64-
"items": [
65-
"cncf-projects/external-secrets",
66-
"cncf-projects/cilium"
67-
]
68-
},
69-
{
70-
"type": "category",
71-
"label": "Appendixes",
72-
"items": [
73-
"appendixes/backup_volumesnapshot",
74-
"appendixes/backup_barmanobjectstore",
75-
"appendixes/object_stores"
76-
]
4+
"type": "autogenerated",
5+
"dirName": "."
776
}
787
]
798
}

0 commit comments

Comments
 (0)