Created
May 16, 2022 06:41
-
-
Save pelly-ryu/bd62af42dc4a672d2cf043249544820b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @jsx h */ | |
import { Fragment, h } from "preact"; | |
import { useEffect, useState } from "preact/compat"; | |
interface PluginInfo { | |
id: string; | |
name: string; | |
author: string; | |
description: string; | |
repo: string; | |
} | |
const fetchPlugins = async () => | |
await window.fetch( | |
"https://raw.githubusercontent.com/obsidianmd/obsidian-releases/HEAD/community-plugins.json" | |
); | |
const PluginTable = async () => { | |
let [plugins, setPlugins] = useState([]); | |
useEffect(() => { | |
(async () => { | |
const resp = await fetchPlugins(); | |
if (!resp.ok) { | |
console.error(resp); | |
return; | |
} | |
setPlugins(await resp.json()); | |
})(); | |
}, []); | |
return ( | |
<table> | |
<thead> | |
<tr> | |
<th>name</th> | |
<th>description</th> | |
<th>author</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
{plugins.map((item) => ( | |
<Fragment key={item.id}> | |
<td>{item.name}</td> | |
<td>{item.description}</td> | |
<td>{item.author}</td> | |
</Fragment> | |
))} | |
</tr> | |
</tbody> | |
</table> | |
); | |
}; | |
export { PluginTable }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment