From 9d09be24a6ce4be5a11134235226e4cdc219974e Mon Sep 17 00:00:00 2001 From: Fabian Rodriguez Date: Thu, 16 Nov 2023 10:58:30 +0100 Subject: [PATCH] Fix cpinstall tag for kong-mesh There's a slight difference between Kuma and Kong Mesh in terms of the base segment of the docs' url. For Kuma, all the docs live under `/docs/`. Unfortunately, that's not the case for Kong Mesh. Kong docs renders multiple products, so we namespace the docs with the corresponding product name, i.e. they live under `/mesh/`. This commit updates the tag's code so that it uses the base path in which the page is generated as the first url segment. That way we can re-use the code in both platforms. It also modifies the link that is rendered, so that it uses `page.release` instead of `page.version` so that it also works for both docs sites. Signed-off-by: Fabian Rodriguez --- .../lib/jekyll/kuma-plugins/liquid/tags/cpinstall.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jekyll-kuma-plugins/lib/jekyll/kuma-plugins/liquid/tags/cpinstall.rb b/jekyll-kuma-plugins/lib/jekyll/kuma-plugins/liquid/tags/cpinstall.rb index 3cfdd65d9..55914019c 100644 --- a/jekyll-kuma-plugins/lib/jekyll/kuma-plugins/liquid/tags/cpinstall.rb +++ b/jekyll-kuma-plugins/lib/jekyll/kuma-plugins/liquid/tags/cpinstall.rb @@ -22,6 +22,7 @@ def render(context) content = super return "" unless content != "" site_data = context.registers[:site].config + page = context.environments.first['page'] opts = content.strip.split("\n").map do |x| x = site_data['set_flag_values_prefix'] + x if @prefixed @@ -39,7 +40,7 @@ def render(context) ``` {% endtab %} {% tab #{@tabs_name} helm %} -Before using {{site.mesh_product_name}} with helm, please follow [these steps](/docs/{{ page.version }}/production/cp-deployment/kubernetes/#helm) to configure your local helm repo. +Before using {{site.mesh_product_name}} with helm, please follow [these steps](/#{product_url_segment(page)}/{{ page.release }}/production/cp-deployment/kubernetes/#helm) to configure your local helm repo. ```shell helm install --create-namespace --namespace {{site.mesh_namespace}} \\ #{res} \\ @@ -49,6 +50,10 @@ def render(context) {% endtabs %}" ::Liquid::Template.parse(htmlContent).render(context) end + + def product_url_segment(page) + page['dir'].split('/')[1] + end end end end