Skip to content

Commit

Permalink
Improve changelog component
Browse files Browse the repository at this point in the history
  • Loading branch information
DervexDev committed Aug 13, 2024
1 parent 4b98e7e commit 84da353
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/components/Changelog.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react"
import { useEffect, useState } from "react"
import ContentLoader from "react-content-loader"
import Markdown from "react-markdown"

Expand Down Expand Up @@ -71,9 +71,19 @@ function Placeholder() {
export default function Changelog({ link }: { link: string }) {
const [changelog, setChangelog] = useState(<Placeholder />)

fetch(link)
.then((response) => response.text())
.then((text) => setChangelog(<Markdown>{text}</Markdown>))
useEffect(() => {
fetch(link)
.then((response) => response.text())
.then((text) => {
text = text.substring(text.indexOf("##"))

if (text.indexOf("###") > 20) {
text = text.substring(text.indexOf("##", 2))
}

setChangelog(<Markdown>{text}</Markdown>)
})
}, [link])

return changelog
}

0 comments on commit 84da353

Please sign in to comment.