Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion layouts/partials/algolia/api-page-index.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
{{ $lang := .lang }}
{{ $api_version := .api_version }} {{/* "v1" or "v2" */}}
{{ $endpoint_data := .endpoint_data }}
{{ $endpoint_path := .endpoint_path }}
{{ $method := .method }}
{{ $api_v1_translate_actions := .api_v1_translate_actions }}
{{ $api_v2_translate_actions := .api_v2_translate_actions }}

Expand All @@ -20,13 +22,17 @@
{{ $action_data := index $translate_actions_datafile $operationId }}
{{ $section_header := $action_data.summary }}
{{ $section_content := $action_data.description }}

{{/* Append "METHOD /path" so the endpoint's REST path is searchable. Kept at the end to stay out of the embedding's truncated input. */}}
{{ $section_content = printf "%s\n\n%s %s" ($section_content | default "") (upper $method) $endpoint_path | strings.TrimSpace }}

{{ $endpoint_slug := $section_header | anchorize }}
{{ $full_url := print $permalink $endpoint_slug "/" }}
{{ $relpermalink = print $relpermalink $endpoint_slug "/" }}

{{/* When the same operationId+summary exists in both v1 and v2, both versions share one endpoint page with version tabs. Disambiguate the records by linking to the tab anchor. */}}
{{ $other_action := cond (eq $api_version "v1") (index $api_v2_translate_actions $operationId) (index $api_v1_translate_actions $operationId) }}
{{ if and (ne $other_action nil) (eq $other_action.summary $section_header) }}
{{ if and (ne $other_action nil) (eq ($other_action.summary | anchorize) ($section_header | anchorize)) }}
{{ $tab_anchor := (print $section_header "-" $api_version) | anchorize }}
{{ $full_url = print $full_url "#" $tab_anchor }}
{{ $relpermalink = print $relpermalink "#" $tab_anchor }}
Expand Down
20 changes: 12 additions & 8 deletions layouts/partials/algolia/api-pages-full-index.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

{{/* Get all v1 api actions for this page by matching title with spec data's tag property */}}
{{ range $endpoint_path, $endpoint_data := $api_v1_data.paths }}
{{ range $endpoint_data }}
{{ range $method, $action := $endpoint_data }}
{{ $tags := slice }}
{{ if isset . "tags" }}
{{ $tags = .tags }}
{{ if isset $action "tags" }}
{{ $tags = $action.tags }}
{{ end }}

{{ if in $tags $title }}
Expand All @@ -47,7 +47,9 @@
"title" $title
"lang" $lang
"api_version" "v1"
"endpoint_data" .
"endpoint_data" $action
"endpoint_path" $endpoint_path
"method" $method
"api_v1_translate_actions" $api_v1_translate_actions
"api_v2_translate_actions" $api_v2_translate_actions
)
Expand All @@ -60,10 +62,10 @@

{{/* Get all v2 api actions for this page by matching title with spec data's tag property */}}
{{ range $endpoint_path, $endpoint_data := $api_v2_data.paths }}
{{ range $endpoint_data }}
{{ range $method, $action := $endpoint_data }}
{{ $tags := slice }}
{{ if isset . "tags" }}
{{ $tags = .tags }}
{{ if isset $action "tags" }}
{{ $tags = $action.tags }}
{{ end }}

{{ if in $tags $title }}
Expand All @@ -75,7 +77,9 @@
"title" $title
"lang" $lang
"api_version" "v2"
"endpoint_data" .
"endpoint_data" $action
"endpoint_path" $endpoint_path
"method" $method
"api_v1_translate_actions" $api_v1_translate_actions
"api_v2_translate_actions" $api_v2_translate_actions
)
Expand Down
Loading