Skip to content

Commit c25c046

Browse files
authored
fix(src): components and ci (#1164)
2 parents 4bd1a9e + 0c3d27b commit c25c046

File tree

10 files changed

+41
-18
lines changed

10 files changed

+41
-18
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.docusaurus
22
.vscode
33
/build
4-
/node-modules
4+
/node_modules
55
/docgen/**

.eslintrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ module.exports = {
2424
"warn",
2525
{ prefer: "type-imports" },
2626
],
27+
"@typescript-eslint/ban-ts-comment": [
28+
"error",
29+
{
30+
"ts-expect-error": "allow-with-description",
31+
"ts-ignore": true,
32+
"ts-nocheck": true,
33+
"ts-check": true,
34+
},
35+
],
2736
},
2837
overrides: [
2938
{

.github/workflows/check-external-links.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
env:
3535
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3636
- name: Comment on PR if broken links found
37-
if: ${{ always() && steps.lychee.outputs.exit_code != 0 }}
37+
if: ${{ steps.lychee.outputs.exit_code && steps.lychee.outputs.exit_code != '0' }}
3838
uses: thollander/actions-comment-pull-request@v3
3939
with:
4040
message: |
@@ -49,5 +49,5 @@ jobs:
4949
env:
5050
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5151
- name: Fail if broken links found
52-
if: ${{ steps.lychee.outputs.exit_code != 0 }}
52+
if: ${{ failure() || (steps.lychee.outputs.exit_code && steps.lychee.outputs.exit_code != '0') }}
5353
run: exit 1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ yarn-error.log*
2222
.vscode
2323
.idea
2424
.lycheecache
25+
.eslintcache
2526

2627
flare-smart-contracts-v2/
2728
flare-smart-contracts/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"format": "prettier --write . && prettier --write --plugin=prettier-plugin-solidity 'examples/developer-hub-solidity/**/*.sol' && npm run format --prefix examples/developer-hub-javascript",
1919
"format:diff": "prettier --list-different .",
2020
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,md,mdx}\"",
21-
"lint": "npx eslint ."
21+
"lint": "npx eslint . --cache --cache-location .eslintcache"
2222
},
2323
"dependencies": {
2424
"@docusaurus/core": "^3.9.2",

src/components/RemixEmbed/index.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
import React, { type JSX } from "react";
1+
import React, { type JSX, type ReactNode } from "react";
22
import Link from "@docusaurus/Link";
33

4-
export default function RemixEmbed({ children, fileName }): JSX.Element {
4+
type RemixEmbedProps = {
5+
children: ReactNode;
6+
fileName: string;
7+
};
8+
9+
const sanitizeFileName = (value: string) =>
10+
encodeURIComponent(value).replace(/%2F/g, "/");
11+
12+
export default function RemixEmbed({
13+
children,
14+
fileName,
15+
}: RemixEmbedProps): JSX.Element {
516
const baseUrl = "https://remix.ethereum.org/";
617
const githubUrl =
718
"#url=https://github.com/flare-foundation/developer-hub/blob/main/examples/developer-hub-solidity/" +
8-
fileName;
19+
sanitizeFileName(fileName);
920
const parameters =
1021
"&version=builtin&evmVersion=cancun&optimize=true&runs=200";
1122
return (

src/components/YouTubeEmbed/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ const YouTubeEmbed: React.FC<YouTubeEmbedProps> = ({
6060
useEffect(() => {
6161
if (isActivated) return;
6262
if (loadStrategy !== "onVisible") return;
63+
if (typeof IntersectionObserver === "undefined") {
64+
setIsActivated(true);
65+
return;
66+
}
6367

6468
const el = containerRef.current;
6569
if (!el) return;

src/features/DeveloperTools/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ const CATEGORY_ORDER = [
4545
"Explorers",
4646
] as const;
4747

48+
const slugifyCategory = (value: string) =>
49+
value
50+
.toLowerCase()
51+
.trim()
52+
.replace(/[^a-z0-9]+/g, "-")
53+
.replace(/^-+|-+$/g, "") || "category";
54+
4855
function scrollToHash(hash: string) {
4956
const id = hash.replace(/^#/, "");
5057
if (!id) return;
@@ -186,7 +193,7 @@ const DeveloperTools: React.FC = () => {
186193
</div>
187194

188195
{orderedCategories.map(([category, tools]) => {
189-
const categoryId = CATEGORY_IDS[category] ?? category;
196+
const categoryId = CATEGORY_IDS[category] ?? slugifyCategory(category);
190197

191198
return (
192199
<div key={category} className={styles.categorySection}>

src/theme/DocCard/index.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
findFirstSidebarItemLink,
77
} from "@docusaurus/plugin-content-docs/client";
88
import { usePluralForm } from "@docusaurus/theme-common";
9-
import isInternalUrl from "@docusaurus/isInternalUrl";
109
import { translate } from "@docusaurus/Translate";
1110

1211
import type { Props } from "@theme/DocCard";
@@ -54,12 +53,10 @@ function CardContainer({
5453

5554
function CardLayout({
5655
href,
57-
// icon,
5856
title,
5957
description,
6058
}: {
6159
href: string;
62-
// icon?: ReactNode;
6360
title: string;
6461
description?: string;
6562
}): JSX.Element {
@@ -71,7 +68,6 @@ function CardLayout({
7168
className={clsx("text--truncate", styles.cardTitle)}
7269
title={title}
7370
>
74-
{/* {icon} */}
7571
{title}
7672
</Heading>
7773
<svg
@@ -115,22 +111,17 @@ function CardCategory({
115111
return (
116112
<CardLayout
117113
href={href}
118-
// @ts-expect-error: To make linter happy not sure whats wrong since code is swizzled from docosaurus theme
119-
icon="🗃️"
120114
title={item.label}
121115
description={item.description ?? categoryItemsPlural(item.items.length)}
122116
/>
123117
);
124118
}
125119

126120
function CardLink({ item }: { item: PropSidebarItemLink }): JSX.Element {
127-
const icon = isInternalUrl(item.href) ? "📄️" : "🔗";
128121
const doc = useDocById(item.docId ?? undefined);
129122
return (
130123
<CardLayout
131124
href={item.href}
132-
// @ts-expect-error: To make linter happy not sure whats wrong since code is swizzled from docosaurus theme
133-
icon={icon}
134125
title={item.label}
135126
description={item.description ?? doc?.description}
136127
/>

src/theme/PaginatorNavLink/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function PaginatorNavLink(props: Props): JSX.Element {
1818
<div
1919
className={clsx(
2020
styles.subLabel,
21-
isNext ? styles.nextSubLabel : styles.prevSubLabe,
21+
isNext ? styles.nextSubLabel : styles.prevSubLabel,
2222
)}
2323
>
2424
{!isNext && (

0 commit comments

Comments
 (0)