links on index

This commit is contained in:
Karol Wypchlo 2021-02-19 17:34:23 +01:00
parent a7a71f45dd
commit c17710f1f4
1 changed files with 9 additions and 2 deletions

View File

@ -5,9 +5,11 @@ import Link from "next/link";
import useSWR from "swr";
import Layout from "../components/Layout";
import authServerSideProps from "../services/authServerSideProps";
import { SkynetClient } from "skynet-js";
dayjs.extend(relativeTime);
const skynetClient = new SkynetClient(process.env.SKYNET_PORTAL_API ?? "https://siasky.net");
const apiPrefix = process.env.NODE_ENV === "development" ? "/api/stubs" : "";
const fetcher = (url) => fetch(url).then((r) => r.json());
@ -21,9 +23,14 @@ function SkylinkList({ items = [] }) {
{/* <a href="#" className="block hover:bg-gray-50"> */}
<div className="px-4 py-4 sm:px-6">
<div className="flex items-center justify-between">
<p className="text-sm font-medium text-green-600 truncate">
<a
href={skynetClient.getSkylinkUrl(item.skylink)}
className="text-sm font-medium text-green-600 hover:text-green-900 truncate"
target="_blank"
rel="noopener noreferrer"
>
{item.name || "— file name not available —"}
</p>
</a>
<abbr className="text-xs text-gray-400 whitespace-nowrap" title={`sia://${item.skylink}`}>
sia://{item.skylink.substr(0, 5)}…{item.skylink.substr(-5)}
</abbr>