bitflicker64 commented on code in PR #542:
URL: https://github.com/apache/hugegraph-doc/pull/542#discussion_r4317908948
##########
layouts/_partials/ai/config.html:
##########
@@ -10,24 +10,37 @@
{{- end -}}
{{- $provider = index $raw "provider" | default "" -}}
{{- $websiteID = index $raw "website_id" | default "" -}}
- {{- $sourceGroups = index $raw "source_groups" | default dict -}}
+ {{- $sourceGroups = index $raw "source_groups" -}}
{{- else -}}
{{- errorf "params.ai_search must be a map" -}}
{{- end -}}
+{{- /* This site selects an exact version before exposing the language groups.
+ An unconfigured version keeps a local notice, never a latest fallback.
*/ -}}
+{{- $version := .Site.Params.version | default "latest" -}}
+{{- $versionGroups := dict -}}
+{{- $configured := false -}}
+{{- if reflect.IsMap $sourceGroups -}}
+ {{- $configured = isset $sourceGroups $version -}}
+ {{- $versionGroups = index $sourceGroups $version | default dict -}}
+{{- end -}}
{{- $enGroup := "" -}}
{{- $cnGroup := "" -}}
-{{- if reflect.IsMap $sourceGroups -}}
- {{- $enGroup = index $sourceGroups "en" | default "" -}}
- {{- $cnGroup = index $sourceGroups "cn" | default "" -}}
+{{- if reflect.IsMap $versionGroups -}}
+ {{- $enGroup = index $versionGroups "en" | default "" -}}
+ {{- $cnGroup = index $versionGroups "cn" | default "" -}}
{{- end -}}
{{- if $enabled -}}
+ {{- if not (reflect.IsMap $sourceGroups) }}{{ errorf
"params.ai_search.source_groups must be a map when AI search is enabled" }}{{
end -}}
{{- if ne $provider "kapa" }}{{ errorf "params.ai_search.provider must be
kapa when AI search is enabled" }}{{ end -}}
{{- if not $websiteID }}{{ errorf "params.ai_search.website_id is required
when AI search is enabled" }}{{ end -}}
- {{- if or (not $enGroup) (not $cnGroup) }}{{ errorf
"params.ai_search.source_groups.en and .cn are required when AI search is
enabled" }}{{ end -}}
+ {{- if and $configured (or (not $enGroup) (not $cnGroup)) -}}
Review Comment:
Minor: With AI enabled, a build whose current version is `latest` no longer
fails when `source_groups.latest` is missing. The root site then ships the
unindexed notice on every page.
`$configured` is false when the key is absent, so this check is skipped. I
rendered the real partial with `version: latest` and `source_groups` holding
only `1.7` and `1.5`: Hugo exits 0 and every page gets `sourceGroupId: ""` with
the unindexed label. Before this change, missing `en`/`cn` failed the build.
The e2e fixture always supplies `latest`, so CI would not catch a production
config that dropped it.
Please fail the build when AI is enabled, `$configured` is false and
`.Site.Params.archived_version` is not true (or `eq $version "latest"`), and
add a test for it. The `archived_version` form needs the test harness to set
that flag for the 1.3/1.0/unknown cases. `scripts/kapa-rollout.md` should then
say `latest` is required; its old line saying a missing ID refuses the build
was removed in this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]