mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Show description from github repo
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
74e008299a
commit
0e012036d1
@ -10,33 +10,35 @@ import { Extension, getExtensionById } from "./extension-list";
|
|||||||
import { Spinner } from "../spinner";
|
import { Spinner } from "../spinner";
|
||||||
import { ExtensionCard } from "./extension-card";
|
import { ExtensionCard } from "./extension-card";
|
||||||
import { useParams } from "react-router";
|
import { useParams } from "react-router";
|
||||||
|
import { MarkdownViewer } from "../markdown-viewer";
|
||||||
|
|
||||||
export function ExtensionPage() {
|
export function ExtensionPage() {
|
||||||
const [extension, setExtension] = useState<Extension>(null);
|
const [extension, setExtension] = useState<Extension>(null);
|
||||||
|
const [description, setDescription] = useState<string>("");
|
||||||
const { id } = useParams<{ id?: string }>();
|
const { id } = useParams<{ id?: string }>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchExtension() {
|
async function fetchExtension() {
|
||||||
try {
|
return await getExtensionById(id);
|
||||||
const response = await getExtensionById(id);
|
}
|
||||||
|
|
||||||
setExtension(response);
|
async function loadData() {
|
||||||
|
try {
|
||||||
|
const extension = await fetchExtension();
|
||||||
|
const readmeUrl = `${extension.githubRepositoryUrl.replace("github.com", "raw.githubusercontent.com")}/master/README.md`;
|
||||||
|
const description = await (await fetch(readmeUrl)).text();
|
||||||
|
|
||||||
|
setExtension(extension);
|
||||||
|
setDescription(description);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchGithubDescription() {
|
loadData();
|
||||||
const description = await fetch("https://raw.githubusercontent.com/{owner}/{repo}/{branch}/README.md");
|
|
||||||
|
|
||||||
console.log(await description.text());
|
|
||||||
}
|
|
||||||
|
|
||||||
fetchExtension();
|
|
||||||
fetchGithubDescription();
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (!extension) {
|
if (!extension || !description) {
|
||||||
return <Spinner/>;
|
return <Spinner/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +48,7 @@ export function ExtensionPage() {
|
|||||||
<hr />
|
<hr />
|
||||||
<div className={styles.contents}>
|
<div className={styles.contents}>
|
||||||
<div className="github">
|
<div className="github">
|
||||||
GitHub description
|
<MarkdownViewer markdown={description} />
|
||||||
</div>
|
</div>
|
||||||
<div className="metadata">
|
<div className="metadata">
|
||||||
<h3 className="mb-5">Categories</h3>
|
<h3 className="mb-5">Categories</h3>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user