feat: activities page

This commit is contained in:
DIYgod
2023-03-24 00:44:36 +00:00
parent 19a09cc265
commit 20cec796a2
9 changed files with 839 additions and 360 deletions
+3 -1
View File
@@ -167,5 +167,7 @@
"DNS Checking": "DNS 检查中",
"DNS check passed.": "DNS 检查通过。",
"DNS check failed.": "DNS 检查失败。",
"Recheck": "重新检查"
"Recheck": "重新检查",
"Latest": "最新",
"Following": "关注"
}
+2
View File
@@ -29,6 +29,8 @@
"Features": "特色",
"Showcase": "展示柜",
"Integration": "集成",
"Home": "首页",
"Activities": "动态",
"Source Code": "源码",
"Visit": "访问",
"Easy to get started": "简单上手",
+165
View File
@@ -0,0 +1,165 @@
import Link from "next/link"
import { useDate } from "~/hooks/useDate"
import { EmptyState } from "../ui/EmptyState"
import { useRouter } from "next/router"
import { Image } from "~/components/ui/Image"
import { Button } from "~/components/ui/Button"
import { useTranslation } from "next-i18next"
import { useEffect, useState } from "react"
import { useGetFeed } from "~/queries/home"
import { CharacterFloatCard } from "~/components/common/CharacterFloatCard"
import { useAccountState } from "@crossbell/connect-kit"
import InfiniteScroll from "react-infinite-scroller"
export const MainFeed: React.FC<{
type?: "latest" | "recommend" | "following"
}> = ({ type }) => {
const currentCharacterId = useAccountState(
(s) => s.computed.account?.characterId,
)
const feed = useGetFeed({
type: type,
characterId: currentCharacterId,
})
const router = useRouter()
const { t } = useTranslation(["common", "site"])
const date = useDate()
const [isMounted, setIsMounted] = useState(false)
useEffect(() => {
setIsMounted(true)
}, [])
let currentLength = 0
return (
<>
<InfiniteScroll
loadMore={feed.fetchNextPage as any}
hasMore={feed.hasNextPage}
loader={
<div
className="relative mt-4 w-full text-sm text-center py-4"
key={"loading"}
>
Loading ...
</div>
}
>
{feed.isLoading ? (
<div className="text-center">Loading...</div>
) : !feed.data?.pages[0]?.count ? (
<EmptyState />
) : (
<div className="xlog-posts space-y-8">
{feed.data?.pages.map((posts) =>
posts?.list.map((post) => {
currentLength++
return (
<div key={`${post.characterId}-${post.noteId}`}>
<div className="flex items-center space-x-2">
<CharacterFloatCard siteId={post.character?.handle}>
<div className="flex items-center space-x-4 cursor-pointer">
<span className="w-10 h-10 inline-block">
<Image
className="rounded-full"
src={
post.character?.metadata?.content
?.avatars?.[0] ||
"ipfs://bafkreiabgixxp63pg64moxnsydz7hewmpdkxxi3kdsa4oqv4pb6qvwnmxa"
}
alt={post.character?.handle || ""}
width="40"
height="40"
></Image>
</span>
<span className="font-medium">
{post.character?.metadata?.content?.name ||
post.character?.handle}
</span>
</div>
</CharacterFloatCard>
<span className="text-zinc-400">·</span>
<time
dateTime={date.formatToISO(post.createdAt)}
className="xlog-post-date whitespace-nowrap text-zinc-400 text-sm"
>
{t("ago", {
time: date.dayjs
.duration(
date
.dayjs(post?.createdAt)
.diff(date.dayjs(), "minute"),
"minute",
)
.humanize(),
})}
</time>
</div>
<Link
target="_blank"
href={`/api/redirection?characterId=${post.characterId}&noteId=${post.noteId}`}
className="xlog-post sm:hover:bg-hover bg-white transition-all p-4 ml-10 sm:rounded-xl flex flex-col sm:flex-row items-center"
>
<div className="flex-1 flex justify-center flex-col w-full min-w-0">
<h3 className="xlog-post-title text-2xl font-bold text-zinc-700">
{post.metadata?.content?.title}
</h3>
<div className="xlog-post-meta text-sm text-zinc-400 mt-1 space-x-4 flex items-center mr-8">
{!!post.metadata?.content?.tags?.filter(
(tag) => tag !== "post" && tag !== "page",
).length && (
<span className="xlog-post-tags space-x-1 truncate min-w-0">
{post.metadata?.content?.tags
?.filter(
(tag) => tag !== "post" && tag !== "page",
)
.map((tag) => (
<span
className="hover:text-zinc-600"
key={tag}
onClick={(e) => {
e.preventDefault()
router.push(`/tag/${tag}`)
}}
>
#{tag}
</span>
))}
</span>
)}
</div>
<div
className="xlog-post-excerpt mt-3 text-zinc-500 line-clamp-2"
style={{
wordBreak: "break-word",
}}
>
{post.metadata?.content?.summary}
{post.metadata?.content?.summary && "..."}
</div>
</div>
{post.metadata?.content.cover && (
<div className="xlog-post-cover flex items-center relative w-full sm:w-24 h-40 sm:h-24 mt-2 sm:ml-4 sm:mt-0">
<Image
className="object-cover rounded"
alt="cover"
fill={true}
src={post.metadata?.content.cover}
></Image>
</div>
)}
</Link>
</div>
)
}),
)}
</div>
)}
</InfiniteScroll>
</>
)
}
+34 -21
View File
@@ -9,20 +9,35 @@ import { SEOHead } from "../common/SEOHead"
import { UniLink } from "../ui/UniLink"
import { ConnectButton } from "../common/ConnectButton"
import { getSiteLink } from "~/lib/helpers"
import { Link } from "react-scroll"
import { useTranslation } from "next-i18next"
import { Logo } from "~/components/common/Logo"
import { useRouter } from "next/router"
import { cn } from "~/lib/utils"
const tabs = [
{
name: "Home",
link: "/",
},
{
name: "Activities",
link: "/activities",
},
{
name: "Source Code",
link: GITHUB_LINK,
},
]
export function MainLayout({
children,
title,
tabs,
}: {
children?: React.ReactNode
title?: string
tabs?: string[]
}) {
const { t } = useTranslation("index")
const router = useRouter()
return (
<>
@@ -33,32 +48,30 @@ export function MainLayout({
/>
<header className="py-5 fixed w-full top-0 bg-white z-10">
<div className="max-w-screen-lg px-5 mx-auto flex justify-between items-center">
<div className="text-2xl font-extrabold flex items-center">
<UniLink
href="/"
className="text-2xl font-extrabold flex items-center"
>
<div className="inline-block w-9 h-9 mr-3">
<Logo type="lottie" width={36} height={36} autoplay={false} />
</div>
xLog
</div>
</UniLink>
<div className="space-x-14 text-zinc-500 flex">
{tabs?.map((tab, index) => (
<Link
activeClass="text-accent"
className="cursor-pointer items-center hidden sm:flex hover:text-accent"
to={tab}
spy={true}
smooth={true}
duration={500}
key={tab}
<UniLink
className={cn(
"cursor-pointer items-center hidden sm:flex hover:text-accent text-lg",
{
"text-accent": router.pathname === tab.link,
},
)}
key={tab.name}
href={tab.link}
>
{t(tab)}
</Link>
{t(tab.name)}
</UniLink>
))}
<UniLink
href={GITHUB_LINK}
className="items-center hidden sm:flex hover:text-accent"
>
{t("Source Code")}
</UniLink>
<ConnectButton size="base" variantColor="black" />
</div>
</div>
+13
View File
@@ -1,5 +1,6 @@
import type { Note as UniNote, Profile as UniProfile } from "unidata.js"
import { ReactElement } from "react"
import { NoteEntity } from "crossbell.js"
export type Site = {
id: string
@@ -88,6 +89,18 @@ export type Note = UniNote & {
views?: number
}
export type ExpandedNote = NoteEntity & {
metadata: {
content: {
summary?: string
cover?: string
frontMatter?: Record<string, any>
slug?: string
views?: number
}
}
}
export type Notes = {
total: number
list: Note[]
+104
View File
@@ -0,0 +1,104 @@
import { ExpandedNote } from "~/lib/types"
import { indexer } from "@crossbell/indexer"
const expandPage = async (page: ExpandedNote, useStat?: boolean) => {
if (page.metadata?.content) {
if (page.metadata?.content?.content) {
const { renderPageContent } = await import("~/markdown")
const rendered = renderPageContent(page.metadata.content.content, true)
if (!page.metadata.content.summary) {
page.metadata.content.summary = rendered.excerpt
}
page.metadata.content.cover = rendered.cover
if (page.metadata) {
page.metadata.content.frontMatter = rendered.frontMatter
}
}
page.metadata.content.slug = encodeURIComponent(
page.metadata.content.attributes?.find(
(a) => a.trait_type === "xlog_slug",
)?.value || "",
)
if (useStat) {
const stat = await (
await fetch(
`https://indexer.crossbell.io/v1/stat/notes/${page.characterId}/${page.noteId}`,
)
).json()
page.metadata.content.views = stat.viewDetailCount
}
}
return page
}
export async function getFeed({
type,
cursor,
limit = 10,
characterId,
}: {
type?: "latest" | "recommend" | "following"
cursor?: string
limit?: number
characterId?: number
}) {
switch (type) {
case "latest":
const result = await indexer.getNotes({
sources: "xlog",
tags: ["post"],
limit,
cursor,
includeCharacter: true,
})
const list = await Promise.all(
result.list.map(async (page: any) => {
return expandPage(page, true)
}),
)
return {
list,
cursor: result.cursor,
count: result.count,
}
case "following":
if (!characterId) {
return {
list: [],
cursor: "",
count: 0,
}
} else {
const result = await indexer.getFollowingFeedsOfCharacter(characterId, {
// sources: "xlog",
// tags: ["post"],
limit: limit * 2,
cursor,
type: ["POST_NOTE"],
})
const list = await Promise.all(
result.list
.filter((page) => {
return (
page.note?.metadata?.content?.sources?.includes("xlog") &&
page.note?.metadata?.content?.tags?.includes("post")
)
})
.map(async (page: any) => {
return expandPage(page.note, true)
}),
)
return {
list,
cursor: result.cursor,
count: result.count,
}
}
}
}
+168
View File
@@ -0,0 +1,168 @@
import { GetServerSideProps } from "next"
import { ReactElement, useState } from "react"
import { MainLayout } from "~/components/main/MainLayout"
import { UniLink } from "~/components/ui/UniLink"
import { Button } from "~/components/ui/Button"
import { useConnectedAction } from "@crossbell/connect-kit"
import { useRefCallback } from "@crossbell/util-hooks"
import { getSiteLink } from "~/lib/helpers"
import { Image } from "~/components/ui/Image"
import { dehydrate, QueryClient } from "@tanstack/react-query"
import { prefetchGetSites } from "~/queries/site.server"
import { useGetSites } from "~/queries/site"
import showcase from "../../showcase.json"
import { CharacterFloatCard } from "~/components/common/CharacterFloatCard"
import { useAccountSites, useSubscribeToSites } from "~/queries/site"
import { useTranslation } from "next-i18next"
import { serverSideTranslations } from "next-i18next/serverSideTranslations"
import { languageDetector } from "~/lib/language-detector"
import { MainFeed } from "~/components/main/MainFeed"
import { Tabs } from "~/components/ui/Tabs"
export const getServerSideProps: GetServerSideProps = async (ctx) => {
const queryClient = new QueryClient()
await prefetchGetSites(showcase, queryClient)
return {
props: {
...(await serverSideTranslations(languageDetector(ctx), [
"common",
"index",
"dashboard",
])),
dehydratedState: dehydrate(queryClient),
},
}
}
function Activities() {
const showcaseSites = useGetSites(showcase)
const { t } = useTranslation("index")
const userSite = useAccountSites()
const subscribeToSites = useSubscribeToSites()
const doSubscribeToSites = useRefCallback(() => {
subscribeToSites.mutate({
characterIds: showcaseSites.data
?.map((s: { characterId?: string }) => s.characterId)
.filter(Boolean)
.map(Number),
siteIds: showcaseSites.data?.map((s: { handle: string }) => s.handle),
} as any)
})
const followAll = useConnectedAction(() => {
doSubscribeToSites()
})
const [showcaseMore, setShowcaseMore] = useState(false)
const [feedType, setFeedType] = useState<"latest" | "following">(
userSite.data?.length ? "following" : "latest",
)
const tabs = [
{
text: "Latest",
onClick: () => setFeedType("latest"),
active: feedType === "latest",
},
{
text: "Following",
onClick: () => setFeedType("following"),
active: feedType === "following",
},
]
return (
<section className="pt-24">
<div className="max-w-screen-lg px-5 mx-auto flex">
<div className="flex-1 min-w-[300px]">
<Tabs items={tabs} className="border-none text-lg"></Tabs>
<MainFeed type={feedType} />
</div>
<div className="w-80 pl-10 pt-4 hidden sm:block">
<div className="text-center">
<div className="mb-10 text-zinc-700">
<p>
{t(
"Discover these awesome teams and creators on xLog (sorted by update time)",
)}
</p>
<Button
className="mt-5"
onClick={followAll}
isLoading={
showcaseSites.isLoading ||
userSite.isLoading ||
subscribeToSites.isLoading
}
isDisabled={subscribeToSites.isSuccess}
>
🥳{" "}
{subscribeToSites.isSuccess
? t("Already Followed All!")
: t("Follow All!")}
</Button>
<ul
className={`pt-5 overflow-y-clip relative text-left space-y-4 ${
showcaseMore ? "" : "max-h-[540px]"
}`}
>
<div
className={`absolute bottom-0 h-14 left-0 right-0 bg-gradient-to-t from-white via-white flex items-end justify-center font-bold cursor-pointer z-[1] text-sm ${
showcaseMore ? "hidden" : ""
}`}
onClick={() => setShowcaseMore(true)}
>
{t("Show more")}
</div>
{showcaseSites.data?.map((site: any) => (
<li className="flex align-middle" key={site.handle}>
<UniLink
href={getSiteLink({
subdomain: site.handle,
})}
className="inline-flex align-middle w-full"
>
<CharacterFloatCard siteId={site.handle}>
<span className="w-10 h-10 inline-block">
<Image
className="rounded-full"
src={
site.metadata.content?.avatars?.[0] ||
"ipfs://bafkreiabgixxp63pg64moxnsydz7hewmpdkxxi3kdsa4oqv4pb6qvwnmxa"
}
alt={site.handle}
width="40"
height="40"
></Image>
</span>
</CharacterFloatCard>
<span className="ml-3 min-w-0 flex-1 justify-center inline-flex flex-col">
<span className="truncate w-full inline-block font-medium">
{site.metadata.content?.name}
</span>
{site.metadata.content?.bio && (
<span className="text-gray-500 text-xs truncate w-full inline-block mt-1">
{site.metadata.content?.bio}
</span>
)}
</span>
</UniLink>
</li>
))}
</ul>
</div>
</div>
</div>
</div>
</section>
)
}
Activities.getLayout = (page: ReactElement) => {
return <MainLayout>{page}</MainLayout>
}
export default Activities
+330 -338
View File
@@ -1,5 +1,5 @@
import { GetServerSideProps } from "next"
import { useState } from "react"
import { ReactElement, useState } from "react"
import { MainLayout } from "~/components/main/MainLayout"
import { UniLink } from "~/components/ui/UniLink"
import { Button } from "~/components/ui/Button"
@@ -45,7 +45,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
}
}
export default function Home() {
function Home() {
const isConnected = useAccountState((s) => !!s.computed.account)
const router = useRouter()
const showcaseSites = useGetSites(showcase)
@@ -249,122 +249,164 @@ export default function Home() {
const [showcaseMore, setShowcaseMore] = useState(false)
return (
<MainLayout tabs={["Features", "Showcase", "Integration"]}>
<section>
<div className="max-w-screen-lg px-5 mx-auto">
<div className="h-screen w-full flex justify-center flex-col relative text-center">
<h2 className="text-7xl sm:text-8xl font-bold mb-5">
{features.map((feature) => (
<span
key={feature.title}
className={`text-feature text-feature-${feature.title.toLocaleLowerCase()} block sm:inline-block sm:mr-1 mb-2`}
>
{t(feature.title)}
{t(".")}
</span>
))}
</h2>
<h3 className="mt-5 text-zinc-800 text-2xl sm:text-4xl font-light">
<Trans i18nKey="description" ns="index">
<strong className="font-medium">xLog</strong> is the best{" "}
<UniLink
className="underline decoration-2 text-yellow-400 font-medium"
href={CSB_SCAN}
>
on-chain
</UniLink>{" "}
and{" "}
<UniLink
className="underline decoration-2 text-green-400 font-medium"
href={GITHUB_LINK}
>
open-source
</UniLink>{" "}
blogging community for everyone.
</Trans>
</h3>
<div className="my-6 sm:my-12 flex items-center justify-center sm:flex-row flex-col">
<Button
className="text-accent h-10 mt-4 flex items-center"
onClick={tryNow}
size="2xl"
variantColor="black"
>
{isConnected ? (
<>
<span className="i-mingcute-grid-line text-xl mr-2 inline-block"></span>
<span>{t("Dashboard")}</span>
</>
) : (
t("Get my xLog in 5 minutes")
)}
</Button>
<Button
className="text-accent h-10 sm:ml-4 mt-4 flex"
size="2xl"
variant="outline"
variantColor="gradient"
>
<span>
<Link
to={"Showcase"}
spy={true}
smooth={true}
duration={500}
onClick={() => {
setShowcaseMore(true)
}}
>
{t("Look at others'")}
</Link>
</span>
</Button>
</div>
<div className="text-center absolute bottom-14 w-full flex items-center justify-center flex-col">
<span className="mb-3">{t("Explore the xLog way")}</span>
<div className="max-w-screen-lg px-5 mx-auto">
<div className="h-screen w-full flex justify-center flex-col relative text-center">
<h2 className="text-7xl sm:text-8xl font-bold mb-5">
{features.map((feature) => (
<span
key={feature.title}
className={`text-feature text-feature-${feature.title.toLocaleLowerCase()} block sm:inline-block sm:mr-1 mb-2`}
>
{t(feature.title)}
{t(".")}
</span>
))}
</h2>
<h3 className="mt-5 text-zinc-800 text-2xl sm:text-4xl font-light">
<Trans i18nKey="description" ns="index">
<strong className="font-medium">xLog</strong> is the best{" "}
<UniLink
className="underline decoration-2 text-yellow-400 font-medium"
href={CSB_SCAN}
>
on-chain
</UniLink>{" "}
and{" "}
<UniLink
className="underline decoration-2 text-green-400 font-medium"
href={GITHUB_LINK}
>
open-source
</UniLink>{" "}
blogging community for everyone.
</Trans>
</h3>
<div className="my-6 sm:my-12 flex items-center justify-center sm:flex-row flex-col">
<Button
className="text-accent h-10 mt-4 flex items-center"
onClick={tryNow}
size="2xl"
variantColor="black"
>
{isConnected ? (
<>
<span className="i-mingcute-grid-line text-xl mr-2 inline-block"></span>
<span>{t("Dashboard")}</span>
</>
) : (
t("Get my xLog in 5 minutes")
)}
</Button>
<Button
className="text-accent h-10 sm:ml-4 mt-4 flex"
size="2xl"
variant="outline"
variantColor="gradient"
>
<span>
<Link
to="Features"
to={"Showcase"}
spy={true}
smooth={true}
duration={500}
className="cursor-pointer inline-block i-mingcute:down-line text-3xl"
></Link>
</div>
</div>
<div>
<Element name="Features">
{features.map((feature, index) => (
<div className="text-center mt-28" key={feature.title}>
<div className="">
<div
className={`h-20 w-[1px] bg-gradient-to-b mx-auto text-feature-${feature.title.toLocaleLowerCase()}`}
style={
{
"--tw-gradient-from": "transparent",
} as any
}
></div>
<div
className={`block rounded-full w-10 h-10 mx-auto p-2 text-white bg-gradient-to-br text-feature-${feature.title.toLocaleLowerCase()}`}
>
{index + 1}
</div>
<h3
className={`mt-6 inline-block text-3xl font-bold text-feature text-feature-${feature.title.toLocaleLowerCase()}`}
>
{t(feature.title)}
</h3>
<h4 className="mt-6 text-5xl sm:text-6xl font-bold">
{t(`features.${feature.title}.subtitle`)}
</h4>
<p className="mt-6 text-zinc-500">
onClick={() => {
setShowcaseMore(true)
}}
>
{t("Look at others'")}
</Link>
</span>
</Button>
</div>
<div className="text-center absolute bottom-14 w-full flex items-center justify-center flex-col">
<span className="mb-3">{t("Explore the xLog way")}</span>
<Link
to="Features"
spy={true}
smooth={true}
duration={500}
className="cursor-pointer inline-block i-mingcute:down-line text-3xl"
></Link>
</div>
</div>
<div>
<Element name="Features">
{features.map((feature, index) => (
<div className="text-center mt-28" key={feature.title}>
<div className="">
<div
className={`h-20 w-[1px] bg-gradient-to-b mx-auto text-feature-${feature.title.toLocaleLowerCase()}`}
style={
{
"--tw-gradient-from": "transparent",
} as any
}
></div>
<div
className={`block rounded-full w-10 h-10 mx-auto p-2 text-white bg-gradient-to-br text-feature-${feature.title.toLocaleLowerCase()}`}
>
{index + 1}
</div>
<h3
className={`mt-6 inline-block text-3xl font-bold text-feature text-feature-${feature.title.toLocaleLowerCase()}`}
>
{t(feature.title)}
</h3>
<h4 className="mt-6 text-5xl sm:text-6xl font-bold">
{t(`features.${feature.title}.subtitle`)}
</h4>
<p className="mt-6 text-zinc-500">
<Trans
i18nKey={`features.${feature.title}.description`}
components={{
aown: (
<UniLink
className="underline"
href="https://github.com/Crossbell-Box/Crossbell-Contracts/wiki"
>
.
</UniLink>
),
}}
ns="index"
/>
</p>
</div>
<ul className="pt-10 grid grid-cols-1 sm:grid-cols-3 gap-8">
{feature.subfeatures.map((item, index) => (
<li
className="border rounded-xl overflow-hidden bg-white hover:shadow-md hover:scale-105 transition duration-300 cursor-default"
key={item.title}
>
{item.screenshot?.src && (
<div className="w-full h-44">
<Image
className="object-cover"
src={item.screenshot.src}
alt={item.title}
fill
></Image>
</div>
)}
<p className="text-2xl font-bold mt-5 flex items-center px-5">
<span className="mr-3">{item.icon}</span>
<span
className={`text-feature text-feature-${feature.title.toLocaleLowerCase()}`}
>
{t(item.title)}
</span>
</p>
<p className="text-base font-light mt-3 mb-4 leading-normal px-5 text-left">
<Trans
i18nKey={`features.${feature.title}.description`}
i18nKey={`${item.title} text`}
components={{
aown: (
strong: <strong className="font-bold" />,
axfm: (
<UniLink
className="underline"
href="https://github.com/Crossbell-Box/Crossbell-Contracts/wiki"
href={`${getSiteLink({
subdomain: "xlog",
})}/xfm`}
>
.
</UniLink>
@@ -373,238 +415,188 @@ export default function Home() {
ns="index"
/>
</p>
</li>
))}
</ul>
{feature.extra && (
<div className="border rounded-xl overflow-hidden bg-white hover:shadow-md hover:scale-105 transition duration-300 cursor-default mt-10 px-5 py-8 space-y-4">
<div className="font-bold text-3xl">
🤫{" "}
<span
className={`text-feature text-feature-${feature.title.toLocaleLowerCase()}`}
>
{t(`features.${feature.title}.extra.title`)}
</span>
</div>
<ul className="pt-10 grid grid-cols-1 sm:grid-cols-3 gap-8">
{feature.subfeatures.map((item, index) => (
<li
className="border rounded-xl overflow-hidden bg-white hover:shadow-md hover:scale-105 transition duration-300 cursor-default"
key={item.title}
>
{item.screenshot?.src && (
<div className="w-full h-44">
<Image
className="object-cover"
src={item.screenshot.src}
alt={item.title}
fill
></Image>
</div>
)}
<p className="text-2xl font-bold mt-5 flex items-center px-5">
<span className="mr-3">{item.icon}</span>
<span
className={`text-feature text-feature-${feature.title.toLocaleLowerCase()}`}
>
{t(item.title)}
</span>
</p>
<p className="text-base font-light mt-3 mb-4 leading-normal px-5 text-left">
<Trans
i18nKey={`${item.title} text`}
components={{
strong: <strong className="font-bold" />,
axfm: (
<UniLink
className="underline"
href={`${getSiteLink({
subdomain: "xlog",
})}/xfm`}
>
.
</UniLink>
),
}}
ns="index"
/>
</p>
</li>
))}
</ul>
{feature.extra && (
<div className="border rounded-xl overflow-hidden bg-white hover:shadow-md hover:scale-105 transition duration-300 cursor-default mt-10 px-5 py-8 space-y-4">
<div className="font-bold text-3xl">
🤫{" "}
<span
className={`text-feature text-feature-${feature.title.toLocaleLowerCase()}`}
>
{t(`features.${feature.title}.extra.title`)}
</span>
</div>
<div>
{t(`features.${feature.title}.extra.description`)}
</div>
<Button
variantColor="black"
onClick={() =>
window.open(
getSiteLink({
subdomain: "xlog",
}),
)
}
>
{t(`features.${feature.title}.extra.button`)}
</Button>
</div>
)}
</div>
))}
</Element>
<Element name="Showcase" className="text-center">
<div className="pt-32 text-5xl sm:text-6xl font-bold">
{t("Showcase")}
</div>
<div className="my-10 text-zinc-700">
<p className="text-lg">
{t(
"Discover these awesome teams and creators on xLog (sorted by update time)",
)}
</p>
<Button
size="xl"
className="mt-5"
onClick={followAll}
isLoading={
showcaseSites.isLoading ||
userSite.isLoading ||
subscribeToSites.isLoading
}
isDisabled={subscribeToSites.isSuccess}
>
🥳{" "}
{subscribeToSites.isSuccess
? t("Already Followed All!")
: t("Follow All!")}
</Button>
<ul
className={`pt-10 grid grid-cols-2 md:grid-cols-3 gap-10 overflow-y-hidden relative text-left ${
showcaseMore ? "" : "max-h-[540px]"
}`}
>
<div
className={`absolute bottom-0 h-20 left-0 right-0 bg-gradient-to-t from-white via-white flex items-end justify-center font-bold cursor-pointer ${
showcaseMore ? "hidden" : ""
}`}
onClick={() => setShowcaseMore(true)}
<div>{t(`features.${feature.title}.extra.description`)}</div>
<Button
variantColor="black"
onClick={() =>
window.open(
getSiteLink({
subdomain: "xlog",
}),
)
}
>
{t("Show more")}
</div>
{showcaseSites.data?.map((site: any) => (
<li className="inline-flex align-middle" key={site.handle}>
<UniLink
href={getSiteLink({
subdomain: site.handle,
})}
className="inline-flex align-middle w-full"
>
<CharacterFloatCard siteId={site.handle}>
<span className="w-14 h-14 inline-block">
<Image
className="rounded-full"
src={
site.metadata.content?.avatars?.[0] ||
"ipfs://bafkreiabgixxp63pg64moxnsydz7hewmpdkxxi3kdsa4oqv4pb6qvwnmxa"
}
alt={site.handle}
width="56"
height="56"
></Image>
</span>
</CharacterFloatCard>
<span className="ml-3 min-w-0 flex-1 justify-center inline-flex flex-col">
<span className="truncate w-full inline-block font-medium">
{site.metadata.content?.name}
</span>
{site.metadata.content?.bio && (
<span className="text-gray-500 text-xs truncate w-full inline-block mt-1">
{site.metadata.content?.bio}
</span>
)}
</span>
</UniLink>
</li>
))}
<li className="inline-flex h-14 align-middle items-center">
<UniLink
className="inline-block text-accent text-center"
href={`${GITHUB_LINK}/edit/dev/showcase.json`}
>
{t("Submit yours")}
</UniLink>
</li>
</ul>
</div>
</Element>
<Element name="Integration" className="text-center">
<div className="pt-32 text-5xl sm:text-6xl font-bold">
{t("Integration")}
</div>
<div className="my-10 text-zinc-700">
<p className="text-xl">
{t(
"xLog's open design allows it to integrate with many other open protocols and applications without friction.",
)}
</p>
<ul className="mt-14 grid grid-cols-3 sm:grid-cols-5 gap-y-14 gap-x-2">
{integrations.map((item, index) => (
<li
className="hover:scale-105 transition-transform duration-300"
key={index}
>
{item.url ? (
<UniLink
href={item.url}
className="w-full flex items-center flex-col justify-center"
>
<div className="w-12 h-12 rounded-md overflow-hidden">
{item.icon}
</div>
<div className="font-medium sm:text-lg mt-2 text-center">
{item.name}
</div>
</UniLink>
) : (
<Tooltip label={item.text!}>
<div className="w-full h-full flex items-center flex-col justify-center">
<div className="w-12 h-12 rounded-md overflow-hidden">
{item.icon}
</div>
<div className="font-medium sm:text-lg mt-2 text-center">
{item.name}
</div>
</div>
</Tooltip>
)}
</li>
))}
<li className="flex items-center justify-center">
<i className="i-mingcute:more-1-line text-5xl" />
</li>
</ul>
</div>
</Element>
</div>
<div className="my-20 text-center">
<div className="w-20 h-20 mx-auto mb-10">
<Logo type="lottie" width={100} height={100} loop={true} />
{t(`features.${feature.title}.extra.button`)}
</Button>
</div>
)}
</div>
{isConnected ? (
<UniLink
href="/dashboard"
className="text-accent inline-flex items-center space-x-2"
>
<Button size="2xl" variantColor="black">
{t("Get my xLog in 5 minutes")}
</Button>
</UniLink>
) : (
<Button onClick={tryNow} size="2xl" variantColor="black">
{t("Get my xLog in 5 minutes")}
</Button>
)}
))}
</Element>
<Element name="Showcase" className="text-center">
<div className="pt-32 text-5xl sm:text-6xl font-bold">
{t("Showcase")}
</div>
<div className="my-10 text-zinc-700">
<p className="text-lg">
{t(
"Discover these awesome teams and creators on xLog (sorted by update time)",
)}
</p>
<Button
size="xl"
className="mt-5"
onClick={followAll}
isLoading={
showcaseSites.isLoading ||
userSite.isLoading ||
subscribeToSites.isLoading
}
isDisabled={subscribeToSites.isSuccess}
>
🥳{" "}
{subscribeToSites.isSuccess
? t("Already Followed All!")
: t("Follow All!")}
</Button>
<ul
className={`pt-10 grid grid-cols-2 md:grid-cols-3 gap-10 overflow-y-hidden relative text-left ${
showcaseMore ? "" : "max-h-[540px]"
}`}
>
<div
className={`absolute bottom-0 h-20 left-0 right-0 bg-gradient-to-t from-white via-white flex items-end justify-center font-bold cursor-pointer ${
showcaseMore ? "hidden" : ""
}`}
onClick={() => setShowcaseMore(true)}
>
{t("Show more")}
</div>
{showcaseSites.data?.map((site: any) => (
<li className="inline-flex align-middle" key={site.handle}>
<UniLink
href={getSiteLink({
subdomain: site.handle,
})}
className="inline-flex align-middle w-full"
>
<CharacterFloatCard siteId={site.handle}>
<span className="w-14 h-14 inline-block">
<Image
className="rounded-full"
src={
site.metadata.content?.avatars?.[0] ||
"ipfs://bafkreiabgixxp63pg64moxnsydz7hewmpdkxxi3kdsa4oqv4pb6qvwnmxa"
}
alt={site.handle}
width="56"
height="56"
></Image>
</span>
</CharacterFloatCard>
<span className="ml-3 min-w-0 flex-1 justify-center inline-flex flex-col">
<span className="truncate w-full inline-block font-medium">
{site.metadata.content?.name}
</span>
{site.metadata.content?.bio && (
<span className="text-gray-500 text-xs truncate w-full inline-block mt-1">
{site.metadata.content?.bio}
</span>
)}
</span>
</UniLink>
</li>
))}
</ul>
</div>
</Element>
<Element name="Integration" className="text-center">
<div className="pt-32 text-5xl sm:text-6xl font-bold">
{t("Integration")}
</div>
<div className="my-10 text-zinc-700">
<p className="text-xl">
{t(
"xLog's open design allows it to integrate with many other open protocols and applications without friction.",
)}
</p>
<ul className="mt-14 grid grid-cols-3 sm:grid-cols-5 gap-y-14 gap-x-2">
{integrations.map((item, index) => (
<li
className="hover:scale-105 transition-transform duration-300"
key={index}
>
{item.url ? (
<UniLink
href={item.url}
className="w-full flex items-center flex-col justify-center"
>
<div className="w-12 h-12 rounded-md overflow-hidden">
{item.icon}
</div>
<div className="font-medium sm:text-lg mt-2 text-center">
{item.name}
</div>
</UniLink>
) : (
<Tooltip label={item.text!}>
<div className="w-full h-full flex items-center flex-col justify-center">
<div className="w-12 h-12 rounded-md overflow-hidden">
{item.icon}
</div>
<div className="font-medium sm:text-lg mt-2 text-center">
{item.name}
</div>
</div>
</Tooltip>
)}
</li>
))}
<li className="flex items-center justify-center">
<i className="i-mingcute:more-1-line text-5xl" />
</li>
</ul>
</div>
</Element>
</div>
<div className="my-20 text-center">
<div className="w-20 h-20 mx-auto mb-10">
<Logo type="lottie" width={100} height={100} loop={true} />
</div>
</section>
</MainLayout>
{isConnected ? (
<UniLink
href="/dashboard"
className="text-accent inline-flex items-center space-x-2"
>
<Button size="2xl" variantColor="black">
{t("Get my xLog in 5 minutes")}
</Button>
</UniLink>
) : (
<Button onClick={tryNow} size="2xl" variantColor="black">
{t("Get my xLog in 5 minutes")}
</Button>
)}
</div>
</div>
)
}
Home.getLayout = (page: ReactElement) => {
return <MainLayout>{page}</MainLayout>
}
export default Home
+20
View File
@@ -0,0 +1,20 @@
import { useInfiniteQuery } from "@tanstack/react-query"
import * as homeModel from "~/models/home.model"
export const useGetFeed = (data?: {
type?: "latest" | "recommend" | "following"
characterId?: number
limit?: number
}) => {
return useInfiniteQuery({
queryKey: ["getFeed", data],
queryFn: async ({ pageParam }) => {
return homeModel.getFeed({
...data,
cursor: pageParam,
})
},
getNextPageParam: (lastPage) => lastPage?.cursor || undefined,
})
}