import variables from "@/variables/variables"; import NavBar from "@/components/NavBar"; import { Container, Text , Heading, Flex, Card, Box, Strong, Tooltip, Button} from "@radix-ui/themes"; import timeStampToDate from "@/functions/timeStampToDate"; import Link from "next/link"; export default async function Home() { function truncateText(text) { const maxLength = 48; if (text.length > maxLength) { return text.slice(0, maxLength) + "..."; } return text; } try { const url = variables.BACKEND_URL+"/api/v1/read/latest-shares" const request = await fetch(url, { method: 'GET', next: { revalidate: 0, } }) const response = await request.json(); const shares = response.data; return ( <>
Markdown Share Welcome to markdown share, and alternative to the usual codebins. Here instead of sharing just the code you share markdown and if you want to add code you can just write a codeblock and share it. This methods makes it easier for you to write things like the error, explain what is wrong, etc.
Recent Shares
{shares.map(i => ( {i.title}
{truncateText(i.description || "No description")}
Created on {timeStampToDate(i.createdAt*1)}
{i.views } views
))}
); } catch(e) { console.error(e) return

Internal Server Error

} }