From 21ad5d64f6b8cb866cf0945eef813ee9e754baf8 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Fri, 26 Mar 2021 10:17:34 -0700 Subject: [PATCH] [website] adjust internal links in old latest when making a new version Summary: A little bit of sed to adjust links (see previous commit for effect). Reviewed By: skcho Differential Revision: D27360106 fbshipit-source-id: 2fa32f05f --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index 476f3e322..c74a3f56c 100644 --- a/Makefile +++ b/Makefile @@ -984,6 +984,13 @@ new-website-version: doc-publish cd $(WEBSITE_DIR)/versioned_docs/version-$(INFER_MAJOR).$(INFER_MINOR).$(INFER_PATCH)/ && \ find . -type f -not -name versions.md \ -exec sed -i -e 's#/next/#/$(INFER_MAJOR).$(INFER_MINOR).$(INFER_PATCH)/#g' \{\} \+ +# adjust intra-doc links in the previous "latest" version: /docs/foo -> /docs//foo +# select the first version that is not the one we are creating (in case this target is run +# multiple times) + old_latest=$$(jq 'map(select(. != "$(INFER_MAJOR).$(INFER_MINOR).$(INFER_PATCH)"))[0]' < $(WEBSITE_DIR)/versions.json | tr -d '"'); \ + cd $(WEBSITE_DIR)/versioned_docs/version-$${old_latest}/ && \ + find . -type f -not -name versions.md \ + -exec sed -i -e "s#(/docs/\([^$$(echo $$old_latest | cut -b 1)]\)#(/docs/$${old_latest}/\1#g" \{\} \+ # adjust versions.md, the page where users can navigate to other versions of the docs, unless # it was already changed by an earlier run of this rule cd $(WEBSITE_DIR)/ && \