Copilot commented on code in PR #2024:
URL: https://github.com/apache/apisix-website/pull/2024#discussion_r3076672902
##
website/src/pages/ai-gateway.tsx:
##
@@ -11,37 +11,67 @@ const ChakraTestPage: React.FC = () => (
-APISIX AI Gateway - LLM Proxy for Efficient, Secure AI Workloads
+What is an AI Gateway? APISIX AI Gateway for LLMs & AI Agents
+ https://apisix.apache.org/ai-gateway/"; />
-
Review Comment:
The `og:title` `content` value includes `&`. In JSX string props this
will be rendered as a literal `&` and then HTML-escaped again, resulting in
`&` in the final HTML. Use a literal `&` in the attribute value instead.
##
website/src/pages/index.tsx:
##
@@ -46,22 +47,24 @@ const Index: FC = () => (
- Apache APISIX® -- Cloud-Native API Gateway and AI Gateway
+ {translate({ id: 'homepage.meta.title', message: 'Apache APISIX -
Open Source API Gateway & AI Gateway' })}
+ https://apisix.apache.org/"; />
Review Comment:
`og:title` is not localized (it stays English even when the page title is
translated) and the `content` value includes `&`, which will be
double-escaped in the rendered HTML attribute. Consider using the same
`translate(...)` value used for `` here, and use a literal `&` in the
string.
##
website/src/pages/index.tsx:
##
@@ -46,22 +47,24 @@ const Index: FC = () => (
- Apache APISIX® -- Cloud-Native API Gateway and AI Gateway
+ {translate({ id: 'homepage.meta.title', message: 'Apache APISIX -
Open Source API Gateway & AI Gateway' })}
+ https://apisix.apache.org/"; />
+ https://apisix.apache.org/"; />
Review Comment:
Same issue as `og:title`: `twitter:title` is not localized and the `content`
string contains `&`, which will end up double-escaped in the output HTML
attribute. Prefer using the translated title string and a literal `&`.
##
website/src/pages/ai-gateway.tsx:
##
@@ -11,37 +11,67 @@ const ChakraTestPage: React.FC = () => (
-APISIX AI Gateway - LLM Proxy for Efficient, Secure AI Workloads
+What is an AI Gateway? APISIX AI Gateway for LLMs & AI Agents
+ https://apisix.apache.org/ai-gateway/"; />
Review Comment:
The canonical URL is hard-coded to the non-localized route. If this page is
built under `/zh/ai-gateway/`, it will still canonicalize to the English URL
and the hreflang postBuild plugin won’t adjust it because it only adds
canonicals when missing. Consider computing the canonical from the current
locale/path (or removing it and relying on the postBuild plugin).
```suggestion
```
##
website/src/pages/ai-gateway.tsx:
##
@@ -11,37 +11,67 @@ const ChakraTestPage: React.FC = () => (
-APISIX AI Gateway - LLM Proxy for Efficient, Secure AI Workloads
+What is an AI Gateway? APISIX AI Gateway for LLMs & AI Agents
+ https://apisix.apache.org/ai-gateway/"; />
-
+ https://apisix.apache.org/ai-gateway/";
/>
-
Review Comment:
Same escaping issue for `twitter:title`: the `content` value contains
`&`, which will be double-escaped in the final HTML attribute. Use a
literal `&` in the string.
##
website/src/pages/index.tsx:
##
@@ -46,22 +47,24 @@ const Index: FC = () => (
- Apache APISIX® -- Cloud-Native API Gateway and AI Gateway
+ {translate({ id: 'homepage.meta.title', message: 'Apache APISIX -
Open Source API Gateway & AI Gateway' })}
+ https://apisix.apache.org/"; />
Review Comment:
The canonical URL is hard-coded to the non-localized homepage. With i18n
enabled, the zh homepage will also emit this canonical, and the hreflang
postBuild plugin won’t correct it because it only adds canonicals when missing.
Consider computing the canonical from the current locale/path (or removing this
tag and letting the postBuild plugin inject the correct locale-specific
canonical).
```suggestion
```
##
website/src/pages/index.tsx:
##
@@ -46,22 +47,24 @@ const Index: FC = () => (
- Apache APISIX® -- Cloud-Native API Gateway and AI Gateway
+ {translate({ id: 'homepage.meta.title', message: 'Apache APISIX -
Open Source API Gateway & AI Gateway' })}
+ https://apisix.apache.org/"; />
+ https://apisix.apache.org/"; />
tags and canonical URLs
+ * into every HTML page during the post-build phase.
+ *
+ * For each page, it generates:
+ * https://apisix.apache.org/..."; />
+ * https://apisix.apache.org/zh/..."; />
+ * https://apisix.apache.org/..."; />
+ * (if not already present)
+ */
+module.exports = function hreflangPlugin() {
+ return {
+name: 'hreflang',
+
+async postBuild(