Skip to content

Commit

Permalink
[docs] Fix bug for broken ecosystem links
Browse files Browse the repository at this point in the history
Reproduce Bug:

* Visit:
https://www.openpolicyagent.org/docs/edge/policy-language/#ecosystem-projects
* Click `view on the OPA ecosystem page`

I have also tried to use the titles from items in links when the titles
are short enough.

Signed-off-by: Charlie Egan <charlie@styra.com>
  • Loading branch information
charlieegan3 authored and ashutosh-narkar committed Jul 20, 2023
1 parent e57b6c7 commit c83f5b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion docs/website/layouts/docs/ecosystem-single.html.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
{{ if (gt (len $selectedIntegrations) 0) }}
<p>Integrations are ordered by the amount of linked content.</p>
{{ $sortedIntegrations := partial "functions/sort-integrations" (dict "integrations" $selectedIntegrations) }}
{{ partial "ecosystem-project-list-for-feature" (dict "selectedIntegrations" $sortedIntegrations "integrationsData" $.Site.Data.integrations "feature" $feature) }}
{{ $base := delimit (first 3 (split .Page.RelPermalink "/")) "/" }}
{{ partial "ecosystem-project-list-for-feature" (dict "selectedIntegrations" $sortedIntegrations "integrationsData" $.Site.Data.integrations "feature" $feature "base" $base) }}
{{ else }}
<p>There are no integrations for this category.</p>
{{ end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{ $selectedIntegrations := (index . "selectedIntegrations") }}
{{ $integrationsData := (index . "integrationsData") }}
{{ $feature := (index . "feature") }}
{{ $base := (index . "base") }}

<div class="ecosystem-list">
{{ range $name := $selectedIntegrations }}
Expand Down Expand Up @@ -34,8 +35,12 @@
<div class="ecosystem-list-item-content">
{{ (index (index $integration.docs_features $feature) "note") | markdownify }}
</div>
<a class="ecosystem-list-item-footer" href="../#{{ $name }}-detail">
View on the OPA Ecosystem page
<a class="ecosystem-list-item-footer" href="{{ $base }}/ecosystem/#{{ $name }}-detail">
{{ if lt (len $integration.title) 30 }}
View {{ $integration.title }} in Ecosystem
{{ else }}
View in Ecosystem
{{ end }}
</a>
</div>
{{ end }}
Expand Down
5 changes: 2 additions & 3 deletions docs/website/layouts/shortcodes/ecosystem_feature_embed.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{ $feature := .Get "key" }}
{{ $selectedIntegrations := partial "functions/select-integrations-by-docs-feature" (dict "integrations" $.Site.Data.integrations.integrations "feature" $feature) }}

{{ $base := delimit (first 3 (split .Page.RelPermalink "/")) "/" }}
{{ if (gt (len $selectedIntegrations) 6) }}
{{ $base := delimit (first 3 (split .Page.RelPermalink "/")) "/" }}
<p>
The {{ len $selectedIntegrations }} ecosystem projects related to this page
can be found in the corresponding <a href="{{ $base }}/ecosystem/{{ $feature }}">OPA Ecosystem section</a>.
Expand All @@ -14,9 +14,8 @@
</p>

{{ $sortedIntegrations := partial "functions/sort-integrations" (dict "integrations" $selectedIntegrations) }}
{{ partial "ecosystem-project-list-for-feature" (dict "selectedIntegrations" $sortedIntegrations "integrationsData" $.Site.Data.integrations "feature" $feature) }}
{{ partial "ecosystem-project-list-for-feature" (dict "selectedIntegrations" $sortedIntegrations "integrationsData" $.Site.Data.integrations "feature" $feature "base" $base) }}

{{ $base := delimit (first 3 (split .Page.RelPermalink "/")) "/" }}
<p class="mt-4">
View these projects in the <a href="{{ $base }}/ecosystem/{{ $feature }}">OPA Ecosystem</a>.
</p>
Expand Down

0 comments on commit c83f5b7

Please sign in to comment.