diff --git a/scripts/fileProcessor/processors/cnp/replace-github-urls.mjs b/scripts/fileProcessor/processors/cnp/replace-github-urls.mjs new file mode 100644 index 00000000000..f61a241eda4 --- /dev/null +++ b/scripts/fileProcessor/processors/cnp/replace-github-urls.mjs @@ -0,0 +1,20 @@ +// Replace URLs beginning with the following patterns... +// - https://github.com/EnterpriseDB/cloud-native-postgres/tree/main/docs/ +// - https://raw.githubusercontent.com/EnterpriseDB/cloud-native-postgres/main/docs/src/ +// ...with equivalent URLs referencing postgres for kubernetes in the public EDB Docs repo + +const replacements = [ + {pattern: /https:\/\/github\.com\/EnterpriseDB\/cloud-native-postgres\/tree\/main\/docs\//g, replacement: "https://github.com/EnterpriseDB/docs/tree/main/product_docs/docs/postgres-for-kubernetes/latest/"}, + {pattern: /https:\/\/github\.com\/EnterpriseDB\/cloud-native-postgres\/blob\/main\/docs\//g, replacement: "https://github.com/EnterpriseDB/docs/blob/main/product_docs/docs/postgres-for-kubernetes/latest/"}, + {pattern: /https:\/\/raw\.githubusercontent\.com\/EnterpriseDB\/cloud-native-postgres\/main\/docs\/src\//g, replacement: "https://raw.githubusercontent.com/EnterpriseDB/docs/main/product_docs/docs/postgres-for-kubernetes/latest/"}, +]; + +export const process = (filename, content) => { + for (const r of replacements) + content = content.replace(r.pattern, r.replacement); + + return { + newFilename: filename, + newContent: content, + }; +}; diff --git a/scripts/source/process-cnp-docs.sh b/scripts/source/process-cnp-docs.sh index d70a4abeee1..c654ab28107 100755 --- a/scripts/source/process-cnp-docs.sh +++ b/scripts/source/process-cnp-docs.sh @@ -26,6 +26,7 @@ node $DESTINATION_CHECKOUT/scripts/fileProcessor/main.mjs \ node $DESTINATION_CHECKOUT/scripts/fileProcessor/main.mjs \ -f "src/**/*.md" \ + -p "cnp/replace-github-urls" \ -p "cnp/update-yaml-links" \ -p "cnp/add-frontmatters" \ -p "cnp/rename-to-mdx" diff --git a/scripts/source/process-pgd4k-docs.sh b/scripts/source/process-pgd4k-docs.sh index 11ad5d9aa28..052c5db1d1a 100755 --- a/scripts/source/process-pgd4k-docs.sh +++ b/scripts/source/process-pgd4k-docs.sh @@ -22,6 +22,7 @@ cd $SOURCE_CHECKOUT/docs node $DESTINATION_CHECKOUT/scripts/fileProcessor/main.mjs \ -f "src/**/*.md" \ + -p "cnp/replace-github-urls" \ -p "cnp/update-yaml-links" \ -p "cnp/add-frontmatters" \ -p "cnp/rename-to-mdx"