diff --git a/scripts/import_docs.sh b/scripts/import_docs.sh index a2c9115..d90ec4b 100755 --- a/scripts/import_docs.sh +++ b/scripts/import_docs.sh @@ -22,6 +22,8 @@ set -euo pipefail SOURCE_REPO="https://github.com/cloudnative-pg/cloudnative-pg.git" +ROOT_DIR=$(cd "$(dirname "$0")/../"; pwd) +WEBSITE_DIR=${ROOT_DIR}/website SOURCE_DOCS_PATH="docs/src" TMP_BASE="$(mktemp -d)" trap 'rm -rf "$TMP_BASE"' EXIT @@ -106,24 +108,44 @@ fi # ===== MAIN BRANCH ===== if [[ "$IS_MAIN" == true ]]; then echo "Copying imported docs -> ./website/docs" - mkdir -p ./website/docs - rsync -av --delete "$SOURCE_PATH/" --exclude "css" ./website/docs/ + mkdir -p ${WEBSITE_DIR}/docs + rsync -av --delete "$SOURCE_PATH/" --exclude "css" ${WEBSITE_DIR}/docs/ + echo "Updated ./docs from main — import completed." exit 0 fi # ===== VERSION TAG ===== -VERSIONS_JSON="./website/versions.json" -VERSIONS_CONFIG="./website/versions_config.json" -DOCUSAURUS_CONFIG="./website/docusaurus.config.ts" -TARGET_DIRECTORY="./website/versioned_docs/version-${VERSION_DIR}" +VERSIONS_JSON="${WEBSITE_DIR}/versions.json" +VERSIONS_CONFIG="${WEBSITE_DIR}/versions_config.json" +DOCUSAURUS_CONFIG="${WEBSITE_DIR}/docusaurus.config.ts" +TARGET_DIRECTORY="${WEBSITE_DIR}/versioned_docs/version-${VERSION_DIR}" echo "Copying imported docs -> ${TARGET_DIRECTORY}" rsync -av --delete "$SOURCE_PATH/" --exclude "css" "${TARGET_DIRECTORY}" +# Create autogenerated sidebar configuration for this version if it doesn't exist +SIDEBAR_TARGET_DIR="${WEBSITE_DIR}/versioned_sidebars" +SIDEBAR_TARGET_FILE="$SIDEBAR_TARGET_DIR/version-${VERSION_DIR}-sidebars.json" + +if [[ ! -f "$SIDEBAR_TARGET_FILE" ]]; then + echo "Creating autogenerated sidebar config for version ${VERSION_DIR}" + mkdir -p "$SIDEBAR_TARGET_DIR" + cat > "$SIDEBAR_TARGET_FILE" <<'SIDEBAR_EOF' +{ + "docs": [ + { + "type": "autogenerated", + "dirName": "." + } + ] +} +SIDEBAR_EOF +else + echo "Sidebar config for version ${VERSION_DIR} already exists, keeping it" +fi + # Add the new version to versions.json if not already present -if ! grep -q "\"${VERSION_DIR}\"" versions.json 2>/dev/null; then - # Import the new version in the correct folder - cp "./website/sidebar_config.json" "./website/versioned_sidebars/version-${VERSION_DIR}-sidebars.json" +if ! grep -q "\"${VERSION_DIR}\"" "$VERSIONS_JSON" 2>/dev/null; then jq --arg version "$VERSION_DIR" \ '. = [$version] + . | unique' \ "$VERSIONS_JSON" > "${VERSIONS_JSON}.tmp" && \ diff --git a/website/docs/appendixes/_category_.json b/website/docs/appendixes/_category_.json new file mode 100644 index 0000000..406ff35 --- /dev/null +++ b/website/docs/appendixes/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Appendixes", + "position": 600, + "link": { + "type": "generated-index" + } +} diff --git a/website/docs/cncf-projects/_category_.json b/website/docs/cncf-projects/_category_.json new file mode 100644 index 0000000..0bb5a46 --- /dev/null +++ b/website/docs/cncf-projects/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "CNCF Projects Integrations", + "position": 590, + "link": { + "type": "generated-index" + } +} diff --git a/website/sidebar_config.json b/website/sidebar_config.json index ac4015e..1fd014a 100644 --- a/website/sidebar_config.json +++ b/website/sidebar_config.json @@ -1,79 +1,8 @@ { "docs": [ - "index", - "before_you_start", - "use_cases", - "architecture", - "installation_upgrade", - "quickstart", - "image_catalog", - "bootstrap", - "database_import", - "security", - "instance_manager", - "scheduling", - "resource_management", - "failure_modes", - "rolling_update", - "replication", - "logical_replication", - "backup", - "wal_archiving", - "recovery", - "service_management", - "postgresql_conf", - "declarative_role_management", - "declarative_database_management", - "tablespaces", - "operator_conf", - "cluster_conf", - "storage", - "labels_annotations", - "monitoring", - "logging", - "certificates", - "ssl_connections", - "applications", - "connection_pooling", - "replica_cluster", - "kubernetes_upgrade", - "postgres_upgrades", - "kubectl-plugin", - "failover", - "troubleshooting", - "fencing", - "declarative_hibernation", - "postgis", - "e2e", - "container_images", - "imagevolume_extensions", - "cnpg_i", - "operator_capability_levels", - "controller", - "samples", - "networking", - "benchmarking", - "faq", - "cloudnative-pg.v1", - "supported_releases", - "preview_version", - "release_notes", { - "type": "category", - "label": "CNCF Projects Integrations", - "items": [ - "cncf-projects/external-secrets", - "cncf-projects/cilium" - ] - }, - { - "type": "category", - "label": "Appendixes", - "items": [ - "appendixes/backup_volumesnapshot", - "appendixes/backup_barmanobjectstore", - "appendixes/object_stores" - ] + "type": "autogenerated", + "dirName": "." } ] }