diff --git a/docs/docs/intro.md b/docs/docs/intro.md index bd8284e..edb742b 100644 --- a/docs/docs/intro.md +++ b/docs/docs/intro.md @@ -1,7 +1,12 @@ --- sidebar_position: 1 + +title: Introduction --- +import LatestRelease from '@site/src/components/LatestRelease'; +import AddToYourProject from '@site/src/components/AddToYourProject'; + # Introduction Let's get started with **Ollama4j**. @@ -71,20 +76,16 @@ The command runs the Ollama server locally at **http://localhost:11434/**. ### Setup your project -Get started by **creating a new Maven project** on your favorite IDE. Add the dependency to your project's `pom.xml`. -```xml + - - io.github.ollama4j - ollama4j - 1.0.78 - -``` +
+ +
-Find the latest version of the library [here](https://central.sonatype.com/artifact/io.github.ollama4j/ollama4j). +Find the latest version of the library from [Maven Central Repository](https://central.sonatype.com/artifact/io.github.ollama4j/ollama4j). You might want to include an implementation of [SL4J](https://www.slf4j.org/) logger in your `pom.xml` file. For example, diff --git a/docs/src/components/AddToYourProject/index.js b/docs/src/components/AddToYourProject/index.js new file mode 100644 index 0000000..7ab55fd --- /dev/null +++ b/docs/src/components/AddToYourProject/index.js @@ -0,0 +1,65 @@ +import React, { useState, useEffect } from 'react'; +import CodeBlock from '@theme/CodeBlock'; + +const AddToYourProject = () => { + const [releaseInfo, setReleaseInfo] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + const fetchLatestRelease = async () => { + setLoading(true); + setError(null); + try { + const response = await fetch('https://api.github.com/repos/ollama4j/ollama4j/releases/latest'); + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + const data = await response.json(); + setReleaseInfo(data); + } catch (err) { + console.error('Failed to fetch release info:', err); + setError(err); + } finally { + setLoading(false); + } + }; + + fetchLatestRelease(); + }, []); + + return ( +
+ {loading ? ( +
Loading latest release info...
+ ) : error ? ( +
Error: {error.message}
+ ) : releaseInfo ? ( + <> +

Using Maven pom.xml

+ + {` + io.github.ollama4j + ollama4j + ${releaseInfo.name} +`} + +

Using Groovy-based build.gradle

+ + {`dependencies { + implementation 'io.github.ollama4j:ollama4j:${releaseInfo.name}' +}`} + +

For Kotlin-based build.gradle.kts

+ + {`dependencies { + implementation("io.github.ollama4j:ollama4j:${releaseInfo.name}") +}`} + + + ) : null} +
+ ); +}; + +export default AddToYourProject; diff --git a/docs/src/components/LatestRelease/index.js b/docs/src/components/LatestRelease/index.js new file mode 100644 index 0000000..6efd1b5 --- /dev/null +++ b/docs/src/components/LatestRelease/index.js @@ -0,0 +1,51 @@ +import React, { useState, useEffect } from 'react'; + +const LatestRelease = () => { + const [releaseInfo, setReleaseInfo] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + const fetchLatestRelease = async () => { + setLoading(true); + setError(null); + try { + const response = await fetch('https://api.github.com/repos/ollama4j/ollama4j/releases/latest'); + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + const data = await response.json(); + setReleaseInfo(data); + } catch (err) { + console.error('Failed to fetch release info:', err); + setError(err); + } finally { + setLoading(false); + } + }; + + fetchLatestRelease(); + }, []); + + return ( +
+ {loading ? ( +
Loading latest release info...
+ ) : error ? ( +
Error: {error.message}
+ ) : releaseInfo ? ( +
+ {/*

Latest Release

*/} +
+ Latest Version: {releaseInfo.name} released on {new Date(releaseInfo.published_at).toLocaleDateString(undefined, { year: 'numeric', month: 'long', day: 'numeric' })}. +
+ {/*
+                        {JSON.stringify(releaseInfo, null, 2)}
+                    
*/} +
+ ) : null} +
+ ); +}; + +export default LatestRelease; diff --git a/docs/src/pages/index.js b/docs/src/pages/index.js index 8d4dc46..b5f99e9 100644 --- a/docs/src/pages/index.js +++ b/docs/src/pages/index.js @@ -7,39 +7,51 @@ import BuyMeACoffee from '@site/src/components/BuyMeACoffee'; import Heading from '@theme/Heading'; import styles from './index.module.css'; import BrowserOnly from '@docusaurus/BrowserOnly'; +import LatestRelease from '@site/src/components/LatestRelease'; + + function HomepageHeader() { const {siteConfig} = useDocusaurusContext(); - return (
-
- - {siteConfig.title} - - Ollama4j Logo -

{siteConfig.tagline}

-
- - Getting Started - + return ( +
+
+ + {siteConfig.title} + + Ollama4j Logo +

{siteConfig.tagline}

+
+ + Getting Started + +
+
+ +
-
-
); + + ); } export default function Home() { const {siteConfig} = useDocusaurusContext(); - return ( - -
- - - {() => } - -
-
); + +
+ + + {() => } + +
+ + ); } \ No newline at end of file