From c7d57baf82adbf7e5c92935e7ea5e3389bcd50bf Mon Sep 17 00:00:00 2001 From: LofiSu <163713803+LofiSu@users.noreply.github.com> Date: Mon, 2 Sep 2024 11:01:19 +0800 Subject: [PATCH] [Feat]Add new sections HomePageLanguageCard and HomePageCode (#177) "Add new sections HomePageLanguageCard and HomePageCode with Corresponding links . Added some basic configurations" https://github.com/user-attachments/assets/2e93e064-2698-4c5d-a111-ae019f9d5a5a --- babel.config.js | 2 +- docusaurus.config.ts | 1 + package.json | 7 +- src/components/HomePageLanguageCard/index.tsx | 79 ++++++++++++++++++ src/components/HomepageCode/index.tsx | 72 ++++++++++++++++ src/pages/index.tsx | 16 +++- static/JavaScript.svg | 1 + static/Rust.svg | 1 + static/cat.svg | 1 + static/golang.svg | 1 + static/home/coding.svg | 82 +++++++++++++++++++ static/java.svg | 1 + static/more.svg | 1 + static/programming.svg | 1 + static/python.svg | 1 + 15 files changed, 263 insertions(+), 4 deletions(-) create mode 100644 src/components/HomePageLanguageCard/index.tsx create mode 100644 src/components/HomepageCode/index.tsx create mode 100644 static/JavaScript.svg create mode 100644 static/Rust.svg create mode 100644 static/cat.svg create mode 100644 static/golang.svg create mode 100644 static/home/coding.svg create mode 100644 static/java.svg create mode 100644 static/more.svg create mode 100644 static/programming.svg create mode 100644 static/python.svg diff --git a/babel.config.js b/babel.config.js index e00595dae..bfd75dbdf 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,3 +1,3 @@ module.exports = { - presets: [require.resolve('@docusaurus/core/lib/babel/preset')], + presets: [require.resolve("@docusaurus/core/lib/babel/preset")], }; diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 5ac8ac80d..db6778713 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -77,6 +77,7 @@ const config: Config = { plugins: [ require.resolve('docusaurus-lunr-search') ], + themeConfig: { metadata: [ {'http-equiv': 'Content-Security-Policy', content: "frame-src 'self' https://ghbtns.com"}, diff --git a/package.json b/package.json index 45c87c262..372823a48 100644 --- a/package.json +++ b/package.json @@ -20,17 +20,22 @@ "@docusaurus/plugin-content-docs": "^3.5.1", "@docusaurus/preset-classic": "3.0.1", "@mdx-js/react": "^3.0.0", + "antd": "^5.20.3", "aos": "^2.3.4", "clsx": "^2.0.0", "docusaurus-lunr-search": "^3.3.1", "prism-react-renderer": "^2.3.0", "react": "^18.0.0", - "react-dom": "^18.0.0" + "react-dom": "^18.0.0", + "react-syntax-highlighter": "^15.5.0" }, "devDependencies": { "@docusaurus/module-type-aliases": "3.0.1", "@docusaurus/tsconfig": "3.0.1", "@docusaurus/types": "3.0.1", + "css-loader": "^7.1.2", + "esbuild-loader": "^4.2.2", + "style-loader": "^4.0.0", "typescript": "~5.2.2" }, "browserslist": { diff --git a/src/components/HomePageLanguageCard/index.tsx b/src/components/HomePageLanguageCard/index.tsx new file mode 100644 index 000000000..39b3050ea --- /dev/null +++ b/src/components/HomePageLanguageCard/index.tsx @@ -0,0 +1,79 @@ +import React from "react"; +import { Card } from "antd"; + +export const HomePageLanguageCard = () => ( +
+
+

Quick Start!

+

Choose a language to get started .

+
+ + { + window.location.href = + "https://fury.apache.org/docs/start/usage/#java-serialization"; + }}> + + Java + + { + window.location.href = + "https://fury.apache.org/docs/start/usage/#python"; + }}> + + Python + + { + window.location.href = + "https://fury.apache.org/docs/start/usage/#golang"; + }}> + + Golang + + { + window.location.href = + "https://fury.apache.org/docs/start/usage/#javascript"; + }}> + + JavaScript + + { + window.location.href = "https://fury.apache.org/docs/start/usage/#rust"; + }}> + + Rust + + { + window.location.href = + "https://fury.apache.org/docs/start/usage/#crosslanguage-serialization"; + }}> + + More + + +
+); + +const gridStyle: React.CSSProperties = { + width: "50%", + display: "flex", + alignItems: "center", + justifyContent: "center", + height: "100px", + textAlign: "center", + border: "1px solid #f0f0f0", + borderRadius: "10px", + fontWeight: "bold", + fontSize: "18px", +}; +const imageStyle: React.CSSProperties = { + width: "38px", + height: "38px", + marginRight: "8px", +}; diff --git a/src/components/HomepageCode/index.tsx b/src/components/HomepageCode/index.tsx new file mode 100644 index 000000000..f0f2fa95c --- /dev/null +++ b/src/components/HomepageCode/index.tsx @@ -0,0 +1,72 @@ +import React from "react"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { dracula } from "react-syntax-highlighter/dist/esm/styles/prism"; + +export const HomepageCodeDisplay = () => { + const codeString = `import java.util.List; +import java.util.Arrays; +import org.apache.fury.*; + +public class Example { + public static void main(String[] args) { + SomeClass object = new SomeClass(); + // Note that Fury instances should be reused between + // multiple serializations of different objects. + Fury fury = Fury.builder().withLanguage(Language.JAVA) + // Allow to deserialize objects unknown types, + // more flexible but less secure. + // .withSecureMode(false) + .build(); + // Registering types can reduce class name serialization + // overhead but not mandatory. + // If secure mode enabled + //all custom types must be registered. + fury.register(SomeClass.class); + byte[] bytes = fury.serialize(object); + System.out.println(fury.deserialize(bytes)); + } +} + `; + + return ( + <> +
+
+ programming-coding +
+
+ + {codeString} + +
+
+ + ); +}; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 86a82aaa4..abe4e9db4 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -9,6 +9,8 @@ import styles from "./index.module.css"; import Translate, { translate } from "@docusaurus/Translate"; import AOS from "aos"; import "aos/dist/aos.css"; +import { HomePageLanguageCard } from "../components/HomePageLanguageCard"; +import { HomepageCodeDisplay } from "../components/HomepageCode"; function HomepageHeader() { const { siteConfig } = useDocusaurusContext(); @@ -95,11 +97,21 @@ export default function Home(): JSX.Element { >
-
+
+
+
+ +
+
+
+
+ +
+
- ); + ); } diff --git a/static/JavaScript.svg b/static/JavaScript.svg new file mode 100644 index 000000000..326d41725 --- /dev/null +++ b/static/JavaScript.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/Rust.svg b/static/Rust.svg new file mode 100644 index 000000000..bbcd3dbcb --- /dev/null +++ b/static/Rust.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/cat.svg b/static/cat.svg new file mode 100644 index 000000000..431358c13 --- /dev/null +++ b/static/cat.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/golang.svg b/static/golang.svg new file mode 100644 index 000000000..5cf4792bb --- /dev/null +++ b/static/golang.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/home/coding.svg b/static/home/coding.svg new file mode 100644 index 000000000..df9b9e32e --- /dev/null +++ b/static/home/coding.svg @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/java.svg b/static/java.svg new file mode 100644 index 000000000..56dbe6e55 --- /dev/null +++ b/static/java.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/more.svg b/static/more.svg new file mode 100644 index 000000000..e99a22609 --- /dev/null +++ b/static/more.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/programming.svg b/static/programming.svg new file mode 100644 index 000000000..2e7d451d1 --- /dev/null +++ b/static/programming.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/python.svg b/static/python.svg new file mode 100644 index 000000000..7c19426b5 --- /dev/null +++ b/static/python.svg @@ -0,0 +1 @@ + \ No newline at end of file