feat: index page and site page i18n

This commit is contained in:
DIYgod
2023-02-23 03:37:06 +00:00
parent d0d42619ea
commit 7e8c43c0f6
30 changed files with 305 additions and 167 deletions
+1
View File
@@ -2,5 +2,6 @@ module.exports = {
i18n: {
defaultLocale: "en",
locales: ["en", "zh"],
reloadOnPrerender: process.env.NODE_ENV === "development",
},
}
-5
View File
@@ -112,10 +112,5 @@ module.exports = withBundleAnalyzer(
ENV_OPENSEA_API_KEY: process.env.OPENSEA_API_KEY,
ENV_POAP_API_KEY: process.env.POAP_API_KEY,
},
i18n: {
...i18n,
localeDetection: false,
},
}),
)
+2 -1
View File
@@ -1,3 +1,4 @@
{
"easy": "Easy"
"intlDateTime": "{{val, datetime}}",
"intlRelativeTime": "{{val, relativetime}}"
}
+1
View File
@@ -0,0 +1 @@
{}
+5
View File
@@ -0,0 +1,5 @@
{
"description": "xLog, <1>on-chain</1> and <3>open-source</3> blogging platform for everyone.",
"discover awesome": "Discover these awesome teams and geeks on xLog (sorted by update time)",
"Integration description": "xLog's open design allows it to integrate with many other open protocols and applications without friction."
}
+4
View File
@@ -0,0 +1,4 @@
{
"load more": "There are {{count}} more {{name}}, click to load more",
"signed and stored on the blockchain": "This {{name}} has been signed and securely stored on the blockchain by its creator."
}
+30 -1
View File
@@ -1,3 +1,32 @@
{
"easy": "简单"
"Connect": "连接",
"Followers": "关注者",
"Following": "正在关注",
"Followings": "正在关注",
"Follow": "关注",
"Unfollow": "取消关注",
"intlDateTime": "{{val, datetime}}",
"intlRelativeTime": "{{val, relativetime}}",
"post": "文章",
"posts": "文章",
"page": "页面",
"pages": "页面",
"comment": "评论",
"comments": "评论",
"Comment": "评论",
"Comments": "评论",
"reply": "回复",
"replies": "回复",
"like": "喜欢",
"likes": "喜欢",
"blog": "博客",
"Owner": "所有者",
"Transaction Hash": "交易哈希",
"IPFS Address": "IPF 地址",
"Creation": "创建",
"Last Update": "最后更新",
"Create Character": "创建角色",
"Submit": "提交",
"Reply": "回复",
"Cancel Reply": "取消回复"
}
+1
View File
@@ -0,0 +1 @@
{}
+26
View File
@@ -0,0 +1,26 @@
{
"Blog Free": "自由创作",
"description": "xLog,给所有人的 <1>链上</1> <3>开源</3> 博客平台。",
"Get my xLog in 5 minutes": "5 分钟拥有自己的 xLog",
"Features": "特点",
"Showcase": "展示",
"Integration": "集成",
"Source Code": "源码",
"Visit": "访问",
"Easy": "简单",
"Easy description": "使用 <strong>Web3钱包</strong> 或 <strong>电子邮件</strong> 连接,轻松构建拥有自定义域名、订阅、点赞、评论、NFT铸造、RSS等功能的个人网站,无需任何费用和限制。",
"Safe": "安全",
"Safe description": "所有的博客数据,包括配置、文章、订阅、评论等,都由你亲手签名并安全地存储在<strong>区块链</strong>上,除了你自己,包括我们在内的任何人都无法进行更改。",
"Fast": "快速",
"Fast description": "区块链不意味着低效。xLog 采用高效的缓存机制和多项优化措施,发挥了极致的性能。",
"Customizable": "可定制",
"Customizable description": "使用自己的<strong>域名</strong>,自定义网站<strong>风格</strong>,完全自由地打造你的网站。这是你的网站,没有任何限制。",
"Open": "开放",
"Open description": "采用标准的 <strong>Markdown</strong> 语法,并提供了导入和导出工具以及丰富的API,让迁入和迁出变得轻而易举。所有的代码都<strong>开源</strong>在 GitHub 上,所有的<strong>数据都透明</strong>地存储在区块链上。",
"discover awesome": "在 xLog 上发现这些超棒的团队和极客们(按更新时间排序)",
"Follow All!": "关注所有!",
"Show more": "显示更多",
"Submit yours": "提交你的",
"Integration description": "xLog 的开放式设计使其能够与许多其他开放协议和应用程序无缝集成,没有任何限制。",
"Dashboard": "仪表盘"
}
+8
View File
@@ -0,0 +1,8 @@
{
"Home": "主页",
"Archives": "归档",
"About": "关于",
"load more": "还有 {{count}} 篇{{name}},点击加载更多",
"signed and stored on the blockchain": "此{{name}}已经由它的创作者签名并安全地存储在区块链上。",
"Write a comment on the blockchain": "在区块链上写下你的评论"
}
+18 -13
View File
@@ -6,11 +6,15 @@ import { ChevronUpIcon } from "@heroicons/react/20/solid"
import { BlockchainIcon } from "~/components/icons/BlockchainIcon"
import { toIPFS, toGateway } from "~/lib/ipfs-parser"
import { IPFS_GATEWAY } from "~/lib/env"
import { useTranslation } from "next-i18next"
export const BlockchainInfo: React.FC<{
site?: Profile | null
page?: Note | null
}> = ({ site, page }) => {
const { t } = useTranslation("common")
const { t: siteT } = useTranslation("site")
return (
<div className="text-sm">
<Disclosure defaultOpen={true}>
@@ -23,14 +27,15 @@ export const BlockchainInfo: React.FC<{
<span>
<BlockchainIcon className="w-4 h-4 inline-block align-middle mr-2" />
<span className="align-middle">
This{" "}
{page
? page.tags?.includes("post")
? "post"
: "page"
: "blog"}{" "}
has been signed and securely stored on the blockchain by its
creator.
{siteT("signed and stored on the blockchain", {
name: t(
page
? page.tags?.includes("post")
? "post"
: "page"
: "blog",
),
})}
</span>
</span>
<ChevronUpIcon
@@ -58,7 +63,7 @@ export const BlockchainInfo: React.FC<{
</li>
)}
<li>
<div className="font-medium">Owner</div>
<div className="font-medium">{t("Owner")}</div>
<div>
<a
target="_blank"
@@ -74,7 +79,7 @@ export const BlockchainInfo: React.FC<{
</div>
</li>
<li>
<div className="font-medium">Transaction Hash</div>
<div className="font-medium">{t("Transaction Hash")}</div>
<div>
{page
? page?.related_urls
@@ -88,7 +93,7 @@ export const BlockchainInfo: React.FC<{
href={url}
key={url}
>
{index === 0 ? "Creation" : "Last Update"}{" "}
{t(index === 0 ? "Creation" : "Last Update")}{" "}
{url
.replace(CSB_SCAN + "/tx/", "")
.slice(0, 10)}
@@ -107,7 +112,7 @@ export const BlockchainInfo: React.FC<{
href={`${CSB_SCAN}/tx/${hash}`}
key={hash}
>
{index === 0 ? "Creation" : "Last Update"}{" "}
{t(index === 0 ? "Creation" : "Last Update")}{" "}
{hash.slice(0, 10)}...{hash.slice(-10)}
</a>
)
@@ -116,7 +121,7 @@ export const BlockchainInfo: React.FC<{
</div>
</li>
<li>
<div className="font-medium">IPFS Address</div>
<div className="font-medium">{t("IPFS Address")}</div>
<div>
{page
? page.related_urls
+8 -2
View File
@@ -3,6 +3,7 @@ import { Note } from "~/lib/types"
import { useGetComments } from "~/queries/page"
import { CommentItem } from "~/components/common/CommentItem"
import { CommentInput } from "~/components/common/CommentInput"
import { useTranslation } from "next-i18next"
export const Comment: React.FC<{
page?: Note | null
@@ -11,13 +12,18 @@ export const Comment: React.FC<{
const comments = useGetComments({
pageId: page?.id,
})
const { t } = useTranslation("common")
return (
<div className={clsx("xlog-comment", "comment", className)} id="comments">
<div className="xlog-comment-count border-b pb-2 mb-6">
<span>
{comments.data?.count || "0"} Comment
{comments.data?.count && comments.data.count > 1 ? "s" : ""}
{comments.data?.count || "0"}{" "}
{t(
`Comment${
comments.data?.count && comments.data.count > 1 ? "s" : ""
}`,
)}
</span>
</div>
<CommentInput pageId={page?.id} />
+11 -6
View File
@@ -11,6 +11,7 @@ import { useRouter } from "next/router"
import { EmojiPicker } from "./EmojiPicker"
import { Popover } from "@headlessui/react"
import { FaceSmileIcon } from "@heroicons/react/24/outline"
import { useTranslation } from "next-i18next"
export const CommentInput: React.FC<{
pageId?: string
@@ -21,6 +22,8 @@ export const CommentInput: React.FC<{
const commentPage = useCommentPage()
const router = useRouter()
const [viewer, setViewer] = useState<Profile | null>(null)
const { t } = useTranslation("common")
const { t: siteT } = useTranslation("site")
useEffect(() => {
if (userSites.isSuccess && userSites.data?.length) {
@@ -73,7 +76,7 @@ export const CommentInput: React.FC<{
multiline
maxLength={300}
className="mb-2"
placeholder="Write a comment on the blockchain"
placeholder={siteT("Write a comment on the blockchain") || ""}
{...form.register("content", {})}
/>
</div>
@@ -101,11 +104,13 @@ export const CommentInput: React.FC<{
type="submit"
isLoading={userSites.isLoading || commentPage.isLoading}
>
{account
? userSites.isSuccess && !userSites.data?.length
? "Create Character"
: "Submit"
: "Connect"}
{t(
account
? userSites.isSuccess && !userSites.data?.length
? "Create Character"
: "Submit"
: "Connect",
)}
</Button>
</div>
</form>
+3 -1
View File
@@ -11,6 +11,7 @@ import { Reactions } from "~/components/common/Reactions"
import { useState } from "react"
import { CommentInput } from "~/components/common/CommentInput"
import { CharacterFloatCard } from "~/components/common/CharacterFloatCard"
import { useTranslation } from "next-i18next"
export const CommentItem: React.FC<{
comment: NoteEntity & {
@@ -20,6 +21,7 @@ export const CommentItem: React.FC<{
depth: number
}> = ({ comment, originalId, depth }) => {
const [replyOpen, setReplyOpen] = useState(false)
const { t } = useTranslation("common")
return (
<div
@@ -91,7 +93,7 @@ export const CommentItem: React.FC<{
variant="text"
onClick={() => setReplyOpen(!replyOpen)}
>
{replyOpen ? "Cancel " : ""}Reply
{t(`${replyOpen ? "Cancel " : ""}Reply`)}
<span className="ml-1">
{(comment as any)?.fromNotes?.count || 0}
</span>
+10 -2
View File
@@ -12,7 +12,6 @@ import {
import { useAccountSites } from "~/queries/site"
import { Avatar } from "~/components/ui/Avatar"
import { Button } from "~/components/ui/Button"
import type { HeaderLinkType } from "~/components/site/SiteHeader"
import { DashboardIcon } from "../icons/DashboardIcon"
import { UniLink } from "../ui/UniLink"
import { useEffect, useState } from "react"
@@ -36,6 +35,14 @@ import {
} from "@crossbell/notification"
import { useAccountBalance } from "~/hooks/use-account-balance"
import { Menu } from "~/components/ui/Menu"
import { useTranslation } from "next-i18next"
type HeaderLinkType = {
icon?: React.ReactNode
label: string | JSX.Element
url?: string
onClick?: () => void
}
export const ConnectButton: React.FC<{
left?: boolean
@@ -87,6 +94,7 @@ export const ConnectButton: React.FC<{
const { isAllRead } = useNotifications()
const [InsufficientBalance, setInsufficientBalance] = useState<boolean>(false)
const { t } = useTranslation("common")
useEffect(() => {
if (balance) {
@@ -184,7 +192,7 @@ export const ConnectButton: React.FC<{
style={{ height: avatarSize + "px" }}
variant={variant || "primary"}
>
Connect
{t("Connect")}
</Button>
)
}
+8 -4
View File
@@ -10,6 +10,7 @@ import {
import { useConnectedAction } from "@crossbell/connect-kit"
import clsx from "clsx"
import { Profile } from "~/lib/types"
import { useTranslation } from "next-i18next"
export const FollowingButton: React.FC<{
site: Profile | undefined | null
@@ -22,6 +23,7 @@ export const FollowingButton: React.FC<{
const unsubscribeFromSite = useUnsubscribeFromSite()
const userSite = useAccountSites()
const characterId = site?.metadata?.proof ? Number(site.metadata.proof) : null
const { t } = useTranslation("common")
const handleClickSubscribe = useConnectedAction(() => {
if (characterId) {
@@ -63,7 +65,7 @@ export const FollowingButton: React.FC<{
<Button
variant={variant}
onClick={handleClickSubscribe}
className={clsx(className, "align-middle space-x-1")}
className={clsx(className, "align-middle space-x-1 group")}
isLoading={
subscription.data
? unsubscribeFromSite.isLoading || subscribeToSite.isLoading
@@ -78,11 +80,13 @@ export const FollowingButton: React.FC<{
<span className="i-bxs:bell"></span>
{subscription.data ? (
<>
<span className="pr-1 group-hover:hidden w-16">Following</span>
<span className="pr-1 hidden group-hover:block w-16">Unfollow</span>
<span className="pr-1 group-hover:hidden w-16">{t("Following")}</span>
<span className="pr-1 hidden group-hover:block w-16">
{t("Unfollow")}
</span>
</>
) : (
<span className="pr-1">Follow</span>
<span className="pr-1">{t("Follow")}</span>
)}
</Button>
)
+4 -2
View File
@@ -10,6 +10,7 @@ import {
useGetSiteSubscriptions,
useGetSiteToSubscriptions,
} from "~/queries/site"
import { useTranslation } from "next-i18next"
export const FollowingCount: React.FC<{
siteId?: string
@@ -17,6 +18,7 @@ export const FollowingCount: React.FC<{
}> = ({ siteId, disableList }) => {
let [isFollowListOpen, setIsFollowListOpen] = useState(false)
let [isToFollowListOpen, setIsToFollowListOpen] = useState(false)
const { t } = useTranslation("common")
const subscriptions = useGetSiteSubscriptions({
siteId: siteId || "",
@@ -97,7 +99,7 @@ export const FollowingCount: React.FC<{
<span className="font-bold text-zinc-700">
{subscriptions.data?.total || 0}
</span>{" "}
Followers
{t("Followers")}
</span>
<span
className={
@@ -109,7 +111,7 @@ export const FollowingCount: React.FC<{
<span className="font-bold text-zinc-700">
{toSubscriptions.data?.total || 0}
</span>{" "}
Followings
{t("Followings")}
</span>
{!disableList && (
<CharacterList
+13 -4
View File
@@ -25,6 +25,7 @@ import { nanoid } from "nanoid"
import { renderPageContent } from "~/markdown"
import { Tooltip } from "../ui/Tooltip"
import { APP_NAME } from "~/lib/env"
import { useTranslation } from "next-i18next"
export const PagesManager: React.FC<{
isPost: boolean
@@ -44,6 +45,7 @@ export const PagesManager: React.FC<{
const createOrUpdatePage = useCreateOrUpdatePage()
const [convertToastId, setConvertToastId] = useState("")
const [deleteToastId, setDeleteToastId] = useState("")
const { t } = useTranslation(["site", "common"])
useEffect(() => {
if (deletePage.isSuccess) {
@@ -460,10 +462,17 @@ export const PagesManager: React.FC<{
onClick={pages.fetchNextPage as () => void}
isLoading={pages.isFetchingNextPage}
>
There are {(pages.data?.pages?.[0].total || 0) - currentLength} more{" "}
{isPost ? "post" : "page"}
{(pages.data?.pages?.[0].total || 0) - currentLength > 1 ? "s" : ""}
, click to load more
{t("load more", {
name: t(
isPost
? "post"
: "page" +
((pages.data?.pages?.[0].total || 0) - currentLength > 1
? "s"
: ""),
),
count: (pages.data?.pages?.[0].total || 0) - currentLength,
})}
</Button>
)}
</div>
+6 -3
View File
@@ -11,6 +11,7 @@ import { ConnectButton } from "../common/ConnectButton"
import { getSiteLink } from "~/lib/helpers"
import Image from "next/image"
import { Link } from "react-scroll"
import { useTranslation } from "next-i18next"
export function MainLayout({
children,
@@ -21,6 +22,8 @@ export function MainLayout({
title?: string
tabs?: string[]
}) {
const { t } = useTranslation("index")
return (
<>
<SEOHead
@@ -28,7 +31,7 @@ export function MainLayout({
siteName={APP_NAME}
description={APP_DESCRIPTION}
/>
<header className="py-5 fixed w-full top-0 bg-white z-50">
<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-3xl font-extrabold flex items-center">
<div className="inline-block w-9 h-9">
@@ -51,14 +54,14 @@ export function MainLayout({
duration={500}
key={tab}
>
{tab}
{t(tab)}
</Link>
))}
<UniLink
href={GITHUB_LINK}
className="items-center hidden sm:flex hover:text-accent"
>
Source Code
{t("Source Code")}
</UniLink>
<ConnectButton size="base" />
</div>
+13 -11
View File
@@ -1,4 +1,4 @@
import { formatDate, formatToISO } from "~/lib/date"
import { formatToISO } from "~/lib/date"
import { BlockchainIcon } from "~/components/icons/BlockchainIcon"
import { UniLink } from "~/components/ui/UniLink"
import { Note, Profile } from "~/lib/types"
@@ -9,17 +9,14 @@ import { getSiteLink } from "~/lib/helpers"
import { Avatar } from "~/components/ui/Avatar"
import { EyeIcon, PencilSquareIcon } from "@heroicons/react/24/outline"
import { useUserRole } from "~/hooks/useUserRole"
import { useTranslation } from "next-i18next"
export const PostMeta: React.FC<{
page: Note
site?: Profile | null
author?: Profile | null
}> = ({ page, site, author }) => {
const [isMounted, setIsMounted] = useState(false)
useEffect(() => {
setIsMounted(true)
}, [])
const { t } = useTranslation("common")
const [showEdit, setShowEdit] = useState(false)
const userRole = useUserRole(site?.username)
@@ -35,11 +32,16 @@ export const PostMeta: React.FC<{
dateTime={formatToISO(page.date_published)}
className="xlog-post-date whitespace-nowrap"
>
{formatDate(
page.date_published,
undefined,
isMounted ? undefined : "America/Los_Angeles",
)}
{t("intlDateTime", {
val: new Date(page.date_published),
formatParams: {
val: {
year: "numeric",
month: "short",
day: "numeric",
},
},
})}
</time>
{page.tags?.filter((tag) => tag !== "post" && tag !== "page").length ? (
<>
+5 -3
View File
@@ -18,10 +18,11 @@ import { FastAverageColor } from "fast-average-color"
import { useState, useRef, useEffect, RefObject } from "react"
import chroma from "chroma-js"
import { Menu } from "~/components/ui/Menu"
import { useTranslation } from "next-i18next"
export type HeaderLinkType = {
type HeaderLinkType = {
icon?: React.ReactNode
label: string | JSX.Element
label: string
url?: string
onClick?: () => void
}
@@ -30,6 +31,7 @@ const fac = new FastAverageColor()
const HeaderLink: React.FC<{ link: HeaderLinkType }> = ({ link }) => {
const router = useRouter()
const { t } = useTranslation("site")
const active = router.asPath === link.url
return (
<UniLink
@@ -43,7 +45,7 @@ const HeaderLink: React.FC<{ link: HeaderLinkType }> = ({ link }) => {
)}
>
{link.icon && <span>{link.icon}</span>}
<span>{link.label}</span>
<span>{t(link.label)}</span>
</UniLink>
)
}
+20 -16
View File
@@ -1,12 +1,12 @@
import Link from "next/link"
import { formatDate, formatToISO } from "~/lib/date"
import { formatToISO } from "~/lib/date"
import { Notes } from "~/lib/types"
import { EmptyState } from "../ui/EmptyState"
import { useRouter } from "next/router"
import { Image } from "~/components/ui/Image"
import { Button } from "~/components/ui/Button"
import { useEffect, useState } from "react"
import { EyeIcon } from "@heroicons/react/24/outline"
import { useTranslation } from "next-i18next"
export const SiteHome: React.FC<{
postPages?: Notes[]
@@ -15,12 +15,8 @@ export const SiteHome: React.FC<{
isFetchingNextPage?: boolean
}> = ({ postPages, fetchNextPage, hasNextPage, isFetchingNextPage }) => {
const router = useRouter()
const [isMounted, setIsMounted] = useState(false)
useEffect(() => {
setIsMounted(true)
}, [])
const { t } = useTranslation("common")
const { t: siteT } = useTranslation("site")
if (!postPages?.length) return null
@@ -49,11 +45,16 @@ export const SiteHome: React.FC<{
dateTime={formatToISO(post.date_published)}
className="xlog-post-date whitespace-nowrap"
>
{formatDate(
post.date_published,
undefined,
isMounted ? undefined : "America/Los_Angeles",
)}
{t("intlDateTime", {
val: new Date(post.date_published),
formatParams: {
val: {
year: "numeric",
month: "short",
day: "numeric",
},
},
})}
</time>
{!!post.tags?.filter(
(tag) => tag !== "post" && tag !== "page",
@@ -114,9 +115,12 @@ export const SiteHome: React.FC<{
isLoading={isFetchingNextPage}
aria-label="load more"
>
There are {postPages[0].total - currentLength} more post
{postPages[0].total - currentLength > 1 ? "s" : ""}, click to load
more
{siteT("load more", {
name: t(
"post" + (postPages[0].total - currentLength > 1 ? "s" : ""),
),
count: postPages[0].total - currentLength,
})}
</Button>
)}
</>
+7 -1
View File
@@ -8,6 +8,8 @@ import { PageVisibilityEnum } from "~/lib/types"
import { dehydrate, QueryClient } from "@tanstack/react-query"
import { fetchGetPage } from "~/queries/page.server"
import { notFound } from "~/lib/server-side-props"
import { serverSideTranslations } from "next-i18next/serverSideTranslations"
import { languageDetector } from "~/lib/language-detector"
export const getServerSideProps = async (
ctx: any,
@@ -83,7 +85,11 @@ export const getServerSideProps = async (
return {
props: {
dehydratedState: dehydrate(queryClient),
...(await serverSideTranslations(languageDetector(ctx), [
"common",
"site",
])),
dehydratedState: JSON.parse(JSON.stringify(dehydrate(queryClient))),
},
}
}
+7 -1
View File
@@ -1,5 +1,11 @@
import type { GetServerSidePropsContext } from "next"
import url from "url"
export const languageDetector = (ctx: GetServerSidePropsContext) => {
return ctx.req.headers["accept-language"]?.split(",")[0].split("-")[0] || "en"
const queryLang = url.parse(ctx.req.url!, true).query.lang as string
return (
queryLang ||
ctx.req.headers["accept-language"]?.split(",")[0].split("-")[0] ||
"en"
)
}
+9 -5
View File
@@ -3,7 +3,7 @@ import { SiteLayout } from "~/components/site/SiteLayout"
import { getServerSideProps as getLayoutServerSideProps } from "~/components/site/SiteLayout.server"
import { SitePage } from "~/components/site/SitePage"
import { serverSidePropsHandler } from "~/lib/server-side-props"
import { dehydrate, QueryClient } from "@tanstack/react-query"
import { QueryClient } from "@tanstack/react-query"
import { useGetPage } from "~/queries/page"
import { useGetSite } from "~/queries/site"
import type { ReactElement } from "react"
@@ -14,13 +14,17 @@ export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
const domainOrSubdomain = ctx.params!.site as string
const pageSlug = ctx.params!.page as string
await getLayoutServerSideProps(ctx, queryClient, {
useStat: true,
})
const { props: layoutProps } = await getLayoutServerSideProps(
ctx,
queryClient,
{
useStat: true,
},
)
return {
props: {
dehydratedState: dehydrate(queryClient),
...layoutProps,
domainOrSubdomain,
pageSlug,
},
+9 -5
View File
@@ -4,7 +4,7 @@ import { getServerSideProps as getLayoutServerSideProps } from "~/components/sit
import { serverSidePropsHandler } from "~/lib/server-side-props"
import { SiteArchives } from "~/components/site/SiteArchives"
import { Profile, Notes } from "~/lib/types"
import { dehydrate, QueryClient } from "@tanstack/react-query"
import { QueryClient } from "@tanstack/react-query"
import { useGetPagesBySiteLite } from "~/queries/page"
import { PageVisibilityEnum } from "~/lib/types"
import type { ReactElement } from "react"
@@ -13,13 +13,17 @@ export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
async (ctx) => {
const queryClient = new QueryClient()
const domainOrSubdomain = ctx.params!.site as string
await getLayoutServerSideProps(ctx, queryClient, {
take: 100,
})
const { props: layoutProps } = await getLayoutServerSideProps(
ctx,
queryClient,
{
take: 100,
},
)
return {
props: {
dehydratedState: JSON.parse(JSON.stringify(dehydrate(queryClient))),
...layoutProps,
domainOrSubdomain,
},
}
+9 -5
View File
@@ -2,7 +2,7 @@ import { GetServerSideProps } from "next"
import { SiteHome } from "~/components/site/SiteHome"
import { SiteLayout } from "~/components/site/SiteLayout"
import { getServerSideProps as getLayoutServerSideProps } from "~/components/site/SiteLayout.server"
import { dehydrate, QueryClient } from "@tanstack/react-query"
import { QueryClient } from "@tanstack/react-query"
import { useGetPagesBySiteLite } from "~/queries/page"
import { PageVisibilityEnum } from "~/lib/types"
import type { ReactElement } from "react"
@@ -10,13 +10,17 @@ import type { ReactElement } from "react"
export const getServerSideProps: GetServerSideProps = async (ctx) => {
const queryClient = new QueryClient()
const domainOrSubdomain = ctx.params!.site as string
await getLayoutServerSideProps(ctx, queryClient, {
useStat: true,
})
const { props: layoutProps } = await getLayoutServerSideProps(
ctx,
queryClient,
{
useStat: true,
},
)
return {
props: {
dehydratedState: JSON.parse(JSON.stringify(dehydrate(queryClient))),
...layoutProps,
domainOrSubdomain,
},
}
+9 -5
View File
@@ -1,7 +1,7 @@
import { GetServerSideProps } from "next"
import { SiteLayout } from "~/components/site/SiteLayout"
import { getServerSideProps as getLayoutServerSideProps } from "~/components/site/SiteLayout.server"
import { dehydrate, QueryClient } from "@tanstack/react-query"
import { QueryClient } from "@tanstack/react-query"
import { useGetSite, useGetNFTs } from "~/queries/site"
import { ReactElement, useEffect, useState } from "react"
import type { Asset } from "unidata.js"
@@ -12,13 +12,17 @@ import { UniLink } from "~/components/ui/UniLink"
export const getServerSideProps: GetServerSideProps = async (ctx) => {
const queryClient = new QueryClient()
const domainOrSubdomain = ctx.params!.site as string
await getLayoutServerSideProps(ctx, queryClient, {
skipPages: true,
})
const { props: layoutProps } = await getLayoutServerSideProps(
ctx,
queryClient,
{
skipPages: true,
},
)
return {
props: {
dehydratedState: JSON.parse(JSON.stringify(dehydrate(queryClient))),
...layoutProps,
domainOrSubdomain,
},
}
+9 -5
View File
@@ -4,7 +4,7 @@ import { getServerSideProps as getLayoutServerSideProps } from "~/components/sit
import { serverSidePropsHandler } from "~/lib/server-side-props"
import { SiteArchives } from "~/components/site/SiteArchives"
import { Profile, Notes } from "~/lib/types"
import { dehydrate, QueryClient } from "@tanstack/react-query"
import { QueryClient } from "@tanstack/react-query"
import { useGetPagesBySiteLite } from "~/queries/page"
import { PageVisibilityEnum } from "~/lib/types"
import type { ReactElement } from "react"
@@ -15,13 +15,17 @@ export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
const domainOrSubdomain = ctx.params!.site as string
const tag = ctx.params!.tag as string
await getLayoutServerSideProps(ctx, queryClient, {
take: 100,
})
const { props: layoutProps } = await getLayoutServerSideProps(
ctx,
queryClient,
{
take: 100,
},
)
return {
props: {
dehydratedState: JSON.parse(JSON.stringify(dehydrate(queryClient))),
...layoutProps,
domainOrSubdomain,
tag,
},
+49 -66
View File
@@ -33,7 +33,7 @@ import {
XShopLogo,
CrossbellChainLogo,
} from "@crossbell/ui"
import { useTranslation } from "next-i18next"
import { useTranslation, Trans } from "next-i18next"
import { serverSideTranslations } from "next-i18next/serverSideTranslations"
import { languageDetector } from "~/lib/language-detector"
@@ -43,7 +43,10 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
return {
props: {
...(await serverSideTranslations(languageDetector(ctx), ["common"])),
...(await serverSideTranslations(languageDetector(ctx), [
"common",
"index",
])),
dehydratedState: dehydrate(queryClient),
},
}
@@ -53,7 +56,7 @@ export default function Home() {
const isConnected = useAccountState((s) => !!s.computed.account)
const router = useRouter()
const showcaseSites = useGetSites(showcase)
const { t } = useTranslation("common")
const { t } = useTranslation("index")
const tryNow = useConnectedAction(() => {
router.push("/dashboard")
@@ -65,15 +68,8 @@ export default function Home() {
src: "/assets/easy.png",
},
icon: <LaughIcon />,
title: t("easy"),
text: (
<>
Connect with your <span className="font-bold">Web3 Wallet</span> or{" "}
<span className="font-bold">Email</span>. Build your own site with
custom domains, subscriptions, likes, comments, minting as nft, RSS
and more in one second. No fees, no friction.
</>
),
title: "Easy",
text: "Connect with your <strong>Web3 Wallet</strong> or <strong>Email</strong>. Build your own site with custom domains, subscriptions, likes, comments, minting as nft, RSS and more in one second. No fees, no friction.",
},
{
screenshot: {
@@ -81,14 +77,7 @@ export default function Home() {
},
icon: <FingerPrintIcon className="w-7 h-7" />,
title: "Safe",
text: (
<>
All blog data, including configs, posts, subscriptions, comments,
etc., are signed and securely stored on the{" "}
<span className="font-bold">blockchain</span> with your own hands. No
one else, including us, can make any changes.
</>
),
text: "All blog data, including configs, posts, subscriptions, comments, etc., are signed and securely stored on the <strong>blockchain</strong> with your own hands. No one else, including us, can make any changes.",
},
{
screenshot: {
@@ -96,13 +85,7 @@ export default function Home() {
},
icon: <BoltIcon className="w-7 h-7" />,
title: "Fast",
text: (
<>
Blockchain doesn&apos;t always mean inefficiency. xLog&apos;s
efficient caching mechanism and numerous optimisations take it to the
peak of performance.
</>
),
text: "Blockchain doesn't always mean inefficiency. xLog's efficient caching mechanism and numerous optimisations take it to the peak of performance.",
},
{
screenshot: {
@@ -110,7 +93,7 @@ export default function Home() {
},
icon: <DashboardIcon />,
title: "Customizable",
text: "Use your own domain, customise your site and style it however you like. This is your site, there are no restrictions.",
text: "Use your own <strong>domain</strong>, customise your site and <strong>style</strong> it however you like. This is your site, there are no restrictions.",
},
{
screenshot: {
@@ -118,14 +101,7 @@ export default function Home() {
},
icon: <BlockchainIcon className="w-6 h-6" />,
title: "Open",
text: (
<>
Uses <span className="font-bold">standard Markdown</span> with export
and import tools and rich APIs for a painless move in and out. All
code is <span className="font-bold">open source</span> on GitHub, all
data is <span className="font-bold">transparent</span> on the chain.
</>
),
text: "Uses standard <strong>Markdown</strong> with export and import tools and rich APIs for a painless move in and out. All code is <strong>open source</strong> on GitHub, all <strong>data is transparent</strong> on the chain.",
},
]
@@ -244,17 +220,21 @@ export default function Home() {
height={200}
/>
</div>
<h2 className="text-3xl sm:text-5xl font-bold mb-5">Blog Free</h2>
<h2 className="text-3xl sm:text-5xl font-bold mb-5">
{t("Blog Free")}
</h2>
<h3 className="mt-5 text-zinc-800 text-4xl sm:text-6xl font-light">
{APP_NAME}, the first{" "}
<UniLink className="underline decoration-2" href={CSB_SCAN}>
on-chain
</UniLink>{" "}
and{" "}
<UniLink className="underline decoration-2" href={GITHUB_LINK}>
open-source
</UniLink>{" "}
blogging platform for everyone.
<Trans i18nKey="description" ns="index">
xLog, the first{" "}
<UniLink className="underline decoration-2" href={CSB_SCAN}>
on-chain
</UniLink>{" "}
and{" "}
<UniLink className="underline decoration-2" href={GITHUB_LINK}>
open-source
</UniLink>{" "}
blogging platform for everyone.
</Trans>
</h3>
<div className="my-10 sm:my-16">
<Button
@@ -265,10 +245,10 @@ export default function Home() {
{isConnected ? (
<>
<span className="i-bi-grid text-lg mr-2"></span>
<span>Dashboard</span>
<span>{t("Dashboard")}</span>
</>
) : (
"Get my xLog in 5 minutes"
t("Get my xLog in 5 minutes")
)}
</Button>
</div>
@@ -296,7 +276,9 @@ export default function Home() {
width={3785}
height={2170}
></Image>
<p className="text-center">Visit xlog.{OUR_DOMAIN}</p>
<p className="text-center">
{t("Visit")} xlog.{OUR_DOMAIN}
</p>
</UniLink>
<ul className="pt-20 grid grid-cols-1 sm:grid-cols-3 gap-8">
{features.map((item, index) => (
@@ -314,22 +296,26 @@ export default function Home() {
</div>
<p className="text-2xl font-bold mt-5 flex items-center px-5">
<span className="mr-3">{item.icon}</span>
<span>{item.title}</span>
<span>{t(item.title)}</span>
</p>
<p className="text-base font-light mt-3 mb-4 leading-normal px-5">
{item.text}
<Trans
i18nKey={`${item.title} description`}
defaults={item.text}
components={{
strong: <strong className="font-bold" />,
}}
ns="index"
/>
</p>
</li>
))}
</ul>
</Element>
<Element name="Showcase">
<div className="pt-28 text-4xl font-bold">Showcase</div>
<div className="pt-28 text-4xl font-bold">{t("Showcase")}</div>
<div className="my-10 text-zinc-700">
<p className="text-lg">
Discover these awesome teams and geeks on xLog (sorted by
update time)
</p>
<p className="text-lg">{t("discover awesome")}</p>
<Button
size="xl"
className="mt-5"
@@ -340,7 +326,7 @@ export default function Home() {
subscribeToSites.isLoading
}
>
🥳 Follow All!
🥳 {t("Follow All!")}
</Button>
<ul
className={`pt-10 grid grid-cols-2 md:grid-cols-3 gap-10 overflow-y-hidden relative ${
@@ -353,7 +339,7 @@ export default function Home() {
}`}
onClick={() => setShowcaseMore(true)}
>
Show more
{t("Show more")}
</div>
{showcaseSites.data?.map((site: any) => (
<li className="inline-flex align-middle" key={site.handle}>
@@ -399,19 +385,16 @@ export default function Home() {
className="inline-block text-accent text-center"
href={`${GITHUB_LINK}/edit/dev/showcase.json`}
>
Submit yours
{t("Submit yours")}
</UniLink>
</li>
</ul>
</div>
</Element>
<Element name="Integration">
<div className="pt-28 text-4xl font-bold">Integration</div>
<div className="pt-28 text-4xl font-bold">{t("Integration")}</div>
<div className="my-10 text-zinc-700">
<p className="text-xl">
xLog&apos;s open design allows it to integrate with many other
open protocols and applications without friction.
</p>
<p className="text-xl">{t("Integration description")}</p>
<ul className="mt-14 grid grid-cols-3 sm:grid-cols-5 gap-y-14 gap-x-2">
{integrations.map((item, index) => (
<li
@@ -465,11 +448,11 @@ export default function Home() {
href="/dashboard"
className="text-accent inline-flex items-center space-x-2"
>
<Button size="xl">Get my xLog in 5 minutes</Button>
<Button size="xl">{t("Get my xLog in 5 minutes")}</Button>
</UniLink>
) : (
<Button onClick={tryNow} size="xl">
Get my xLog in 5 minutes
{t("Get my xLog in 5 minutes")}
</Button>
)}
</div>