Copilot commented on code in PR #464:
URL: https://github.com/apache/casbin-website/pull/464#discussion_r3087913286
##########
.github/workflows/pr_ci.yml:
##########
@@ -22,5 +22,8 @@ jobs:
- name: Install dependencies
run: yarn install
+ - name: Generate footer stars
+ run: yarn generate:footer-stars
Review Comment:
Since this workflow is being touched, consider upgrading
`actions/checkout@v2` and `actions/setup-node@v2` to the maintained v4 releases
(and optionally enabling `cache: yarn` like `master.yml`). Keeping workflows on
current action majors reduces the chance of future deprecation/security
breakages.
##########
src/theme/Footer/Links/MultiColumn/index.js:
##########
@@ -0,0 +1,116 @@
+import React from "react";
+import clsx from "clsx";
+import {ThemeClassNames} from "@docusaurus/theme-common";
+import LinkItem from "@theme/Footer/LinkItem";
+import FooterMoreBadges from "@site/src/components/FooterMoreBadges";
+
+function getShortHash(value) {
+ let hash = 0;
+
+ for (let index = 0; index < value.length; index += 1) {
+ hash = (hash * 31 + value.charCodeAt(index)) >>> 0;
+ }
+
+ return hash.toString(36);
+}
+
+function getItemKey(item) {
+ if (item.id) {
+ return item.id;
+ }
+
+ const stableKey = [
+ item.href,
+ item.to,
+ item.label,
+ item.className,
+ ].filter(Boolean).join("::");
+
+ if (stableKey) {
+ return stableKey;
+ }
+
+ if (item.html) {
+ return `html:${getShortHash(item.html)}`;
+ }
+
+ return "item";
+}
+
+function getColumnKey(column) {
+ return [
+ column.title,
+ column.className,
+ ...column.items.map(getItemKey),
+ ].filter(Boolean).join("::");
+}
+
+function ColumnLinkItem({item}) {
+ return item.html ? (
+ <li
+ className={clsx("footer__item", item.className)}
+ // Developer provided the HTML, so assume it's safe.
+ // eslint-disable-next-line react/no-danger
+ dangerouslySetInnerHTML={{__html: item.html}}
+ />
+ ) : (
+ <li key={item.href ?? item.to} className="footer__item">
Review Comment:
`ColumnLinkItem` already receives a stable `key` from the parent `.map(...)`
call; the additional `key={item.href ?? item.to}` on the `<li>` is redundant
(and can be `undefined`), which makes the component harder to reason about.
Remove the inner `key` and keep key management at the mapping site only.
--
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]