Merge branch 'dev'
This commit is contained in:
+4
-4
@@ -40,11 +40,11 @@ spec:
|
||||
protocol: TCP
|
||||
resources:
|
||||
requests:
|
||||
memory: "400Mi"
|
||||
cpu: "150m"
|
||||
memory: "1500Mi"
|
||||
cpu: "200m"
|
||||
limits:
|
||||
memory: "1000Mi"
|
||||
cpu: "500m"
|
||||
memory: "10000Mi"
|
||||
cpu: "2000m"
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
readinessProbe:
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
module.exports = {
|
||||
i18n: {
|
||||
defaultLocale: "en",
|
||||
locales: ["en", "zh", "zh-TW", "ja"],
|
||||
reloadOnPrerender: process.env.NODE_ENV === "development",
|
||||
},
|
||||
}
|
||||
+59
-38
@@ -1,55 +1,54 @@
|
||||
// @ts-check
|
||||
const pkg = require("./package.json")
|
||||
const spawn = require("cross-spawn")
|
||||
const withBundleAnalyzer = require("@next/bundle-analyzer")({
|
||||
enabled: process.env.ANALYZE === "true",
|
||||
})
|
||||
const execSync = require("child_process").execSync
|
||||
const { i18n } = require("./next-i18next.config")
|
||||
|
||||
const cache = require("next-pwa/cache")
|
||||
const withPWA = require("next-pwa")({
|
||||
const cache = require("@ducanh2912/next-pwa").runtimeCaching
|
||||
const withPWA = require("@ducanh2912/next-pwa").default({
|
||||
disable: process.env.NODE_ENV === "development",
|
||||
dest: "public",
|
||||
publicExcludes: ["*"],
|
||||
runtimeCaching: [
|
||||
{
|
||||
urlPattern: ({ request }) => {
|
||||
return request.headers.get("x-middleware-prefetch")
|
||||
},
|
||||
handler: "NetworkOnly",
|
||||
},
|
||||
{
|
||||
urlPattern: ({ url }) => {
|
||||
return /\/ipfs\/([^/?#]+)$/.test(url.toString())
|
||||
},
|
||||
handler: "CacheFirst",
|
||||
options: {
|
||||
cacheName: "next-ipfs",
|
||||
expiration: {
|
||||
maxEntries: 64,
|
||||
maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days
|
||||
workboxOptions: {
|
||||
runtimeCaching: [
|
||||
{
|
||||
urlPattern: ({ request }) => {
|
||||
return request.headers.get("x-middleware-prefetch")
|
||||
},
|
||||
cacheableResponse: {
|
||||
statuses: [0, 200],
|
||||
handler: "NetworkOnly",
|
||||
},
|
||||
{
|
||||
urlPattern: ({ url }) => {
|
||||
return /\/ipfs\/([^/?#]+)$/.test(url.toString())
|
||||
},
|
||||
handler: "CacheFirst",
|
||||
options: {
|
||||
cacheName: "next-ipfs",
|
||||
expiration: {
|
||||
maxEntries: 64,
|
||||
maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days
|
||||
},
|
||||
cacheableResponse: {
|
||||
statuses: [0, 200],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
// cspell:ignore Fipfs
|
||||
urlPattern: /\/_next\/image\?url=.+%2Fipfs%2F([^/?#]+)$/i,
|
||||
handler: "CacheFirst",
|
||||
options: {
|
||||
cacheName: "next-ipfs",
|
||||
expiration: {
|
||||
maxEntries: 64,
|
||||
maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days
|
||||
{
|
||||
// cspell:ignore Fipfs
|
||||
urlPattern: /\/_next\/image\?url=.+%2Fipfs%2F([^/?#]+)$/i,
|
||||
handler: "CacheFirst",
|
||||
options: {
|
||||
cacheName: "next-ipfs",
|
||||
expiration: {
|
||||
maxEntries: 64,
|
||||
maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
// @ts-ignore
|
||||
...cache,
|
||||
],
|
||||
...cache,
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
const lastCommitCommand = "git rev-parse HEAD"
|
||||
@@ -63,12 +62,30 @@ module.exports = withBundleAnalyzer(
|
||||
},
|
||||
experimental: {
|
||||
scrollRestoration: true,
|
||||
appDir: true,
|
||||
serverComponentsExternalPackages: ["rehype-react"],
|
||||
},
|
||||
output: "standalone",
|
||||
productionBrowserSourceMaps: true,
|
||||
|
||||
webpack(config) {
|
||||
config.resolve.fallback = { fs: false } // polyfill node-id3
|
||||
|
||||
// https://github.com/WalletConnect/walletconnect-monorepo/blob/7716e164281c2f531145d682c3658f761fa0a823/providers/universal-provider/src/utils/deepLinks.ts#L39
|
||||
// @walletconnect/universal-provider imports react-native conditionally.
|
||||
// Since this is a NextJS app, simply mark it as external to avoid the webpack bundling warning.
|
||||
config.externals.push("react-native")
|
||||
|
||||
// https://github.com/WalletConnect/walletconnect-utils/blob/b7d7dc003c25dd33ef74c2fac483140f71a51d86/jsonrpc/http-connection/src/http.ts#L2
|
||||
// `@walletconnect/jsonrpc-http-connection` imports `cross-fetch` to support fetch in Node.js. It's unnecessary for Next.JS app.
|
||||
config.resolve.alias["cross-fetch"] = require.resolve(
|
||||
"next/dist/build/polyfills/fetch/index.js",
|
||||
)
|
||||
|
||||
// https://github.com/kkomelin/isomorphic-dompurify/issues/54
|
||||
// Fix isomorphic-dompurify in app router
|
||||
config.externals = [...config.externals, "canvas", "jsdom"]
|
||||
|
||||
return config
|
||||
},
|
||||
|
||||
@@ -76,7 +93,11 @@ module.exports = withBundleAnalyzer(
|
||||
dangerouslyAllowSVG: true,
|
||||
contentSecurityPolicy:
|
||||
"default-src 'self'; script-src 'none'; sandbox; style-src 'unsafe-inline';",
|
||||
remotePatterns: [{ hostname: "**" }],
|
||||
remotePatterns: [
|
||||
{ hostname: "**" },
|
||||
{ protocol: "https", hostname: "pbs.twimg.com" },
|
||||
{ protocol: "https", hostname: "abs.twimg.com" },
|
||||
],
|
||||
},
|
||||
|
||||
async generateBuildId() {
|
||||
|
||||
+44
-40
@@ -18,7 +18,8 @@
|
||||
"prisma:studio": "prisma studio",
|
||||
"docker:db": "docker-compose -f docker-compose.db.yml up -d",
|
||||
"spell-check": "cspell lint . --no-progress",
|
||||
"analyze": "NODE_ENV=production ANALYZE=true BUNDLE_ANALYZE=browser next build"
|
||||
"analyze": "NODE_ENV=production ANALYZE=true BUNDLE_ANALYZE=browser next build",
|
||||
"postinstall": "prisma generate"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,jsx,ts,tsx}": [
|
||||
@@ -27,39 +28,41 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@codemirror/commands": "6.2.3",
|
||||
"@codemirror/commands": "6.2.4",
|
||||
"@codemirror/lang-markdown": "6.1.1",
|
||||
"@codemirror/language": "6.6.0",
|
||||
"@codemirror/language-data": "6.3.0",
|
||||
"@codemirror/language-data": "6.3.1",
|
||||
"@codemirror/state": "6.2.0",
|
||||
"@codemirror/theme-one-dark": "6.1.2",
|
||||
"@codemirror/view": "6.10.0",
|
||||
"@crossbell/connect-kit": "0.0.79",
|
||||
"@crossbell/contract": "0.0.79",
|
||||
"@crossbell/indexer": "0.0.79",
|
||||
"@crossbell/notification": "0.0.79",
|
||||
"@crossbell/ui": "0.0.79",
|
||||
"@crossbell/util-hooks": "0.0.79",
|
||||
"@codemirror/view": "6.11.1",
|
||||
"@crossbell/connect-kit": "0.0.82",
|
||||
"@crossbell/contract": "0.0.82",
|
||||
"@crossbell/indexer": "0.0.82",
|
||||
"@crossbell/notification": "0.0.82",
|
||||
"@crossbell/ui": "0.0.82",
|
||||
"@crossbell/util-hooks": "0.0.82",
|
||||
"@ddietr/codemirror-themes": "1.4.1",
|
||||
"@dqbd/tiktoken": "^1.0.7",
|
||||
"@emoji-mart/data": "1.1.2",
|
||||
"@emoji-mart/react": "1.1.1",
|
||||
"@floating-ui/react": "^0.23.1",
|
||||
"@floating-ui/react": "^0.24.0",
|
||||
"@headlessui/react": "1.7.14",
|
||||
"@heroicons/react": "2.0.17",
|
||||
"@iconify-json/mingcute": "^1.1.6",
|
||||
"@lezer/highlight": "^1.1.4",
|
||||
"@mantine/core": "^6.0.9",
|
||||
"@monaco-editor/react": "4.5.0",
|
||||
"@mantine/core": "^6.0.10",
|
||||
"@monaco-editor/react": "4.5.1",
|
||||
"@popperjs/core": "^2.11.7",
|
||||
"@prisma/client": "^4.13.0",
|
||||
"@prisma/client": "^4.14.0",
|
||||
"@tanstack/react-query": "4.29.5",
|
||||
"@tanstack/react-query-devtools": "4.29.6",
|
||||
"@tanstack/react-query-persist-client": "4.29.5",
|
||||
"@uiw/codemirror-extensions-events": "4.19.16",
|
||||
"@urql/core": "4.0.7",
|
||||
"ahooks": "^3.7.6",
|
||||
"ahooks": "^3.7.7",
|
||||
"aplayer-react": "^1.1.0",
|
||||
"async-lock": "^1.4.0",
|
||||
"canvas": "^2.11.2",
|
||||
"canvas-confetti": "^1.6.0",
|
||||
"chroma-js": "^2.4.2",
|
||||
"clsx": "1.2.1",
|
||||
@@ -72,14 +75,15 @@
|
||||
"hast-util-to-html": "^8.0.4",
|
||||
"hast-util-to-text": "^3.1.2",
|
||||
"i18next": "^22.4.15",
|
||||
"idb-keyval": "6.2.0",
|
||||
"immer": "10.0.1",
|
||||
"i18next-resources-to-backend": "^1.1.3",
|
||||
"idb-keyval": "6.2.1",
|
||||
"immer": "10.0.2",
|
||||
"ioredis": "5.3.2",
|
||||
"isomorphic-dompurify": "^1.3.0",
|
||||
"isomorphic-dompurify": "^1.4.0",
|
||||
"js-yaml": "4.1.0",
|
||||
"jsonfeed-to-rss": "^3.0.6",
|
||||
"jsonfeed-to-rss": "^3.0.7",
|
||||
"katex": "^0.16.7",
|
||||
"langchain": "^0.0.66",
|
||||
"langchain": "^0.0.72",
|
||||
"lottie-react": "^2.4.0",
|
||||
"mdast-util-to-hast": "^12.3.0",
|
||||
"mdast-util-to-string": "3.2.0",
|
||||
@@ -87,24 +91,23 @@
|
||||
"medium-zoom": "1.0.8",
|
||||
"mermaid": "10.1.0",
|
||||
"nanoid": "4.0.2",
|
||||
"next": "13.3.1",
|
||||
"next-i18next": "^13.2.2",
|
||||
"nextjs-progressbar": "0.0.16",
|
||||
"next": "13.4.1",
|
||||
"node-id3": "^0.2.6",
|
||||
"pangu": "^4.0.7",
|
||||
"pinyin": "3.0.0-alpha.5",
|
||||
"pinyin-pro": "^3.14.0",
|
||||
"prismjs": "1.29.0",
|
||||
"qier-progress": "1.0.4",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react-hook-form": "7.43.9",
|
||||
"react-hot-toast": "2.4.1",
|
||||
"react-i18next": "^12.2.2",
|
||||
"react-parallax-tilt": "^1.7.131",
|
||||
"react-parallax-tilt": "^1.7.137",
|
||||
"react-popper": "^2.3.0",
|
||||
"react-scroll": "1.8.9",
|
||||
"react-sortablejs": "6.1.4",
|
||||
"react-string-replace": "^1.1.0",
|
||||
"react-virtuoso": "4.3.2",
|
||||
"react-tweet": "^2.0.1",
|
||||
"react-virtuoso": "4.3.6",
|
||||
"refractor": "4.8.1",
|
||||
"rehype-autolink-headings": "6.1.1",
|
||||
"rehype-infer-description-meta": "^1.1.0",
|
||||
@@ -116,7 +119,7 @@
|
||||
"rehype-sanitize": "5.0.1",
|
||||
"rehype-slug": "5.1.0",
|
||||
"rehype-stringify": "9.0.3",
|
||||
"remark-breaks": "^3.0.2",
|
||||
"remark-breaks": "^3.0.3",
|
||||
"remark-directive": "2.0.1",
|
||||
"remark-directive-rehype": "0.4.2",
|
||||
"remark-frontmatter": "4.0.1",
|
||||
@@ -138,14 +141,16 @@
|
||||
"unist-util-visit": "4.1.2",
|
||||
"use-onclickoutside": "0.4.1",
|
||||
"uuid": "9.0.0",
|
||||
"wagmi": "0.12.12",
|
||||
"zustand": "^4.3.7"
|
||||
"wagmi": "0.12.13",
|
||||
"zustand": "^4.3.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ducanh2912/next-pwa": "^8.4.1",
|
||||
"@iconify/tailwind": "^0.1.2",
|
||||
"@next/bundle-analyzer": "13.3.1",
|
||||
"@next/bundle-analyzer": "13.4.1",
|
||||
"@playwright/test": "1.33.0",
|
||||
"@trivago/prettier-plugin-sort-imports": "4.1.1",
|
||||
"@types/async-lock": "^1.4.0",
|
||||
"@types/canvas-confetti": "^1.6.0",
|
||||
"@types/chroma-js": "^2.4.0",
|
||||
"@types/cookie": "0.5.1",
|
||||
@@ -154,13 +159,12 @@
|
||||
"@types/katex": "^0.16.0",
|
||||
"@types/mdast": "^3.0.11",
|
||||
"@types/mjml": "4.7.1",
|
||||
"@types/node": "18.16.2",
|
||||
"@types/node": "20.1.1",
|
||||
"@types/pangu": "^4.0.0",
|
||||
"@types/prismjs": "1.26.0",
|
||||
"@types/react": "18.2.0",
|
||||
"@types/react-dom": "18.2.1",
|
||||
"@types/react": "18.2.6",
|
||||
"@types/react-dom": "18.2.4",
|
||||
"@types/react-infinite-scroller": "1.2.3",
|
||||
"@types/react-scroll": "1.8.6",
|
||||
"@types/remove-markdown": "0.3.1",
|
||||
"@types/serialize-javascript": "^5.0.2",
|
||||
"@types/sortablejs": "1.15.1",
|
||||
@@ -168,22 +172,22 @@
|
||||
"@types/uuid": "9.0.1",
|
||||
"autoprefixer": "10.4.14",
|
||||
"babel-loader": "^9.1.2",
|
||||
"cross-spawn": "7.0.3",
|
||||
"cspell": "^6.31.1",
|
||||
"esbuild": "0.17.18",
|
||||
"esbuild-register": "3.4.2",
|
||||
"eslint": "8.39.0",
|
||||
"eslint-config-next": "13.3.1",
|
||||
"eslint": "8.40.0",
|
||||
"eslint-config-next": "13.4.1",
|
||||
"eslint-plugin-import": "2.27.5",
|
||||
"eslint-plugin-unused-imports": "2.0.0",
|
||||
"husky": "8.0.3",
|
||||
"lint-staged": "13.2.2",
|
||||
"next-pwa": "^5.6.0",
|
||||
"postcss-import": "15.1.0",
|
||||
"postcss-prune-var": "1.0.5",
|
||||
"prettier": "2.8.8",
|
||||
"prettier-package-json": "2.8.0",
|
||||
"prisma": "^4.13.0",
|
||||
"prisma": "^4.14.0",
|
||||
"tailwindcss": "3.3.2",
|
||||
"tailwindcss-variable-colors": "0.0.1",
|
||||
"typescript": "5.0.4"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
Generated
+1414
-1578
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,7 @@ module.exports = {
|
||||
plugins: {
|
||||
"postcss-import": {},
|
||||
tailwindcss: {},
|
||||
"postcss-prune-var": {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"intlDateTime": "{{val, datetime}}",
|
||||
"ago": "{{time}} ago",
|
||||
"joined ago": "Joined {{time}} ago"
|
||||
"joined ago": "Joined {{time}} ago",
|
||||
"signed and stored on the blockchain": "Ownership of this {{name}} data is guaranteed by blockchain and smart contracts to the creator alone."
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
{
|
||||
"load more": "There are {{count}} more {{name}}, click to load more",
|
||||
"signed and stored on the blockchain": "Ownership of this {{name}} data is guaranteed by blockchain and smart contracts to the creator alone."
|
||||
"load more": "There are {{count}} more {{name}}, click to load more"
|
||||
}
|
||||
@@ -55,5 +55,6 @@
|
||||
"Showcase": "ショーケース",
|
||||
"AI-generated summary": "AIが生成した要約",
|
||||
"Generating": "生成中",
|
||||
"Show more": "もっと表示する"
|
||||
"Show more": "もっと表示する",
|
||||
"signed and stored on the blockchain": "{{name}}は、創作者によって署名され、ブロックチェーンに安全に保存されています。"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
"About": "紹介",
|
||||
"Tags": "タグ",
|
||||
"load more": "まだ{{count}}件の{{name}}があります。",
|
||||
"signed and stored on the blockchain": "{{name}}は、創作者によって署名され、ブロックチェーンに安全に保存されています。",
|
||||
"Write a comment on the blockchain": "ブロックチェーンでコメントする",
|
||||
"powered by": "<span>このサイトは </span><name/><span> によって作動します</span>"
|
||||
}
|
||||
|
||||
@@ -1,87 +1,88 @@
|
||||
{
|
||||
"Connect": "連線",
|
||||
"Followers": "粉絲",
|
||||
"Following": "追蹤中",
|
||||
"Followings": "追蹤中",
|
||||
"Follow": "追蹤",
|
||||
"Unfollow": "取消追蹤",
|
||||
"intlDateTime": "{{val, datetime}}",
|
||||
"post": "文章",
|
||||
"posts": "文章",
|
||||
"page": "頁面",
|
||||
"pages": "頁面",
|
||||
"comment": "留言",
|
||||
"comments": "留言",
|
||||
"Comment": "留言",
|
||||
"Comments": "留言",
|
||||
"reply": "回覆",
|
||||
"replies": "回覆",
|
||||
"like": "讚",
|
||||
"likes": "讚",
|
||||
"blog": "部落格",
|
||||
"Owner": "擁有者",
|
||||
"Transaction Hash": "交易雜湊值",
|
||||
"IPFS Address": "IPFS 位址",
|
||||
"BNB Greenfield Address": "BNB Greenfield 位址",
|
||||
"Creation": "創建",
|
||||
"Last Update": "最後更新",
|
||||
"Create Character": "創建身份",
|
||||
"Submit": "提交",
|
||||
"Reply": "回覆",
|
||||
"Cancel Reply": "取消回覆",
|
||||
"Edit": "編輯",
|
||||
"Cancel Edit": "取消編輯",
|
||||
"Confirm Modification": "確認編輯",
|
||||
"ago": "{{time}}前",
|
||||
"joined ago": "{{time}}前加入",
|
||||
"obtained ago": "{{time}}前獲得",
|
||||
"Like": "點讚",
|
||||
"Mint to an NFT": "珍藏為 NFT",
|
||||
"Like successfully": "點讚成功",
|
||||
"Mint successfully": "珍藏完成~",
|
||||
"like stored": "你的點讚已被安全地儲存在區塊鏈上,可以在 <2>Crossbell Scan</2> 上查看",
|
||||
"mint stored": "你已將這篇文章珍藏成 NFT,可以在 <2>xChar</2> 或 <6>Crossbell Scan</6> 上查看",
|
||||
"Got it, thanks!": "知道啦,感恩的心~",
|
||||
"Like List": "按讚列表",
|
||||
"Mint List": "珍藏列表",
|
||||
"Revert": "收回",
|
||||
"Confirm to revert": "確定收回",
|
||||
"like revert": "請確定是否想要收回這個點讚操作?",
|
||||
"Cancel": "算了",
|
||||
"Confirm": "確定",
|
||||
"No Content Yet.": "什麼都沒",
|
||||
"Close": "關閉",
|
||||
"Dashboard": "主控臺",
|
||||
"Copied!": "拷貝完成",
|
||||
"Operator Sign": "簽名授權",
|
||||
"Switch Characters": "切換身份",
|
||||
"Upgrade to Wallet": "升級為錢包認證",
|
||||
"Disconnect": "中斷連線",
|
||||
"Loading": "載入中...",
|
||||
"Showcase": "展示櫃",
|
||||
"AI-generated summary": "AI 生成的摘要",
|
||||
"Generating": "生成中...",
|
||||
"Show more": "顯示更多",
|
||||
"Patron": "贊助",
|
||||
"Become a patron of {{name}}": "成為 {{name}} 的贊助者",
|
||||
"Latest patrons": "最新贊助者",
|
||||
"Latest tipper": "最新贊助者",
|
||||
"You are here to be the first patron.": "你是第一位贊助者。",
|
||||
"You are here to be the first tipper.": "你是第一位贊助者。",
|
||||
"Select a tier": "選擇一個等級",
|
||||
"One-time": "一次性",
|
||||
"Monthly and NFT Rewards": "每月和 NFT 獎勵",
|
||||
"Coming soon": "即將推出",
|
||||
"What is MIRA? Where can I get some?": "MIRA 是什麼?能吃嗎?我在哪裡可以獲得?",
|
||||
"Tip": "贊助",
|
||||
"Tip the post: {{name}}": "贊助文章:{{name}}",
|
||||
"Custom": "自訂",
|
||||
"Mintable": "Mintable",
|
||||
"Successfully followed": "嘿!你已經開始<2>追蹤他們的最新動態</2>囉。",
|
||||
"Enable AI Filtering": "AI 過濾",
|
||||
"Filter out possible low-quality content based on AI ratings.": "基於 AI 評分過濾可能不佳的內容",
|
||||
"Refreshing": "重新載入中",
|
||||
"Search for your interest": "搜你所想",
|
||||
"results": "項結果",
|
||||
"My xLog": "你的 xLog"
|
||||
"Connect": "連線",
|
||||
"Followers": "粉絲",
|
||||
"Following": "追蹤中",
|
||||
"Followings": "追蹤中",
|
||||
"Follow": "追蹤",
|
||||
"Unfollow": "取消追蹤",
|
||||
"intlDateTime": "{{val, datetime}}",
|
||||
"post": "文章",
|
||||
"posts": "文章",
|
||||
"page": "頁面",
|
||||
"pages": "頁面",
|
||||
"comment": "留言",
|
||||
"comments": "留言",
|
||||
"Comment": "留言",
|
||||
"Comments": "留言",
|
||||
"reply": "回覆",
|
||||
"replies": "回覆",
|
||||
"like": "讚",
|
||||
"likes": "讚",
|
||||
"blog": "部落格",
|
||||
"Owner": "擁有者",
|
||||
"Transaction Hash": "交易雜湊值",
|
||||
"IPFS Address": "IPFS 位址",
|
||||
"BNB Greenfield Address": "BNB Greenfield 位址",
|
||||
"Creation": "創建",
|
||||
"Last Update": "最後更新",
|
||||
"Create Character": "創建身份",
|
||||
"Submit": "提交",
|
||||
"Reply": "回覆",
|
||||
"Cancel Reply": "取消回覆",
|
||||
"Edit": "編輯",
|
||||
"Cancel Edit": "取消編輯",
|
||||
"Confirm Modification": "確認編輯",
|
||||
"ago": "{{time}}前",
|
||||
"joined ago": "{{time}}前加入",
|
||||
"obtained ago": "{{time}}前獲得",
|
||||
"Like": "點讚",
|
||||
"Mint to an NFT": "珍藏為 NFT",
|
||||
"Like successfully": "點讚成功",
|
||||
"Mint successfully": "珍藏完成~",
|
||||
"like stored": "你的點讚已被安全地儲存在區塊鏈上,可以在 <2>Crossbell Scan</2> 上查看",
|
||||
"mint stored": "你已將這篇文章珍藏成 NFT,可以在 <2>xChar</2> 或 <6>Crossbell Scan</6> 上查看",
|
||||
"Got it, thanks!": "知道啦,感恩的心~",
|
||||
"Like List": "按讚列表",
|
||||
"Mint List": "珍藏列表",
|
||||
"Revert": "收回",
|
||||
"Confirm to revert": "確定收回",
|
||||
"like revert": "請確定是否想要收回這個點讚操作?",
|
||||
"Cancel": "算了",
|
||||
"Confirm": "確定",
|
||||
"No Content Yet.": "什麼都沒",
|
||||
"Close": "關閉",
|
||||
"Dashboard": "主控臺",
|
||||
"Copied!": "拷貝完成",
|
||||
"Operator Sign": "簽名授權",
|
||||
"Switch Characters": "切換身份",
|
||||
"Upgrade to Wallet": "升級為錢包認證",
|
||||
"Disconnect": "中斷連線",
|
||||
"Loading": "載入中...",
|
||||
"Showcase": "展示櫃",
|
||||
"AI-generated summary": "AI 生成的摘要",
|
||||
"Generating": "生成中...",
|
||||
"Show more": "顯示更多",
|
||||
"Patron": "贊助",
|
||||
"Become a patron of {{name}}": "成為 {{name}} 的贊助者",
|
||||
"Latest patrons": "最新贊助者",
|
||||
"Latest tipper": "最新贊助者",
|
||||
"You are here to be the first patron.": "你是第一位贊助者。",
|
||||
"You are here to be the first tipper.": "你是第一位贊助者。",
|
||||
"Select a tier": "選擇一個等級",
|
||||
"One-time": "一次性",
|
||||
"Monthly and NFT Rewards": "每月和 NFT 獎勵",
|
||||
"Coming soon": "即將推出",
|
||||
"What is MIRA? Where can I get some?": "MIRA 是什麼?能吃嗎?我在哪裡可以獲得?",
|
||||
"Tip": "贊助",
|
||||
"Tip the post: {{name}}": "贊助文章:{{name}}",
|
||||
"Custom": "自訂",
|
||||
"Mintable": "Mintable",
|
||||
"Successfully followed": "嘿!你已經開始<2>追蹤他們的最新動態</2>囉。",
|
||||
"Enable AI Filtering": "AI 過濾",
|
||||
"Filter out possible low-quality content based on AI ratings.": "基於 AI 評分過濾可能不佳的內容",
|
||||
"Refreshing": "重新載入中",
|
||||
"Search for your interest": "搜你所想",
|
||||
"results": "項結果",
|
||||
"My xLog": "你的 xLog",
|
||||
"signed and stored on the blockchain": "此{{name}}數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。"
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
"About": "關於",
|
||||
"Tags": "標籤",
|
||||
"load more": "還有{{count}}篇{{name}},點選載入更多文章",
|
||||
"signed and stored on the blockchain": "此{{name}}數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。",
|
||||
"Write a comment on the blockchain": "在區塊鏈上留言。",
|
||||
"powered by": "<span>由 </span><name/><span> 提供支援</span>",
|
||||
"This address is in local editing preview mode and cannot be viewed by the public.": "此地址處於本地編輯預覽模式,尚未公開。",
|
||||
|
||||
@@ -83,5 +83,6 @@
|
||||
"Refreshing": "刷新中",
|
||||
"Search for your interest": "搜索你感兴趣的内容",
|
||||
"results": "条结果",
|
||||
"My xLog": "我的 xLog"
|
||||
"My xLog": "我的 xLog",
|
||||
"signed and stored on the blockchain": "此{{name}}数据所有权由区块链加密技术和智能合约保障仅归创作者所有。"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
"About": "关于",
|
||||
"Tags": "标签",
|
||||
"load more": "还有 {{count}} 篇{{name}},点击加载更多",
|
||||
"signed and stored on the blockchain": "此{{name}}数据所有权由区块链加密技术和智能合约保障仅归创作者所有。",
|
||||
"Write a comment on the blockchain": "在区块链上写下你的评论",
|
||||
"powered by": "<span>由 </span><name/><span> 提供支持</span>",
|
||||
"This address is in local editing preview mode and cannot be viewed by the public.":
|
||||
@@ -15,5 +14,6 @@
|
||||
"View on Crossbell Scan": "在 Crossbell Scan 上查看",
|
||||
"Subscribe to JSON Feed": "订阅 JSON Feed",
|
||||
"Subscribe to RSS": "订阅 RSS",
|
||||
"Search on this site": "在本站搜索"
|
||||
"Search on this site": "在本站搜索",
|
||||
"404 - Whoops, this page is gone.": "404 - 哎呀,这个页面不见了。"
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
const {
|
||||
transformColorObjectOfDarkmode,
|
||||
generateCSSByVar,
|
||||
} = require("./transform")
|
||||
|
||||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
|
||||
const [colorObject, cssVar, cssVarDark] = transformColorObjectOfDarkmode()
|
||||
|
||||
const normalCSS = generateCSSByVar(cssVar)
|
||||
const darkCSS = generateCSSByVar(cssVarDark)
|
||||
|
||||
const cssString = `
|
||||
:root {
|
||||
${normalCSS}
|
||||
}
|
||||
|
||||
html.dark {
|
||||
${darkCSS}
|
||||
}
|
||||
|
||||
html.light {
|
||||
${normalCSS}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
html:not(.light) {
|
||||
${darkCSS}
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
html:not(.dark) {
|
||||
${normalCSS}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
fs.writeFileSync(
|
||||
path.resolve(__dirname, "../../src/css/css-var.css"),
|
||||
cssString,
|
||||
"utf-8",
|
||||
)
|
||||
|
||||
fs.writeFileSync(
|
||||
path.resolve(__dirname, "../../tw-colors.js"),
|
||||
`export default ${JSON.stringify(colorObject, null, 2)}`,
|
||||
"utf-8",
|
||||
)
|
||||
@@ -1,97 +0,0 @@
|
||||
const colors = require("tailwindcss/colors")
|
||||
|
||||
const colorKeys = Object.keys(colors)
|
||||
const colorObject = {}
|
||||
|
||||
const hexToRGB = (hex) => {
|
||||
hex = hex.replace("#", "")
|
||||
|
||||
let r = parseInt(hex.substring(0, 2), 16)
|
||||
let g = parseInt(hex.substring(2, 4), 16)
|
||||
let b = parseInt(hex.substring(4, 6), 16)
|
||||
|
||||
return `${r}, ${g}, ${b}`
|
||||
}
|
||||
|
||||
const deprecatedColorKeyMap = {
|
||||
lightBlue: "sky",
|
||||
warmGray: "stone",
|
||||
trueGray: "neutral",
|
||||
coolGray: "gray",
|
||||
blueGray: "slate",
|
||||
}
|
||||
for (const key of colorKeys) {
|
||||
if (typeof colors[key] === "object") {
|
||||
if (deprecatedColorKeyMap[key]) {
|
||||
colorObject[deprecatedColorKeyMap[key]] = colors[key]
|
||||
continue
|
||||
}
|
||||
|
||||
colorObject[key] = colors[key]
|
||||
}
|
||||
}
|
||||
|
||||
const transformColorObjectOfDarkmode = () => {
|
||||
const cssVar = {}
|
||||
const cssVarDark = {}
|
||||
const nextColorObject = {}
|
||||
// slate: {
|
||||
// 50: '#f8fafc',
|
||||
// }
|
||||
// to
|
||||
// slate: {
|
||||
// 50: 'rgb(var(--tw-colors-i-slate-50) / <alpha-value>)',
|
||||
// ...
|
||||
// }
|
||||
for (const colorKey of Object.keys(colorObject)) {
|
||||
const color = colorObject[colorKey]
|
||||
|
||||
if (typeof color === "object") {
|
||||
const nextColor = {}
|
||||
|
||||
for (const colorNumberKey of Object.keys(color)) {
|
||||
const cssVarKey = `--tw-colors-i-${colorKey}-${colorNumberKey}`
|
||||
// @see https://tailwindcss.com/docs/customizing-colors#using-the-default-colors
|
||||
nextColor[colorNumberKey] = `rgba(var(${cssVarKey}), <alpha-value>)`
|
||||
|
||||
cssVar[cssVarKey] = hexToRGB(color[colorNumberKey])
|
||||
// 50 -> 950, 100 -> 900, 200 -> 800, ...
|
||||
|
||||
// colorKey:
|
||||
const reverseColorNumberKey = 1000 - parseInt(colorNumberKey)
|
||||
cssVarDark[cssVarKey] = hexToRGB(color[reverseColorNumberKey])
|
||||
}
|
||||
|
||||
nextColorObject[colorKey] = nextColor
|
||||
}
|
||||
}
|
||||
|
||||
// merge const color
|
||||
Object.assign(nextColorObject, {
|
||||
inherit: "inherit",
|
||||
current: "currentColor",
|
||||
transparent: "transparent",
|
||||
black: "var(--tw-colors-i-black)",
|
||||
white: "var(--tw-colors-i-white)",
|
||||
})
|
||||
cssVar["--tw-colors-i-black"] = "0, 0, 0"
|
||||
cssVar["--tw-colors-i-white"] = "255, 255, 255"
|
||||
cssVarDark["--tw-colors-i-black"] = "255, 255, 255"
|
||||
cssVarDark["--tw-colors-i-white"] = "0, 0, 0"
|
||||
|
||||
return [nextColorObject, cssVar, cssVarDark]
|
||||
}
|
||||
|
||||
function generateCSSByVar(cssVar) {
|
||||
let css = ""
|
||||
for (const key of Object.keys(cssVar)) {
|
||||
css += ` ${key}: ${cssVar[key]};\n`
|
||||
}
|
||||
|
||||
return css
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
transformColorObjectOfDarkmode,
|
||||
generateCSSByVar,
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import { Metadata } from "next"
|
||||
|
||||
import { Hydrate, dehydrate } from "@tanstack/react-query"
|
||||
|
||||
import { HomeFeed } from "~/components/home/HomeFeed"
|
||||
import { HomeSidebar } from "~/components/home/HomeSidebar"
|
||||
import { APP_NAME } from "~/lib/env"
|
||||
import getQueryClient from "~/lib/query-client"
|
||||
import { prefetchGetFeed } from "~/queries/home.server"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: `Activities - ${APP_NAME}`,
|
||||
}
|
||||
|
||||
async function Activities() {
|
||||
const queryClient = getQueryClient()
|
||||
await prefetchGetFeed(
|
||||
{
|
||||
type: "latest",
|
||||
},
|
||||
queryClient,
|
||||
)
|
||||
const dehydratedState = dehydrate(queryClient)
|
||||
|
||||
return (
|
||||
<Hydrate state={dehydratedState}>
|
||||
<section className="pt-24">
|
||||
<div className="max-w-screen-lg px-5 mx-auto flex">
|
||||
<div className="flex-1 min-w-[300px]">
|
||||
<HomeFeed />
|
||||
</div>
|
||||
<HomeSidebar />
|
||||
</div>
|
||||
</section>
|
||||
</Hydrate>
|
||||
)
|
||||
}
|
||||
|
||||
export default Activities
|
||||
@@ -1,61 +1,18 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
|
||||
import { ConnectButton } from "~/components/common/ConnectButton"
|
||||
import { DarkModeSwitch } from "~/components/common/DarkModeSwitch"
|
||||
import { Logo } from "~/components/common/Logo"
|
||||
import {
|
||||
APP_DESCRIPTION,
|
||||
APP_NAME,
|
||||
DISCORD_LINK,
|
||||
GITHUB_LINK,
|
||||
TWITTER_LINK,
|
||||
} from "~/lib/env"
|
||||
import HomeTabs from "~/components/home/HomeTabs"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { APP_NAME, DISCORD_LINK, GITHUB_LINK, TWITTER_LINK } from "~/lib/env"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { ConnectButton } from "../common/ConnectButton"
|
||||
import { DarkModeSwitch } from "../common/DarkModeSwitch"
|
||||
import { SEOHead } from "../common/SEOHead"
|
||||
import { Image } from "../ui/Image"
|
||||
import { UniLink } from "../ui/UniLink"
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
name: "Home",
|
||||
link: "/",
|
||||
},
|
||||
{
|
||||
name: "Activities",
|
||||
link: "/activities",
|
||||
},
|
||||
{
|
||||
name: (
|
||||
<Image
|
||||
className="no-optimization w-24"
|
||||
alt="github stars"
|
||||
src="https://img.shields.io/github/stars/Crossbell-Box/xLog?color=white&label=Stars&logo=github&style=social"
|
||||
/>
|
||||
),
|
||||
link: GITHUB_LINK,
|
||||
},
|
||||
]
|
||||
|
||||
export function MainLayout({
|
||||
export default async function HomeLayout({
|
||||
children,
|
||||
title,
|
||||
}: {
|
||||
children?: React.ReactNode
|
||||
title?: string
|
||||
}) {
|
||||
const { t } = useTranslation("index")
|
||||
const router = useRouter()
|
||||
|
||||
return (
|
||||
<>
|
||||
<SEOHead
|
||||
title={title}
|
||||
siteName={APP_NAME}
|
||||
description={APP_DESCRIPTION}
|
||||
/>
|
||||
<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">
|
||||
<UniLink
|
||||
@@ -68,20 +25,7 @@ export function MainLayout({
|
||||
xLog
|
||||
</UniLink>
|
||||
<div className="space-x-14 text-zinc-500 flex">
|
||||
{tabs?.map((tab, index) => (
|
||||
<UniLink
|
||||
className={cn(
|
||||
"cursor-pointer items-center hidden sm:flex hover:text-accent text-lg",
|
||||
{
|
||||
"text-accent": router.pathname === tab.link,
|
||||
},
|
||||
)}
|
||||
key={tab.link}
|
||||
href={tab.link}
|
||||
>
|
||||
{typeof tab.name === "string" ? t(tab.name) : tab.name}
|
||||
</UniLink>
|
||||
))}
|
||||
<HomeTabs />
|
||||
<ConnectButton size="base" variantColor="black" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,341 @@
|
||||
import Link from "next/link"
|
||||
import { memo } from "react"
|
||||
|
||||
import { Logo } from "~/components/common/Logo"
|
||||
import { default as OriginEntranceButton } from "~/components/home/EntranceButton"
|
||||
import { Integration } from "~/components/home/Integrations"
|
||||
import { ShowCase } from "~/components/home/Showcase"
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { Image } from "~/components/ui/Image"
|
||||
import { CSB_SCAN, GITHUB_LINK } from "~/lib/env"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { Trans, useTranslation } from "~/lib/i18n"
|
||||
|
||||
async function Home() {
|
||||
const { t, i18n } = await useTranslation("index")
|
||||
|
||||
const EntranceButton = memo(function Button() {
|
||||
return (
|
||||
<OriginEntranceButton
|
||||
connectedContent={
|
||||
<>
|
||||
<span className="icon-[mingcute--grid-line] text-xl mr-2 inline-block"></span>
|
||||
<span>{t("Dashboard")}</span>
|
||||
</>
|
||||
}
|
||||
unconnectedContent={t("Get my xLog in 5 minutes")}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
||||
const features: {
|
||||
title: string
|
||||
subfeatures: {
|
||||
screenshot?: {
|
||||
src: string
|
||||
}
|
||||
icon: string
|
||||
title: string
|
||||
}[]
|
||||
extra?: boolean
|
||||
}[] = [
|
||||
{
|
||||
title: "Write",
|
||||
subfeatures: [
|
||||
{
|
||||
screenshot: {
|
||||
src: "/assets/easy.png",
|
||||
},
|
||||
icon: "🤪",
|
||||
title: "Easy to get started",
|
||||
},
|
||||
{
|
||||
screenshot: {
|
||||
src: "/assets/experience.png",
|
||||
},
|
||||
icon: "😆",
|
||||
title: "Elegant experience",
|
||||
},
|
||||
{
|
||||
screenshot: {
|
||||
src: "/assets/fast.png",
|
||||
},
|
||||
icon: "🚀",
|
||||
title: "Fast",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "Own",
|
||||
subfeatures: [
|
||||
{
|
||||
screenshot: {
|
||||
src: "/assets/safe.png",
|
||||
},
|
||||
icon: "🔒",
|
||||
title: "Safe",
|
||||
},
|
||||
{
|
||||
screenshot: {
|
||||
src: "/assets/customizable.png",
|
||||
},
|
||||
icon: "🎨",
|
||||
title: "Customizable",
|
||||
},
|
||||
{
|
||||
screenshot: {
|
||||
src: "/assets/open.png",
|
||||
},
|
||||
icon: "🌐",
|
||||
title: "Open",
|
||||
},
|
||||
],
|
||||
extra: true,
|
||||
},
|
||||
{
|
||||
title: "Earn",
|
||||
subfeatures: [
|
||||
{
|
||||
icon: "🪙",
|
||||
title: "Creator Incentives",
|
||||
},
|
||||
{
|
||||
icon: "🏟️",
|
||||
title: "DAO",
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
return (
|
||||
<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-6xl 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-3 sm:mt-5 text-zinc-800 text-2xl sm:text-4xl font-light">
|
||||
<Trans i18n={i18n} i18nKey="description" ns="index">
|
||||
<strong className="font-medium">xLog</strong> is the best{" "}
|
||||
<a
|
||||
target="_blank"
|
||||
rel="nofollow noreferrer"
|
||||
className="underline decoration-2 text-yellow-400 font-medium"
|
||||
href={CSB_SCAN}
|
||||
>
|
||||
on-chain
|
||||
</a>{" "}
|
||||
and{" "}
|
||||
<a
|
||||
target="_blank"
|
||||
rel="nofollow noreferrer"
|
||||
className="underline decoration-2 text-green-400 font-medium"
|
||||
href={GITHUB_LINK}
|
||||
>
|
||||
open-source
|
||||
</a>{" "}
|
||||
blogging community for everyone.
|
||||
</Trans>
|
||||
</h3>
|
||||
<div className="my-4 sm:my-12 flex items-center justify-center sm:flex-row flex-col">
|
||||
<EntranceButton />
|
||||
<Button
|
||||
className="text-accent h-10 sm:ml-4 mt-4 flex"
|
||||
size="2xl"
|
||||
variant="outline"
|
||||
variantColor="gradient"
|
||||
>
|
||||
<Link className="h-full flex items-center" href="/activities">
|
||||
{t("Look at others'")}
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
<div className="text-center absolute bottom-4 sm:bottom-14 w-full flex items-center justify-center flex-col">
|
||||
<span className="mb-1 sm:mb-3">{t("Explore the xLog way")}</span>
|
||||
<Link
|
||||
href="#features"
|
||||
className="cursor-pointer inline-block icon-[mingcute--down-line] text-3xl"
|
||||
></Link>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div id="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
|
||||
i18n={i18n}
|
||||
i18nKey={`features.${feature.title}.description`}
|
||||
components={{
|
||||
aown: (
|
||||
<a
|
||||
target="_blank"
|
||||
rel="nofollow noreferrer"
|
||||
className="underline"
|
||||
href="https://github.com/Crossbell-Box/Crossbell-Contracts/wiki"
|
||||
>
|
||||
.
|
||||
</a>
|
||||
),
|
||||
}}
|
||||
ns="index"
|
||||
/>
|
||||
</p>
|
||||
</div>
|
||||
<ul className="pt-10 grid grid-cols-1 sm:grid-cols-3 gap-8">
|
||||
{feature.subfeatures.map((item) => (
|
||||
<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
|
||||
i18n={i18n}
|
||||
i18nKey={`${item.title} text`}
|
||||
components={{
|
||||
strong: <strong className="font-bold" />,
|
||||
axfm: (
|
||||
<a
|
||||
target="_blank"
|
||||
rel="nofollow noreferrer"
|
||||
className="underline"
|
||||
href={`${getSiteLink({
|
||||
subdomain: "xlog",
|
||||
})}/xfm`}
|
||||
>
|
||||
.
|
||||
</a>
|
||||
),
|
||||
aincentive: (
|
||||
<a
|
||||
target="_blank"
|
||||
rel="nofollow noreferrer"
|
||||
className="underline"
|
||||
href={`${getSiteLink({
|
||||
subdomain: "xlog",
|
||||
})}/creator-incentive-plan`}
|
||||
>
|
||||
.
|
||||
</a>
|
||||
),
|
||||
}}
|
||||
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>
|
||||
<a
|
||||
target="_blank"
|
||||
href={getSiteLink({ subdomain: "xlog" })}
|
||||
role="button"
|
||||
className="button is-black rounded-lg"
|
||||
>
|
||||
{t(`features.${feature.title}.extra.button`)}
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<div id="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>
|
||||
<ShowCase />
|
||||
</div>
|
||||
</div>
|
||||
<div id="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">
|
||||
<Integration />
|
||||
<li className="flex items-center justify-center">
|
||||
<i className="icon-[mingcute--more-1-line] text-5xl" />
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="my-20 text-center">
|
||||
<div className="w-[100px] h-[100px] mx-auto mb-10">
|
||||
<Logo type="lottie" width={100} height={100} loop={true} />
|
||||
</div>
|
||||
<EntranceButton />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Home
|
||||
@@ -0,0 +1,36 @@
|
||||
import { Metadata } from "next"
|
||||
|
||||
import { SearchInput } from "~/components/common/SearchInput"
|
||||
import { HomeFeed } from "~/components/home/HomeFeed"
|
||||
import { HomeSidebar } from "~/components/home/HomeSidebar"
|
||||
import { APP_NAME } from "~/lib/env"
|
||||
|
||||
export function generateMetadata({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: {
|
||||
[key: string]: string | string[] | undefined
|
||||
}
|
||||
}): Metadata {
|
||||
return {
|
||||
title: `Search: ${searchParams.q} - ${APP_NAME}`,
|
||||
}
|
||||
}
|
||||
|
||||
async function Search() {
|
||||
return (
|
||||
<section className="pt-24">
|
||||
<div className="max-w-screen-lg px-5 mx-auto flex">
|
||||
<div className="flex-1 min-w-[300px]">
|
||||
<SearchInput />
|
||||
<div className="mt-10">
|
||||
<HomeFeed type="search" />
|
||||
</div>
|
||||
</div>
|
||||
<HomeSidebar hideSearch={true} />
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default Search
|
||||
@@ -0,0 +1,46 @@
|
||||
import { Metadata } from "next"
|
||||
|
||||
import { HomeFeed } from "~/components/home/HomeFeed"
|
||||
import { HomeSidebar } from "~/components/home/HomeSidebar"
|
||||
import { APP_NAME } from "~/lib/env"
|
||||
|
||||
import topics from "../../../../../data/topics.json"
|
||||
|
||||
export function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: {
|
||||
topic: string
|
||||
}
|
||||
}): Metadata {
|
||||
return {
|
||||
title: `Topic: ${params.topic} - ${APP_NAME}`,
|
||||
}
|
||||
}
|
||||
|
||||
function Topic({
|
||||
params,
|
||||
}: {
|
||||
params: {
|
||||
topic: string
|
||||
}
|
||||
}) {
|
||||
const info = topics.find((t) => t.name === params.topic)
|
||||
|
||||
return (
|
||||
<section className="pt-24">
|
||||
<div className="max-w-screen-lg px-5 mx-auto flex">
|
||||
<div className="flex-1 min-w-[300px]">
|
||||
<h2 className="text-3xl font-bold">Topic: {params.topic}</h2>
|
||||
<p className="text-zinc-400 mt-4">{info?.description}</p>
|
||||
<div className="mt-10">
|
||||
<HomeFeed type="topic" noteIds={info?.notes} />
|
||||
</div>
|
||||
</div>
|
||||
<HomeSidebar />
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default Topic
|
||||
@@ -0,0 +1,18 @@
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
import { NextServerResponse, getQuery } from "~/lib/server-helper"
|
||||
import { checkDomainServer } from "~/models/site.model"
|
||||
|
||||
// /api/check-domain?handle=innei-4525&domain=blog.innei.ren
|
||||
export async function GET(req: Request): Promise<Response> {
|
||||
const { handle, domain } = getQuery(req)
|
||||
|
||||
if (!handle || !domain) {
|
||||
return NextResponse.json({ error: "Missing characterId or domain" })
|
||||
}
|
||||
const res = new NextServerResponse()
|
||||
|
||||
return res.status(200).json({
|
||||
data: await checkDomainServer(domain as string, handle as string),
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { NextServerResponse } from "~/lib/server-helper"
|
||||
|
||||
// /api/healthcheck
|
||||
export async function GET() {
|
||||
const res = new NextServerResponse()
|
||||
return res.status(200).json({
|
||||
ok: true,
|
||||
})
|
||||
}
|
||||
@@ -1,14 +1,11 @@
|
||||
import { NextApiRequest, NextApiResponse } from "next"
|
||||
|
||||
import { OUR_DOMAIN } from "~/lib/env"
|
||||
import { cacheGet } from "~/lib/redis.server"
|
||||
import { NextServerResponse, getQuery } from "~/lib/server-helper"
|
||||
import { checkDomainServer, fetchTenant } from "~/models/site.model"
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse,
|
||||
) {
|
||||
let { host } = req.query
|
||||
// /api/host2handle?host=blog.innei.ren
|
||||
export async function GET(req: Request) {
|
||||
let { host } = getQuery(req)
|
||||
|
||||
let realHost: string
|
||||
if (Array.isArray(host)) {
|
||||
@@ -57,6 +54,6 @@ export default async function handler(
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
res.status(200).json(result)
|
||||
const res = new NextServerResponse()
|
||||
return res.status(200).json(result)
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
import { NextApiRequest, NextApiResponse } from "next"
|
||||
import { getDefaultSlug } from "~/lib/default-slug"
|
||||
import { NextServerResponse, getQuery } from "~/lib/server-helper"
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse,
|
||||
) {
|
||||
const { address } = req.query
|
||||
export async function GET(req: Request) {
|
||||
const { address } = getQuery(req)
|
||||
|
||||
const result = await (
|
||||
await fetch("https://mirror.xyz/api/graphql", {
|
||||
@@ -20,5 +18,22 @@ export default async function handler(
|
||||
})
|
||||
).json()
|
||||
|
||||
res.status(200).json(result)
|
||||
if (result.data?.projectFeed?.posts?.length) {
|
||||
result.data.projectFeed.posts = result.data.projectFeed.posts.map(
|
||||
(post: any) => {
|
||||
return {
|
||||
title: post.title,
|
||||
date_published: new Date(
|
||||
post.publishedAtTimestamp * 1000,
|
||||
).toISOString(),
|
||||
slug: getDefaultSlug(post.title, post.digest),
|
||||
tags: ["Mirror.xyz"],
|
||||
content: post.body,
|
||||
external_urls: [`https://mirror.xyz/${address}/${post.digest}`],
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
return new NextServerResponse().status(200).json(result)
|
||||
}
|
||||
@@ -1,19 +1,15 @@
|
||||
import { NextApiRequest, NextApiResponse } from "next"
|
||||
|
||||
import { NextServerResponse, getQuery } from "~/lib/server-helper"
|
||||
import { PageVisibilityEnum } from "~/lib/types"
|
||||
import { getPagesBySite } from "~/models/page.model"
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse,
|
||||
) {
|
||||
const query = req.query
|
||||
export async function GET(req: Request) {
|
||||
const query = getQuery(req)
|
||||
|
||||
const result = await getPagesBySite({
|
||||
characterId: +(query.characterId || 0) as number,
|
||||
type: query.type as "post" | "page",
|
||||
visibility: query.visibility as PageVisibilityEnum,
|
||||
limit: query.take ? parseInt(query.take as string) : undefined,
|
||||
limit: query.limit ? parseInt(query.limit as string) : undefined,
|
||||
cursor: query.cursor as string,
|
||||
useStat: true,
|
||||
...(query.tags && {
|
||||
@@ -22,6 +18,6 @@ export default async function handler(
|
||||
: [query.tags as string],
|
||||
}),
|
||||
})
|
||||
|
||||
res.status(200).json(result)
|
||||
const res = new NextServerResponse()
|
||||
return res.status(200).json(result)
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
import { NoteEntity } from "crossbell.js"
|
||||
import { NextApiRequest, NextApiResponse } from "next"
|
||||
import { redirect } from "next/navigation"
|
||||
|
||||
import { IS_VERCEL_PREVIEW } from "~/lib/constants"
|
||||
import { getDefaultSlug } from "~/lib/default-slug"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { NextServerResponse, getQuery } from "~/lib/server-helper"
|
||||
import { checkDomainServer } from "~/models/site.model"
|
||||
|
||||
async function getOriginalNote(
|
||||
@@ -30,15 +31,12 @@ async function getOriginalNote(
|
||||
}
|
||||
}
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse,
|
||||
) {
|
||||
let { characterId, noteId } = req.query
|
||||
export async function GET(req: Request): Promise<Response> {
|
||||
let { characterId, noteId } = getQuery(req)
|
||||
|
||||
const res = new NextServerResponse()
|
||||
if (!characterId || typeof characterId !== "string") {
|
||||
res.status(400).json({ error: "Missing characterId" })
|
||||
return
|
||||
return res.status(400).json({ error: "Missing characterId" })
|
||||
}
|
||||
|
||||
let character
|
||||
@@ -84,6 +82,8 @@ export default async function handler(
|
||||
if (IS_VERCEL_PREVIEW) {
|
||||
const path = new URL(link).pathname
|
||||
|
||||
res.redirect(`/_site/${character.handle}${path}`)
|
||||
} else res.redirect(link)
|
||||
redirect(`/site/${character.handle}${path}`)
|
||||
} else {
|
||||
redirect(link)
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
import { NextApiRequest, NextApiResponse } from "next"
|
||||
import AsyncLock from "async-lock"
|
||||
|
||||
import { toGateway } from "~/lib/ipfs-parser"
|
||||
import prisma from "~/lib/prisma.server"
|
||||
import { cacheGet } from "~/lib/redis.server"
|
||||
import { NextServerResponse, getQuery } from "~/lib/server-helper"
|
||||
|
||||
const lock = new AsyncLock()
|
||||
|
||||
const getOriginalScore = async (cid: string) => {
|
||||
try {
|
||||
@@ -61,70 +64,73 @@ const getOriginalScore = async (cid: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getScore(cid: string) {
|
||||
async function getScore(cid: string) {
|
||||
const score = await cacheGet({
|
||||
key: ["summary_score", cid],
|
||||
allowEmpty: true,
|
||||
noUpdate: true,
|
||||
getValueFun: async () => {
|
||||
const meta = await prisma.metadata.findFirst({
|
||||
where: {
|
||||
uri: `ipfs://${cid}`,
|
||||
},
|
||||
})
|
||||
if (meta) {
|
||||
if (meta?.ai_score !== null) {
|
||||
return {
|
||||
number: meta.ai_score,
|
||||
reason: meta.ai_score_reason,
|
||||
let resut
|
||||
await lock.acquire(cid, async () => {
|
||||
const meta = await prisma.metadata.findFirst({
|
||||
where: {
|
||||
uri: `ipfs://${cid}`,
|
||||
},
|
||||
})
|
||||
if (meta) {
|
||||
if (meta?.ai_score !== null) {
|
||||
resut = {
|
||||
number: meta.ai_score,
|
||||
reason: meta.ai_score_reason,
|
||||
}
|
||||
} else {
|
||||
const score = await getOriginalScore(cid)
|
||||
if (score) {
|
||||
await prisma.metadata.update({
|
||||
where: {
|
||||
uri: `ipfs://${cid}`,
|
||||
},
|
||||
data: {
|
||||
ai_score: score.number,
|
||||
ai_score_reason: score.reason,
|
||||
},
|
||||
})
|
||||
|
||||
resut = score
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const score = await getOriginalScore(cid)
|
||||
if (score) {
|
||||
await prisma.metadata.update({
|
||||
where: {
|
||||
uri: `ipfs://${cid}`,
|
||||
},
|
||||
await prisma.metadata.create({
|
||||
data: {
|
||||
uri: `ipfs://${cid}`,
|
||||
ai_score: score.number,
|
||||
ai_score_reason: score.reason,
|
||||
},
|
||||
})
|
||||
|
||||
return score
|
||||
resut = score
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const score = await getOriginalScore(cid)
|
||||
if (score) {
|
||||
await prisma.metadata.create({
|
||||
data: {
|
||||
uri: `ipfs://${cid}`,
|
||||
ai_score: score.number,
|
||||
ai_score_reason: score.reason,
|
||||
},
|
||||
})
|
||||
|
||||
return score
|
||||
}
|
||||
}
|
||||
})
|
||||
return resut
|
||||
},
|
||||
noUpdate: true,
|
||||
})
|
||||
|
||||
return score
|
||||
}
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse,
|
||||
) {
|
||||
let { cid } = req.query
|
||||
export async function GET(req: Request): Promise<Response> {
|
||||
let { cid } = getQuery(req)
|
||||
|
||||
const res = new NextServerResponse()
|
||||
|
||||
if (!cid) {
|
||||
res.status(400).send("Bad Request")
|
||||
return
|
||||
return res.status(400).send("Bad Request")
|
||||
}
|
||||
|
||||
res.status(200).json({
|
||||
return res.status(200).json({
|
||||
data: await getScore(cid as string),
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { NextServerResponse, getQuery } from "~/lib/server-helper"
|
||||
import { getIdBySlug } from "~/queries/page.server"
|
||||
|
||||
// GET /api/slug2id?characterId=52055&slug=note-144
|
||||
export async function GET(req: Request): Promise<Response> {
|
||||
let { characterId, slug } = getQuery(req)
|
||||
const res = new NextServerResponse()
|
||||
if (!slug || !characterId) {
|
||||
return res.status(400).send("Bad Request")
|
||||
}
|
||||
|
||||
return res
|
||||
.status(200)
|
||||
.send(await getIdBySlug(slug as string, characterId as string))
|
||||
}
|
||||
+5
-24
@@ -1,29 +1,14 @@
|
||||
import { GetServerSideProps } from "next"
|
||||
import { useRouter } from "next/router"
|
||||
import type { ReactElement } from "react"
|
||||
"use client"
|
||||
|
||||
import { useParams } from "next/navigation"
|
||||
|
||||
import { AchievementItem } from "~/components/common/AchievementItem"
|
||||
import { DashboardLayout } from "~/components/dashboard/DashboardLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server"
|
||||
import { DashboardMain } from "~/components/dashboard/DashboardMain"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { useGetAchievements, useGetSite } from "~/queries/site"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
|
||||
async (ctx) => {
|
||||
const { props: layoutProps } = await getLayoutServerSideProps(ctx)
|
||||
|
||||
return {
|
||||
props: {
|
||||
...layoutProps,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
export default function AchievementsPage() {
|
||||
const router = useRouter()
|
||||
const subdomain = router.query.subdomain as string
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
const site = useGetSite(subdomain)
|
||||
|
||||
const achievement = useGetAchievements(site.data?.characterId)
|
||||
@@ -62,7 +47,3 @@ export default function AchievementsPage() {
|
||||
</DashboardMain>
|
||||
)
|
||||
}
|
||||
|
||||
AchievementsPage.getLayout = (page: ReactElement) => {
|
||||
return <DashboardLayout title="Achievements">{page}</DashboardLayout>
|
||||
}
|
||||
+8
-26
@@ -1,34 +1,19 @@
|
||||
import { GetServerSideProps } from "next"
|
||||
import { Trans, useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
import type { ReactElement } from "react"
|
||||
"use client"
|
||||
|
||||
import { useParams } from "next/navigation"
|
||||
import { Virtuoso } from "react-virtuoso"
|
||||
|
||||
import { CommentItem } from "~/components/common/CommentItem"
|
||||
import { DashboardLayout } from "~/components/dashboard/DashboardLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server"
|
||||
import { DashboardMain } from "~/components/dashboard/DashboardMain"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { Trans, useTranslation } from "~/lib/i18n/client"
|
||||
import { useGetCommentsBySite, useGetSite } from "~/queries/site"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
|
||||
async (ctx) => {
|
||||
const { props: layoutProps } = await getLayoutServerSideProps(ctx)
|
||||
|
||||
return {
|
||||
props: {
|
||||
...layoutProps,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
export default function CommentsPage() {
|
||||
const router = useRouter()
|
||||
const subdomain = router.query.subdomain as string
|
||||
const { t } = useTranslation(["dashboard", "common"])
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
const { t, i18n } = useTranslation("dashboard")
|
||||
|
||||
const site = useGetSite(subdomain)
|
||||
|
||||
@@ -98,6 +83,7 @@ export default function CommentsPage() {
|
||||
<div>
|
||||
{name}{" "}
|
||||
<Trans
|
||||
i18n={i18n}
|
||||
i18nKey="comment on your"
|
||||
values={{
|
||||
type: t(type || "", {
|
||||
@@ -137,10 +123,6 @@ export default function CommentsPage() {
|
||||
)
|
||||
}
|
||||
|
||||
CommentsPage.getLayout = (page: ReactElement) => {
|
||||
return <DashboardLayout title="Comments">{page}</DashboardLayout>
|
||||
}
|
||||
|
||||
const Loader = () => {
|
||||
const { t } = useTranslation("common")
|
||||
return (
|
||||
+24
-30
@@ -1,9 +1,9 @@
|
||||
"use client"
|
||||
|
||||
import { useDebounceEffect } from "ahooks"
|
||||
import type { Root } from "mdast"
|
||||
import { nanoid } from "nanoid"
|
||||
import { GetServerSideProps } from "next"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
import { useParams, useRouter, useSearchParams } from "next/navigation"
|
||||
import NodeID3 from "node-id3"
|
||||
import {
|
||||
ChangeEvent,
|
||||
@@ -15,7 +15,6 @@ import {
|
||||
useRef,
|
||||
useState,
|
||||
} from "react"
|
||||
import type { ReactElement } from "react"
|
||||
import toast from "react-hot-toast"
|
||||
import { shallow } from "zustand/shallow"
|
||||
|
||||
@@ -23,8 +22,6 @@ import type { EditorView } from "@codemirror/view"
|
||||
import { useQueryClient } from "@tanstack/react-query"
|
||||
|
||||
import { PageContent } from "~/components/common/PageContent"
|
||||
import { DashboardLayout } from "~/components/dashboard/DashboardLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server"
|
||||
import { DashboardMain } from "~/components/dashboard/DashboardMain"
|
||||
import { OptionsButton } from "~/components/dashboard/OptionsButton"
|
||||
import { PublishButton } from "~/components/dashboard/PublishButton"
|
||||
@@ -50,8 +47,8 @@ import { showConfetti } from "~/lib/confetti"
|
||||
import { getDefaultSlug } from "~/lib/default-slug"
|
||||
import { CSB_SCAN } from "~/lib/env"
|
||||
import { getSiteLink, getTwitterShareUrl } from "~/lib/helpers"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { getPageVisibility } from "~/lib/page-helpers"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { delStorage, setStorage } from "~/lib/storage"
|
||||
import { PageVisibilityEnum } from "~/lib/types"
|
||||
import { cn, pick } from "~/lib/utils"
|
||||
@@ -64,18 +61,6 @@ import {
|
||||
} from "~/queries/page"
|
||||
import { useGetSite } from "~/queries/site"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
|
||||
async (ctx) => {
|
||||
const { props: layoutProps } = await getLayoutServerSideProps(ctx)
|
||||
|
||||
return {
|
||||
props: {
|
||||
...layoutProps,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
const getInputDatetimeValue = (date: Date | string, dayjs: any) => {
|
||||
const str = dayjs(date).format()
|
||||
return str.substring(0, ((str.indexOf("T") | 0) + 6) | 0)
|
||||
@@ -85,10 +70,12 @@ export default function SubdomainEditor() {
|
||||
const router = useRouter()
|
||||
const queryClient = useQueryClient()
|
||||
const { t } = useTranslation("dashboard")
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
const searchParams = useSearchParams()
|
||||
|
||||
let pageId = router.query.id as string | undefined
|
||||
const subdomain = router.query.subdomain as string
|
||||
const isPost = router.query.type === "post"
|
||||
let pageId = searchParams?.get("id") as string | undefined
|
||||
const isPost = searchParams?.get("type") === "post"
|
||||
|
||||
const site = useGetSite(subdomain)
|
||||
|
||||
@@ -105,7 +92,9 @@ export default function SubdomainEditor() {
|
||||
site.data?.characterId,
|
||||
])
|
||||
router.replace(
|
||||
`/dashboard/${subdomain}/editor?id=local-${randomId}&type=${router.query.type}`,
|
||||
`/dashboard/${subdomain}/editor?id=local-${randomId}&type=${searchParams?.get(
|
||||
"type",
|
||||
)}`,
|
||||
)
|
||||
} else {
|
||||
key = `draft-${site.data?.characterId}-${pageId}`
|
||||
@@ -117,7 +106,14 @@ export default function SubdomainEditor() {
|
||||
.replace(`draft-${site.data?.characterId}-`, ""),
|
||||
)
|
||||
}
|
||||
}, [subdomain, pageId, queryClient, router, site.data?.characterId])
|
||||
}, [
|
||||
subdomain,
|
||||
pageId,
|
||||
queryClient,
|
||||
router,
|
||||
site.data?.characterId,
|
||||
searchParams,
|
||||
])
|
||||
|
||||
const page = useGetPage({
|
||||
characterId: site.data?.characterId,
|
||||
@@ -272,7 +268,9 @@ export default function SubdomainEditor() {
|
||||
|
||||
if (createOrUpdatePage.data.data) {
|
||||
router.replace(
|
||||
`/dashboard/${subdomain}/editor?id=${site.data?.characterId}-${createOrUpdatePage.data.data}&type=${router.query.type}`,
|
||||
`/dashboard/${subdomain}/editor?id=${site.data?.characterId}-${
|
||||
createOrUpdatePage.data.data
|
||||
}&type=${searchParams?.get("type")}`,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -507,7 +505,7 @@ export default function SubdomainEditor() {
|
||||
|
||||
const onPreviewButtonClick = useCallback(() => {
|
||||
window.open(
|
||||
`/_site/${subdomain}/preview/${draftKey.replace(
|
||||
`/site/${subdomain}/preview/${draftKey.replace(
|
||||
`draft-${site.data?.characterId}-`,
|
||||
"",
|
||||
)}`,
|
||||
@@ -763,10 +761,6 @@ export default function SubdomainEditor() {
|
||||
)
|
||||
}
|
||||
|
||||
SubdomainEditor.getLayout = (page: ReactElement) => {
|
||||
return <DashboardLayout title="Editor">{page}</DashboardLayout>
|
||||
}
|
||||
|
||||
const EditorExtraProperties: FC<{
|
||||
updateValue: <K extends keyof Values>(key: K, value: Values[K]) => void
|
||||
isPost: boolean
|
||||
+3
-22
@@ -1,35 +1,20 @@
|
||||
import { GetServerSideProps } from "next"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import type { ReactElement } from "react"
|
||||
"use client"
|
||||
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
import { CharacterFloatCard } from "~/components/common/CharacterFloatCard"
|
||||
import { DashboardLayout } from "~/components/dashboard/DashboardLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server"
|
||||
import { DashboardMain } from "~/components/dashboard/DashboardMain"
|
||||
import { Avatar } from "~/components/ui/Avatar"
|
||||
import { Image } from "~/components/ui/Image"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { getStorage, setStorage } from "~/lib/storage"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { useGetPagesBySite } from "~/queries/page"
|
||||
import { useGetSite } from "~/queries/site"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
|
||||
async (ctx) => {
|
||||
const { props: layoutProps } = await getLayoutServerSideProps(ctx)
|
||||
|
||||
return {
|
||||
props: {
|
||||
...layoutProps,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
function SiteAvatar({ siteId }: { siteId: string }) {
|
||||
const site = useGetSite(siteId)
|
||||
return (
|
||||
@@ -189,7 +174,3 @@ export default function EventsPage() {
|
||||
</DashboardMain>
|
||||
)
|
||||
}
|
||||
|
||||
EventsPage.getLayout = (page: ReactElement) => {
|
||||
return <DashboardLayout title="Events">{page}</DashboardLayout>
|
||||
}
|
||||
+7
-27
@@ -1,38 +1,24 @@
|
||||
"use client"
|
||||
|
||||
import type { NoteMetadata } from "crossbell.js"
|
||||
import { GetServerSideProps } from "next"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
import { ReactElement, useEffect, useState } from "react"
|
||||
import { useParams } from "next/navigation"
|
||||
import { useEffect, useState } from "react"
|
||||
import { useForm } from "react-hook-form"
|
||||
import { toast } from "react-hot-toast"
|
||||
|
||||
import { DashboardLayout } from "~/components/dashboard/DashboardLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server"
|
||||
import { DashboardMain } from "~/components/dashboard/DashboardMain"
|
||||
import { ImportPreview } from "~/components/dashboard/ImportPreview"
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { Input } from "~/components/ui/Input"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { readFiles } from "~/lib/read-files"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { usePostNotes } from "~/queries/page"
|
||||
import { useGetSite } from "~/queries/site"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
|
||||
async (ctx) => {
|
||||
const { props: layoutProps } = await getLayoutServerSideProps(ctx)
|
||||
|
||||
return {
|
||||
props: {
|
||||
...layoutProps,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
export default function ImportMarkdownPage() {
|
||||
const router = useRouter()
|
||||
const subdomain = router.query.subdomain as string
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
const site = useGetSite(subdomain)
|
||||
const { t } = useTranslation("dashboard")
|
||||
const form = useForm({
|
||||
@@ -131,9 +117,3 @@ export default function ImportMarkdownPage() {
|
||||
</DashboardMain>
|
||||
)
|
||||
}
|
||||
|
||||
ImportMarkdownPage.getLayout = (page: ReactElement) => {
|
||||
return (
|
||||
<DashboardLayout title="Import from Markdown files">{page}</DashboardLayout>
|
||||
)
|
||||
}
|
||||
+7
-27
@@ -1,36 +1,22 @@
|
||||
"use client"
|
||||
|
||||
import type { NoteMetadata } from "crossbell.js"
|
||||
import { GetServerSideProps } from "next"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
import { ReactElement, useEffect } from "react"
|
||||
import { useParams } from "next/navigation"
|
||||
import { useEffect } from "react"
|
||||
import { useForm } from "react-hook-form"
|
||||
import { toast } from "react-hot-toast"
|
||||
|
||||
import { DashboardLayout } from "~/components/dashboard/DashboardLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server"
|
||||
import { DashboardMain } from "~/components/dashboard/DashboardMain"
|
||||
import { ImportPreview } from "~/components/dashboard/ImportPreview"
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { useCheckMirror, useGetMirrorXyz, usePostNotes } from "~/queries/page"
|
||||
import { useGetSite } from "~/queries/site"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
|
||||
async (ctx) => {
|
||||
const { props: layoutProps } = await getLayoutServerSideProps(ctx)
|
||||
|
||||
return {
|
||||
props: {
|
||||
...layoutProps,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
export default function ImportMarkdownPage() {
|
||||
const router = useRouter()
|
||||
const subdomain = router.query.subdomain as string
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
const site = useGetSite(subdomain)
|
||||
const { t } = useTranslation("dashboard")
|
||||
const form = useForm({
|
||||
@@ -123,9 +109,3 @@ export default function ImportMarkdownPage() {
|
||||
</DashboardMain>
|
||||
)
|
||||
}
|
||||
|
||||
ImportMarkdownPage.getLayout = (page: ReactElement) => {
|
||||
return (
|
||||
<DashboardLayout title="Import from Mirror.xyz">{page}</DashboardLayout>
|
||||
)
|
||||
}
|
||||
+6
-25
@@ -1,29 +1,14 @@
|
||||
import { GetServerSideProps } from "next"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
import type { ReactElement } from "react"
|
||||
"use client"
|
||||
|
||||
import { usePathname } from "next/navigation"
|
||||
|
||||
import { DashboardLayout } from "~/components/dashboard/DashboardLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server"
|
||||
import { DashboardMain } from "~/components/dashboard/DashboardMain"
|
||||
import { Image } from "~/components/ui/Image"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
|
||||
async (ctx) => {
|
||||
const { props: layoutProps } = await getLayoutServerSideProps(ctx)
|
||||
|
||||
return {
|
||||
props: {
|
||||
...layoutProps,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
|
||||
export default function ImportPage() {
|
||||
const router = useRouter()
|
||||
const pathname = usePathname()
|
||||
const { t } = useTranslation("dashboard")
|
||||
|
||||
const options = [
|
||||
@@ -46,7 +31,7 @@ export default function ImportPage() {
|
||||
<UniLink
|
||||
className="prose p-6 bg-slate-100 rounded-lg relative flex items-center"
|
||||
key={option.name}
|
||||
href={router.asPath + option.path}
|
||||
href={pathname + option.path}
|
||||
>
|
||||
<span className="w-8 h-8 mr-4">
|
||||
<Image
|
||||
@@ -64,7 +49,3 @@ export default function ImportPage() {
|
||||
</DashboardMain>
|
||||
)
|
||||
}
|
||||
|
||||
ImportPage.getLayout = (page: ReactElement) => {
|
||||
return <DashboardLayout title="Import">{page}</DashboardLayout>
|
||||
}
|
||||
+18
-16
@@ -1,4 +1,6 @@
|
||||
import { useRouter } from "next/router"
|
||||
"use client"
|
||||
|
||||
import { useParams, usePathname } from "next/navigation"
|
||||
import React, { useEffect } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
@@ -10,10 +12,13 @@ import {
|
||||
|
||||
import { ConnectButton } from "~/components/common/ConnectButton"
|
||||
import { Logo } from "~/components/common/Logo"
|
||||
import { DashboardSidebar } from "~/components/dashboard/DashboardSidebar"
|
||||
import { DashboardTopbar } from "~/components/dashboard/DashboardTopbar"
|
||||
import { Avatar } from "~/components/ui/Avatar"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { useIsMobileLayout } from "~/hooks/useMobileLayout"
|
||||
import { useUserRole } from "~/hooks/useUserRole"
|
||||
import { APP_NAME, DISCORD_LINK } from "~/lib/env"
|
||||
import { DISCORD_LINK } from "~/lib/env"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { toGateway } from "~/lib/ipfs-parser"
|
||||
import { getStorage } from "~/lib/storage"
|
||||
@@ -21,20 +26,15 @@ import { cn } from "~/lib/utils"
|
||||
import { useGetPagesBySite } from "~/queries/page"
|
||||
import { useGetSite } from "~/queries/site"
|
||||
|
||||
import { SEOHead } from "../common/SEOHead"
|
||||
import { UniLink } from "../ui/UniLink"
|
||||
import { DashboardSidebar } from "./DashboardSidebar"
|
||||
import { DashboardTopbar } from "./DashboardTopbar"
|
||||
|
||||
export function DashboardLayout({
|
||||
export default function DashboardLayout({
|
||||
children,
|
||||
title,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
title: string
|
||||
}) {
|
||||
const router = useRouter()
|
||||
const subdomain = router.query.subdomain as string
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
const site = useGetSite(subdomain)
|
||||
|
||||
const userRole = useUserRole(subdomain)
|
||||
@@ -48,6 +48,7 @@ export function DashboardLayout({
|
||||
const { t } = useTranslation("dashboard")
|
||||
|
||||
const isMobileLayout = useIsMobileLayout()
|
||||
const pathname = usePathname()
|
||||
|
||||
useEffect(() => {
|
||||
if (ssrReady) {
|
||||
@@ -92,7 +93,7 @@ export function DashboardLayout({
|
||||
const links: {
|
||||
href?: string
|
||||
onClick?: () => void
|
||||
isActive: (ctx: { href: string; pathname: string }) => boolean
|
||||
isActive: (ctx: { href: string; pathname: string | null }) => boolean
|
||||
icon: React.ReactNode
|
||||
text: string
|
||||
}[] = [
|
||||
@@ -131,7 +132,7 @@ export function DashboardLayout({
|
||||
{
|
||||
href: `/dashboard/${subdomain}/import`,
|
||||
isActive: ({ pathname }) =>
|
||||
pathname.startsWith(`/dashboard/${subdomain}/import`),
|
||||
!!pathname?.startsWith(`/dashboard/${subdomain}/import`),
|
||||
icon: "icon-[mingcute--file-import-line]",
|
||||
text: "Import",
|
||||
},
|
||||
@@ -158,7 +159,7 @@ export function DashboardLayout({
|
||||
{
|
||||
href: `/dashboard/${subdomain}/settings/general`,
|
||||
isActive: ({ pathname }) =>
|
||||
pathname.startsWith(`/dashboard/${subdomain}/settings`),
|
||||
!!pathname?.startsWith(`/dashboard/${subdomain}/settings`),
|
||||
icon: "icon-[mingcute--settings-3-line]",
|
||||
text: "Settings",
|
||||
},
|
||||
@@ -167,7 +168,8 @@ export function DashboardLayout({
|
||||
return ready ? (
|
||||
hasPermission ? (
|
||||
<>
|
||||
<SEOHead title={t(title) || ""} siteName={APP_NAME} />
|
||||
{/* TODO */}
|
||||
{/* <SEOHead title={t(title) || ""} siteName={APP_NAME} /> */}
|
||||
{site?.data?.metadata?.content?.css && (
|
||||
<link
|
||||
type="text/css"
|
||||
@@ -212,7 +214,7 @@ export function DashboardLayout({
|
||||
const active =
|
||||
link.href &&
|
||||
link.isActive({
|
||||
pathname: router.asPath,
|
||||
pathname: pathname,
|
||||
href: link.href,
|
||||
})
|
||||
return (
|
||||
@@ -313,7 +315,7 @@ export function DashboardLayout({
|
||||
const active =
|
||||
link.href &&
|
||||
link.isActive({
|
||||
pathname: router.asPath,
|
||||
pathname: pathname,
|
||||
href: link.href,
|
||||
})
|
||||
return (
|
||||
@@ -1,45 +1,30 @@
|
||||
import { GetServerSideProps } from "next"
|
||||
import { Trans, useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
import type { ReactElement } from "react"
|
||||
"use client"
|
||||
|
||||
import { useParams } from "next/navigation"
|
||||
|
||||
import { CharacterFloatCard } from "~/components/common/CharacterFloatCard"
|
||||
import { DashboardLayout } from "~/components/dashboard/DashboardLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server"
|
||||
import { DashboardMain } from "~/components/dashboard/DashboardMain"
|
||||
import { Image } from "~/components/ui/Image"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
import { CSB_SCAN, DISCORD_LINK, GITHUB_LINK, TWITTER_LINK } from "~/lib/env"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { Trans, useTranslation } from "~/lib/i18n/client"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { useGetShowcase } from "~/queries/home"
|
||||
import { useGetPagesBySite } from "~/queries/page"
|
||||
import { useGetSite, useGetStat, useGetTips } from "~/queries/site"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
|
||||
async (ctx) => {
|
||||
const { props: layoutProps } = await getLayoutServerSideProps(ctx)
|
||||
|
||||
return {
|
||||
props: {
|
||||
...layoutProps,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
export default function SubdomainIndex() {
|
||||
const router = useRouter()
|
||||
const subdomain = router.query.subdomain as string
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
const site = useGetSite(subdomain)
|
||||
const characterId = site.data?.characterId
|
||||
const stat = useGetStat({
|
||||
characterId,
|
||||
})
|
||||
const date = useDate()
|
||||
const { t } = useTranslation("dashboard")
|
||||
const { t, i18n } = useTranslation("dashboard")
|
||||
const tips = useGetTips({
|
||||
toCharacterId: characterId,
|
||||
limit: 1000,
|
||||
@@ -129,6 +114,7 @@ export default function SubdomainIndex() {
|
||||
</div>
|
||||
<div className="prose p-6 bg-slate-50 rounded-lg relative">
|
||||
<Trans
|
||||
i18n={i18n}
|
||||
i18nKey="hello.welcome"
|
||||
defaults="<p>👋 Hello there,</p><p>Welcome to use xLog!</p><p>Here are some useful links to get started:</p>"
|
||||
components={{
|
||||
@@ -158,6 +144,7 @@ export default function SubdomainIndex() {
|
||||
</li>
|
||||
</ul>
|
||||
<Trans
|
||||
i18n={i18n}
|
||||
i18nKey="hello.community"
|
||||
defaults="<p>Join the community to meet friends or build xLog together:</p>"
|
||||
components={{
|
||||
@@ -280,7 +267,3 @@ export default function SubdomainIndex() {
|
||||
</DashboardMain>
|
||||
)
|
||||
}
|
||||
|
||||
SubdomainIndex.getLayout = (page: ReactElement) => {
|
||||
return <DashboardLayout title="Dashboard">{page}</DashboardLayout>
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { PagesManager } from "~/components/dashboard/PagesManager"
|
||||
|
||||
export default function SubdomainPages() {
|
||||
return <PagesManager isPost={false} />
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { PagesManager } from "~/components/dashboard/PagesManager"
|
||||
|
||||
export default function SubdomainPosts() {
|
||||
return <PagesManager isPost={true} />
|
||||
}
|
||||
+6
-25
@@ -1,34 +1,19 @@
|
||||
import { GetServerSideProps } from "next"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
"use client"
|
||||
|
||||
import { useParams } from "next/navigation"
|
||||
import { useEffect, useState } from "react"
|
||||
import type { ReactElement } from "react"
|
||||
import toast from "react-hot-toast"
|
||||
|
||||
import { MonacoEditor } from "~/components/common/Monaco"
|
||||
import { DashboardLayout } from "~/components/dashboard/DashboardLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server"
|
||||
import { SettingsLayout } from "~/components/dashboard/SettingsLayout"
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { FieldLabel } from "~/components/ui/FieldLabel"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { useGetSite, useUpdateSite } from "~/queries/site"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
|
||||
async (ctx) => {
|
||||
const { props: layoutProps } = await getLayoutServerSideProps(ctx)
|
||||
|
||||
return {
|
||||
props: {
|
||||
...layoutProps,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
export default function SettingsCSSPage() {
|
||||
const router = useRouter()
|
||||
const subdomain = router.query.subdomain as string
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
|
||||
const updateSite = useUpdateSite()
|
||||
const site = useGetSite(subdomain)
|
||||
@@ -132,7 +117,3 @@ export default function SettingsCSSPage() {
|
||||
</SettingsLayout>
|
||||
)
|
||||
}
|
||||
|
||||
SettingsCSSPage.getLayout = (page: ReactElement) => {
|
||||
return <DashboardLayout title="Site Settings">{page}</DashboardLayout>
|
||||
}
|
||||
+17
-30
@@ -1,8 +1,7 @@
|
||||
import { GetServerSideProps } from "next"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
"use client"
|
||||
|
||||
import { useParams, useRouter } from "next/navigation"
|
||||
import { useEffect, useState } from "react"
|
||||
import type { ReactElement } from "react"
|
||||
import { useForm } from "react-hook-form"
|
||||
import toast from "react-hot-toast"
|
||||
|
||||
@@ -11,8 +10,6 @@ import {
|
||||
useUpgradeEmailAccountModal,
|
||||
} from "@crossbell/connect-kit"
|
||||
|
||||
import { DashboardLayout } from "~/components/dashboard/DashboardLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server"
|
||||
import { SettingsLayout } from "~/components/dashboard/SettingsLayout"
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { Input } from "~/components/ui/Input"
|
||||
@@ -20,30 +17,19 @@ import { UniLink } from "~/components/ui/UniLink"
|
||||
import { useUserRole } from "~/hooks/useUserRole"
|
||||
import { OUR_DOMAIN } from "~/lib/env"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { checkDomain, getSite } from "~/models/site.model"
|
||||
import { useGetSite, useUpdateSite } from "~/queries/site"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
|
||||
async (ctx) => {
|
||||
const { props: layoutProps } = await getLayoutServerSideProps(ctx)
|
||||
|
||||
return {
|
||||
props: {
|
||||
...layoutProps,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
export default function SettingsDomainsPage() {
|
||||
const router = useRouter()
|
||||
const subdomain = router.query.subdomain as string
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
|
||||
const updateSite = useUpdateSite()
|
||||
const site = useGetSite(subdomain)
|
||||
const userRole = useUserRole(subdomain)
|
||||
const { t } = useTranslation("dashboard")
|
||||
const router = useRouter()
|
||||
|
||||
const isEmailAccount = useAccountState(
|
||||
(s) => s.computed.account?.type === "email",
|
||||
@@ -82,11 +68,16 @@ export default function SettingsDomainsPage() {
|
||||
if (updateSite.isSuccess) {
|
||||
if (updateSite.data?.code === 0) {
|
||||
toast.success("Saved!")
|
||||
router.replace(
|
||||
`/dashboard/${
|
||||
updateSite.variables?.subdomain || updateSite.variables?.site
|
||||
}/settings/domains`,
|
||||
)
|
||||
useAccountState
|
||||
.getState()
|
||||
.refresh()
|
||||
.then(() => {
|
||||
router.replace(
|
||||
`/dashboard/${
|
||||
updateSite.variables?.subdomain || updateSite.variables?.site
|
||||
}/settings/domains`,
|
||||
)
|
||||
})
|
||||
} else {
|
||||
toast.error("Failed to update site" + ": " + updateSite.data.message)
|
||||
}
|
||||
@@ -312,7 +303,3 @@ export default function SettingsDomainsPage() {
|
||||
</SettingsLayout>
|
||||
)
|
||||
}
|
||||
|
||||
SettingsDomainsPage.getLayout = (page: ReactElement) => {
|
||||
return <DashboardLayout title="Site Settings">{page}</DashboardLayout>
|
||||
}
|
||||
+20
-32
@@ -1,42 +1,26 @@
|
||||
import { GetServerSideProps } from "next"
|
||||
import { Trans, useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
"use client"
|
||||
|
||||
import { useParams } from "next/navigation"
|
||||
import { useEffect, useState } from "react"
|
||||
import type { ReactElement } from "react"
|
||||
import { Controller, useForm } from "react-hook-form"
|
||||
import toast from "react-hot-toast"
|
||||
|
||||
import { DashboardLayout } from "~/components/dashboard/DashboardLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server"
|
||||
import { SettingsLayout } from "~/components/dashboard/SettingsLayout"
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { ImageUploader } from "~/components/ui/ImageUploader"
|
||||
import { Input } from "~/components/ui/Input"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { Trans, useTranslation } from "~/lib/i18n/client"
|
||||
import { toIPFS } from "~/lib/ipfs-parser"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { useGetSite, useUpdateSite } from "~/queries/site"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
|
||||
async (ctx) => {
|
||||
const { props: layoutProps } = await getLayoutServerSideProps(ctx)
|
||||
|
||||
return {
|
||||
props: {
|
||||
...layoutProps,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
export default function SiteSettingsGeneralPage() {
|
||||
const router = useRouter()
|
||||
|
||||
const subdomain = router.query.subdomain as string
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
|
||||
const updateSite = useUpdateSite()
|
||||
const site = useGetSite(subdomain)
|
||||
const { t } = useTranslation("dashboard")
|
||||
const { t, i18n } = useTranslation("dashboard")
|
||||
|
||||
const form = useForm({
|
||||
defaultValues: {
|
||||
@@ -93,7 +77,7 @@ export default function SiteSettingsGeneralPage() {
|
||||
!form.getValues("banner") &&
|
||||
form.setValue(
|
||||
"banner",
|
||||
site.data?.metadata?.content?.banners?.[0]
|
||||
site.data?.metadata?.content?.banners?.[0]?.address
|
||||
? {
|
||||
address: toIPFS(
|
||||
site.data?.metadata?.content?.banners?.[0].address || "",
|
||||
@@ -201,7 +185,11 @@ export default function SiteSettingsGeneralPage() {
|
||||
label="Google Analytics"
|
||||
help={
|
||||
<p>
|
||||
<Trans i18nKey="Integrate Google Analytics" ns="dashboard">
|
||||
<Trans
|
||||
i18n={i18n}
|
||||
i18nKey="Integrate Google Analytics"
|
||||
ns="dashboard"
|
||||
>
|
||||
Integrate Google Analytics into your site. You can follow the
|
||||
instructions{" "}
|
||||
<UniLink
|
||||
@@ -223,9 +211,13 @@ export default function SiteSettingsGeneralPage() {
|
||||
label="Umami Cloud Analytics"
|
||||
help={
|
||||
<p>
|
||||
<Trans i18nKey="Integrate Umami Cloud Analytics" ns="dashboard">
|
||||
Integrate Umami Cloud Analytics into your site. You can follow the
|
||||
instructions{" "}
|
||||
<Trans
|
||||
i18n={i18n}
|
||||
i18nKey="Integrate Umami Cloud Analytics"
|
||||
ns="dashboard"
|
||||
>
|
||||
Integrate Umami Cloud Analytics into your site. You can follow
|
||||
the instructions{" "}
|
||||
<UniLink
|
||||
className="underline"
|
||||
href="https://umami.is/docs/collect-data"
|
||||
@@ -259,7 +251,3 @@ export default function SiteSettingsGeneralPage() {
|
||||
</SettingsLayout>
|
||||
)
|
||||
}
|
||||
|
||||
SiteSettingsGeneralPage.getLayout = (page: ReactElement) => {
|
||||
return <DashboardLayout title="Site Settings">{page}</DashboardLayout>
|
||||
}
|
||||
+6
-26
@@ -1,34 +1,19 @@
|
||||
"use client"
|
||||
|
||||
import equal from "fast-deep-equal"
|
||||
import { nanoid } from "nanoid"
|
||||
import { GetServerSideProps } from "next"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
import { useParams } from "next/navigation"
|
||||
import { ChangeEvent, FormEvent, useEffect, useMemo, useState } from "react"
|
||||
import type { ReactElement } from "react"
|
||||
import toast from "react-hot-toast"
|
||||
import { ReactSortable } from "react-sortablejs"
|
||||
|
||||
import { DashboardLayout } from "~/components/dashboard/DashboardLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server"
|
||||
import { SettingsLayout } from "~/components/dashboard/SettingsLayout"
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { Input } from "~/components/ui/Input"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { SiteNavigationItem } from "~/lib/types"
|
||||
import { useGetSite, useUpdateSite } from "~/queries/site"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
|
||||
async (ctx) => {
|
||||
const { props: layoutProps } = await getLayoutServerSideProps(ctx)
|
||||
|
||||
return {
|
||||
props: {
|
||||
...layoutProps,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
type UpdateItem = (id: string, newItem: Partial<SiteNavigationItem>) => void
|
||||
|
||||
type RemoveItem = (id: string) => void
|
||||
@@ -80,9 +65,8 @@ const SortableNavigationItem: React.FC<{
|
||||
}
|
||||
|
||||
export default function SiteSettingsNavigationPage() {
|
||||
const router = useRouter()
|
||||
|
||||
const subdomain = router.query.subdomain as string
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
|
||||
const updateSite = useUpdateSite()
|
||||
const site = useGetSite(subdomain)
|
||||
@@ -211,7 +195,3 @@ export default function SiteSettingsNavigationPage() {
|
||||
</SettingsLayout>
|
||||
)
|
||||
}
|
||||
|
||||
SiteSettingsNavigationPage.getLayout = (page: ReactElement) => {
|
||||
return <DashboardLayout title="Site Settings">{page}</DashboardLayout>
|
||||
}
|
||||
+6
-26
@@ -1,8 +1,7 @@
|
||||
import { GetServerSideProps } from "next"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
"use client"
|
||||
|
||||
import { useParams } from "next/navigation"
|
||||
import { useEffect, useState } from "react"
|
||||
import type { ReactElement } from "react"
|
||||
import toast from "react-hot-toast"
|
||||
|
||||
import {
|
||||
@@ -12,15 +11,13 @@ import {
|
||||
import { Dialog } from "@headlessui/react"
|
||||
|
||||
import { CharacterCard } from "~/components/common/CharacterCard"
|
||||
import { DashboardLayout } from "~/components/dashboard/DashboardLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server"
|
||||
import { SettingsLayout } from "~/components/dashboard/SettingsLayout"
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { Input } from "~/components/ui/Input"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { useUserRole } from "~/hooks/useUserRole"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import {
|
||||
useAddOperator,
|
||||
useGetOperators,
|
||||
@@ -28,18 +25,6 @@ import {
|
||||
useRemoveOperator,
|
||||
} from "~/queries/site"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
|
||||
async (ctx) => {
|
||||
const { props: layoutProps } = await getLayoutServerSideProps(ctx)
|
||||
|
||||
return {
|
||||
props: {
|
||||
...layoutProps,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
type RemoveItem = (operator: string) => void
|
||||
|
||||
const SortableNavigationItem: React.FC<{
|
||||
@@ -78,9 +63,8 @@ const SortableNavigationItem: React.FC<{
|
||||
}
|
||||
|
||||
export default function SettingsOperatorPage() {
|
||||
const router = useRouter()
|
||||
|
||||
const subdomain = router.query.subdomain as string
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
|
||||
const addOperator = useAddOperator()
|
||||
const removeOperator = useRemoveOperator()
|
||||
@@ -275,7 +259,3 @@ export default function SettingsOperatorPage() {
|
||||
</SettingsLayout>
|
||||
)
|
||||
}
|
||||
|
||||
SettingsOperatorPage.getLayout = (page: ReactElement) => {
|
||||
return <DashboardLayout title="Site Settings">{page}</DashboardLayout>
|
||||
}
|
||||
+9
-29
@@ -1,35 +1,20 @@
|
||||
"use client"
|
||||
|
||||
import equal from "fast-deep-equal"
|
||||
import { nanoid } from "nanoid"
|
||||
import { GetServerSideProps } from "next"
|
||||
import { Trans, useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
import { useParams } from "next/navigation"
|
||||
import { ChangeEvent, FormEvent, useEffect, useMemo, useState } from "react"
|
||||
import type { ReactElement } from "react"
|
||||
import toast from "react-hot-toast"
|
||||
import { ReactSortable } from "react-sortablejs"
|
||||
|
||||
import { DashboardLayout } from "~/components/dashboard/DashboardLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server"
|
||||
import { SettingsLayout } from "~/components/dashboard/SettingsLayout"
|
||||
import { Platform } from "~/components/site/Platform"
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { Input } from "~/components/ui/Input"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { Trans, useTranslation } from "~/lib/i18n/client"
|
||||
import { useGetSite, useUpdateSite } from "~/queries/site"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
|
||||
async (ctx) => {
|
||||
const { props: layoutProps } = await getLayoutServerSideProps(ctx)
|
||||
|
||||
return {
|
||||
props: {
|
||||
...layoutProps,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
type Item = {
|
||||
identity: string
|
||||
platform: string
|
||||
@@ -90,13 +75,12 @@ const SortableNavigationItem: React.FC<{
|
||||
}
|
||||
|
||||
export default function SiteSettingsNavigationPage() {
|
||||
const router = useRouter()
|
||||
|
||||
const subdomain = router.query.subdomain as string
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
|
||||
const updateSite = useUpdateSite()
|
||||
const site = useGetSite(subdomain)
|
||||
const { t } = useTranslation("dashboard")
|
||||
const { t, i18n } = useTranslation("dashboard")
|
||||
|
||||
const [items, setItems] = useState<Item[]>([])
|
||||
|
||||
@@ -183,7 +167,7 @@ export default function SiteSettingsNavigationPage() {
|
||||
</p>
|
||||
<p>
|
||||
<span className="text-zinc-800">
|
||||
<Trans ns="dashboard" i18nKey="social tips.p2">
|
||||
<Trans i18n={i18n} ns="dashboard" i18nKey="social tips.p2">
|
||||
We support{" "}
|
||||
<UniLink
|
||||
href="https://github.com/Crossbell-Box/xLog/blob/dev/src/components/site/Platform.tsx#L7"
|
||||
@@ -199,7 +183,7 @@ export default function SiteSettingsNavigationPage() {
|
||||
</p>
|
||||
<p>
|
||||
<span className="text-zinc-800">
|
||||
<Trans ns="dashboard" i18nKey="social tips.p3">
|
||||
<Trans i18n={i18n} ns="dashboard" i18nKey="social tips.p3">
|
||||
You can also connect to Twitter, Telegram Channel, Medium,
|
||||
Substack and more and automatically sync content on{" "}
|
||||
<UniLink href="https://xsync.app/" className="underline">
|
||||
@@ -251,7 +235,3 @@ export default function SiteSettingsNavigationPage() {
|
||||
</SettingsLayout>
|
||||
)
|
||||
}
|
||||
|
||||
SiteSettingsNavigationPage.getLayout = (page: ReactElement) => {
|
||||
return <DashboardLayout title="Site Settings">{page}</DashboardLayout>
|
||||
}
|
||||
+9
-27
@@ -1,7 +1,6 @@
|
||||
import { GetServerSideProps } from "next"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
import type { ReactElement } from "react"
|
||||
"use client"
|
||||
|
||||
import { useParams } from "next/navigation"
|
||||
|
||||
import {
|
||||
useAccountBalance,
|
||||
@@ -9,32 +8,19 @@ import {
|
||||
useWalletClaimCSBModal,
|
||||
} from "@crossbell/connect-kit"
|
||||
|
||||
import { DashboardLayout } from "~/components/dashboard/DashboardLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server"
|
||||
import { DashboardMain } from "~/components/dashboard/DashboardMain"
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { MIRA_LINK } from "~/lib/env"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { useGetMiraBalance, useGetSite } from "~/queries/site"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
|
||||
async (ctx) => {
|
||||
const { props: layoutProps } = await getLayoutServerSideProps(ctx)
|
||||
|
||||
return {
|
||||
props: {
|
||||
...layoutProps,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
export default function TokensPage() {
|
||||
const router = useRouter()
|
||||
const { t } = useTranslation(["dashboard", "index"])
|
||||
const subdomain = router.query.subdomain as string
|
||||
const params = useParams()
|
||||
const { t } = useTranslation("dashboard")
|
||||
const { t: indexT } = useTranslation("index")
|
||||
const subdomain = params?.subdomain as string
|
||||
const site = useGetSite(subdomain)
|
||||
|
||||
const miraBalance = useGetMiraBalance(site.data?.characterId)
|
||||
@@ -138,7 +124,7 @@ export default function TokensPage() {
|
||||
<DashboardMain title="Tokens">
|
||||
<div className="min-w-[270px] max-w-screen-lg flex flex-col space-y-8">
|
||||
<div className="text-sm text-zinc-500 leading-relaxed">
|
||||
{t("features.Earn.description", { ns: "index" })}
|
||||
{indexT("features.Earn.description")}
|
||||
</div>
|
||||
{tokens.map((token) => {
|
||||
return (
|
||||
@@ -161,7 +147,3 @@ export default function TokensPage() {
|
||||
</DashboardMain>
|
||||
)
|
||||
}
|
||||
|
||||
TokensPage.getLayout = (page: ReactElement) => {
|
||||
return <DashboardLayout title="Tokens">{page}</DashboardLayout>
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
import { useRouter } from "next/router"
|
||||
"use client"
|
||||
|
||||
import { useRouter } from "next/navigation"
|
||||
import { useEffect, useRef } from "react"
|
||||
|
||||
import {
|
||||
@@ -0,0 +1,28 @@
|
||||
import { SITE_URL } from "~/lib/env"
|
||||
import { parsePost } from "~/lib/json-feed"
|
||||
import { NextServerResponse } from "~/lib/server-helper"
|
||||
import { ExpandedNote } from "~/lib/types"
|
||||
import { getFeed } from "~/models/home.model"
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const searchParams = new URLSearchParams(request.url.split("?")[1])
|
||||
|
||||
const feed = await getFeed({
|
||||
type: "hot",
|
||||
daysInterval: parseInt(searchParams.get("interval") || "0"),
|
||||
})
|
||||
|
||||
const data = {
|
||||
version: "https://jsonfeed.org/version/1",
|
||||
title: "xLog Latest",
|
||||
icon: "https://ipfs.4everland.xyz/ipfs/bafkreigxdnr5lvtjxqin5upquomrti2s77hlgtjy5zaeu43uhpny75rbga",
|
||||
home_page_url: `${SITE_URL}/activities`,
|
||||
feed_url: `${SITE_URL}/feed/latest`,
|
||||
items: feed?.list?.map((post: ExpandedNote) => parsePost(post)),
|
||||
}
|
||||
|
||||
const format = searchParams.get("format") === "xml" ? "xml" : "json"
|
||||
|
||||
const res = new NextServerResponse()
|
||||
return res.status(200).rss(data, format)
|
||||
}
|
||||
@@ -1,15 +1,10 @@
|
||||
// @ts-ignore
|
||||
import jsonfeedToRSS from "jsonfeed-to-rss"
|
||||
import { GetServerSideProps } from "next"
|
||||
|
||||
import { SITE_URL } from "~/lib/env"
|
||||
import { parsePost, setHeader } from "~/lib/json-feed"
|
||||
import { parsePost } from "~/lib/json-feed"
|
||||
import { NextServerResponse } from "~/lib/server-helper"
|
||||
import { ExpandedNote } from "~/lib/types"
|
||||
import { getFeed } from "~/models/home.model"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||
setHeader(ctx)
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const feed = await getFeed({
|
||||
type: "latest",
|
||||
})
|
||||
@@ -23,16 +18,11 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||
items: feed?.list?.map((post: ExpandedNote) => parsePost(post)),
|
||||
}
|
||||
|
||||
ctx.res.write(
|
||||
ctx.query.format === "xml" ? jsonfeedToRSS(data) : JSON.stringify(data),
|
||||
)
|
||||
ctx.res.end()
|
||||
const format =
|
||||
new URLSearchParams(request.url.split("?")[1]).get("format") === "xml"
|
||||
? "xml"
|
||||
: "json"
|
||||
|
||||
return {
|
||||
props: {},
|
||||
}
|
||||
const res = new NextServerResponse()
|
||||
return res.status(200).rss(data, format)
|
||||
}
|
||||
|
||||
const LatestFeed: React.FC = () => null
|
||||
|
||||
export default LatestFeed
|
||||
@@ -0,0 +1,88 @@
|
||||
import "aplayer-react/dist/index.css"
|
||||
import { dir } from "i18next"
|
||||
import { Metadata } from "next"
|
||||
import { Toaster } from "react-hot-toast"
|
||||
|
||||
import "~/css/main.css"
|
||||
import { useAcceptLang } from "~/hooks/useAcceptLang"
|
||||
import { APP_DESCRIPTION, APP_NAME, APP_SLOGAN, SITE_URL } from "~/lib/env"
|
||||
|
||||
import Providers from "./providers"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: `${APP_NAME} - ${APP_SLOGAN}`,
|
||||
description: APP_DESCRIPTION,
|
||||
applicationName: APP_NAME,
|
||||
generator: APP_NAME,
|
||||
keywords: [
|
||||
"blog",
|
||||
"xlog",
|
||||
"blockchain",
|
||||
"ethereum",
|
||||
"web3",
|
||||
"dapp",
|
||||
"crypto",
|
||||
],
|
||||
themeColor: "#ffffff",
|
||||
alternates: {
|
||||
types: {
|
||||
"application/rss+xml": [
|
||||
{ url: "/feed/latest?format=xml", title: "xLog Latest" },
|
||||
{ url: "/feed/hottest?interval=0&format=xml", title: "xLog Hottest" },
|
||||
{
|
||||
url: "/feed/hottest?interval=1&format=xml",
|
||||
title: "xLog Hottest of the Day",
|
||||
},
|
||||
{
|
||||
url: "/feed/hottest?interval=7&format=xml",
|
||||
title: "xLog Hottest of the Week",
|
||||
},
|
||||
{
|
||||
url: "/feed/hottest?interval=30&format=xml",
|
||||
title: "xLog Hottest of the Month",
|
||||
},
|
||||
],
|
||||
"application/feed+json": [
|
||||
{ url: "/feed/latest", title: "xLog Latest" },
|
||||
{ url: "/feed/hottest?interval=0", title: "xLog Hottest" },
|
||||
{ url: "/feed/hottest?interval=1", title: "xLog Hottest of the Day" },
|
||||
{ url: "/feed/hottest?interval=7", title: "xLog Hottest of the Week" },
|
||||
{
|
||||
url: "/feed/hottest?interval=30",
|
||||
title: "xLog Hottest of the Month",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
icons: `${SITE_URL}/assets/logo.svg`,
|
||||
openGraph: {
|
||||
siteName: `${APP_NAME} - ${APP_SLOGAN}`,
|
||||
description: APP_DESCRIPTION,
|
||||
images: [`${SITE_URL}/assets/logo.svg`],
|
||||
},
|
||||
twitter: {
|
||||
card: "summary_large_image",
|
||||
title: `${APP_NAME} - ${APP_SLOGAN}`,
|
||||
description: APP_DESCRIPTION,
|
||||
images: [`${SITE_URL}/assets/logo.svg`],
|
||||
site: "@_xLog",
|
||||
creator: "@_xLog",
|
||||
},
|
||||
}
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const lang = useAcceptLang()
|
||||
|
||||
return (
|
||||
<html lang={lang} dir={dir(lang)}>
|
||||
<body>
|
||||
<Providers lang={lang}>{children}</Providers>
|
||||
<Toaster />
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
import "aplayer-react/dist/index.css"
|
||||
import { Network } from "crossbell.js"
|
||||
import { appWithTranslation } from "next-i18next"
|
||||
import NextNProgress from "nextjs-progressbar"
|
||||
import { Toaster } from "react-hot-toast"
|
||||
import { AppPropsWithLayout } from "types/next"
|
||||
"use client"
|
||||
|
||||
import { useState } from "react"
|
||||
import { WagmiConfig, createClient } from "wagmi"
|
||||
|
||||
import {
|
||||
@@ -14,44 +11,51 @@ import {
|
||||
NotificationModal,
|
||||
NotificationModalColorScheme,
|
||||
} from "@crossbell/notification"
|
||||
import { Hydrate, QueryClient } from "@tanstack/react-query"
|
||||
import { QueryClient } from "@tanstack/react-query"
|
||||
import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client"
|
||||
|
||||
import "~/css/main.css"
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
import { useDarkMode } from "~/hooks/useDarkMode"
|
||||
import { useMobileLayout } from "~/hooks/useMobileLayout"
|
||||
import { APP_NAME, IPFS_GATEWAY } from "~/lib/env"
|
||||
import { useNProgress } from "~/hooks/useNProgress"
|
||||
import { APP_NAME } from "~/lib/env"
|
||||
import { toGateway } from "~/lib/ipfs-parser"
|
||||
import { createIDBPersister } from "~/lib/persister.client"
|
||||
import { urlComposer } from "~/lib/url-composer"
|
||||
|
||||
Network.setIpfsGateway(IPFS_GATEWAY)
|
||||
import { LangProvider } from "~/providers/LangProvider"
|
||||
|
||||
const wagmiClient = createClient(getDefaultClientConfig({ appName: APP_NAME }))
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
cacheTime: 1000 * 60 * 60 * 24, // 24 hours
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const persister = createIDBPersister()
|
||||
|
||||
const colorScheme: NotificationModalColorScheme = {
|
||||
text: `rgb(var(--tw-colors-i-zinc-800))`,
|
||||
textSecondary: `rgb(var(--tw-colors-i-gray-600))`,
|
||||
background: `rgb(var(--tw-colors-i-white))`,
|
||||
text: `rgb(var(--tw-color-zinc-800))`,
|
||||
textSecondary: `rgb(var(--tw-color-gray-600))`,
|
||||
background: `rgb(var(--tw-color-white))`,
|
||||
border: `var(--border-color)`,
|
||||
}
|
||||
|
||||
function MyApp({ Component, pageProps }: AppPropsWithLayout) {
|
||||
const getLayout = Component.getLayout ?? ((page) => page)
|
||||
|
||||
export default function Providers({
|
||||
children,
|
||||
lang,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
lang: string
|
||||
}) {
|
||||
useDarkMode()
|
||||
useMobileLayout()
|
||||
useNProgress()
|
||||
|
||||
const [queryClient] = useState(
|
||||
() =>
|
||||
new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
cacheTime: 1000 * 60 * 60 * 24, // 24 hours
|
||||
},
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
return (
|
||||
<WagmiConfig client={wagmiClient}>
|
||||
@@ -78,31 +82,10 @@ function MyApp({ Component, pageProps }: AppPropsWithLayout) {
|
||||
signInStrategy="simple"
|
||||
ignoreWalletDisconnectEvent={true}
|
||||
>
|
||||
<Hydrate state={pageProps.dehydratedState}>
|
||||
{/* <ReactQueryDevtools /> */}
|
||||
<NextNProgress
|
||||
options={{ easing: "linear", speed: 500, trickleSpeed: 100 }}
|
||||
/>
|
||||
{getLayout(<Component {...pageProps} />)}
|
||||
<Toaster />
|
||||
<NotificationModal colorScheme={colorScheme} />
|
||||
</Hydrate>
|
||||
<LangProvider lang={lang}>{children}</LangProvider>
|
||||
<NotificationModal colorScheme={colorScheme} />
|
||||
</ConnectKitProvider>
|
||||
</PersistQueryClientProvider>
|
||||
</WagmiConfig>
|
||||
)
|
||||
}
|
||||
|
||||
// Only uncomment this method if you have blocking data requirements for
|
||||
// every single page in your application. This disables the ability to
|
||||
// perform automatic static optimization, causing every page in your app to
|
||||
// be server-side rendered.
|
||||
//
|
||||
// MyApp.getInitialProps = async (appContext) => {
|
||||
// // calls page's `getInitialProps` and fills `appProps.pageProps`
|
||||
// const appProps = await App.getInitialProps(appContext);
|
||||
//
|
||||
// return { ...appProps }
|
||||
// }
|
||||
|
||||
export default appWithTranslation(MyApp)
|
||||
@@ -0,0 +1,11 @@
|
||||
import { MetadataRoute } from "next"
|
||||
|
||||
export default function robots(): MetadataRoute.Robots {
|
||||
return {
|
||||
rules: {
|
||||
userAgent: "*",
|
||||
allow: "/",
|
||||
disallow: ["/dashboard/", "/preview/", "/api/"],
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
import { Metadata } from "next"
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
import { Hydrate, dehydrate } from "@tanstack/react-query"
|
||||
|
||||
import { SitePage } from "~/components/site/SitePage"
|
||||
import { SITE_URL } from "~/lib/env"
|
||||
import { useTranslation } from "~/lib/i18n"
|
||||
import getQueryClient from "~/lib/query-client"
|
||||
import { fetchGetPage } from "~/queries/page.server"
|
||||
import { fetchGetSite } from "~/queries/site.server"
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: {
|
||||
site: string
|
||||
slug: string
|
||||
}
|
||||
}): Promise<Metadata> {
|
||||
const queryClient = getQueryClient()
|
||||
|
||||
const site = await fetchGetSite(params.site, queryClient)
|
||||
|
||||
const page = await fetchGetPage(
|
||||
{
|
||||
characterId: site?.characterId,
|
||||
slug: params.slug,
|
||||
useStat: true,
|
||||
},
|
||||
queryClient,
|
||||
)
|
||||
|
||||
const title = `${page?.metadata?.content?.title} - ${
|
||||
site?.metadata?.content?.name || site?.handle
|
||||
}`
|
||||
const description = page?.metadata?.content?.summary
|
||||
const siteImages =
|
||||
site?.metadata?.content?.avatars || `${SITE_URL}/assets/logo.svg`
|
||||
const images = page?.metadata?.content?.cover || siteImages
|
||||
const twitterCreator =
|
||||
"@" +
|
||||
site?.metadata?.content?.connected_accounts
|
||||
?.find((account) => account?.endsWith?.("@twitter"))
|
||||
?.match(/csb:\/\/account:([^@]+)@twitter/)?.[1]
|
||||
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
openGraph: {
|
||||
siteName: title,
|
||||
description,
|
||||
images,
|
||||
},
|
||||
twitter: {
|
||||
card: "summary_large_image",
|
||||
title,
|
||||
description,
|
||||
images,
|
||||
site: "@_xLog",
|
||||
creator: twitterCreator,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default async function SitePagePage({
|
||||
params,
|
||||
}: {
|
||||
params: {
|
||||
site: string
|
||||
slug: string
|
||||
}
|
||||
}) {
|
||||
const queryClient = getQueryClient()
|
||||
|
||||
const site = await fetchGetSite(params.site, queryClient)
|
||||
|
||||
const page = await fetchGetPage(
|
||||
{
|
||||
characterId: site?.characterId,
|
||||
slug: params.slug,
|
||||
useStat: true,
|
||||
},
|
||||
queryClient,
|
||||
)
|
||||
|
||||
if (
|
||||
!page ||
|
||||
new Date(page!.metadata?.content?.date_published || "") > new Date()
|
||||
) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
const dehydratedState = dehydrate(queryClient)
|
||||
|
||||
const { t } = await useTranslation("site")
|
||||
|
||||
return (
|
||||
<Hydrate state={dehydratedState}>
|
||||
<SitePage page={page || undefined} site={site || undefined} />
|
||||
</Hydrate>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import { Metadata } from "next"
|
||||
|
||||
import { Hydrate, dehydrate } from "@tanstack/react-query"
|
||||
|
||||
import { SiteArchives } from "~/components/site/SiteArchives"
|
||||
import getQueryClient from "~/lib/query-client"
|
||||
import { PageVisibilityEnum } from "~/lib/types"
|
||||
import { prefetchGetPagesBySite } from "~/queries/page.server"
|
||||
import { fetchGetSite } from "~/queries/site.server"
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: {
|
||||
site: string
|
||||
}
|
||||
}): Promise<Metadata> {
|
||||
const queryClient = getQueryClient()
|
||||
|
||||
const site = await fetchGetSite(params.site, queryClient)
|
||||
|
||||
const title = `Archives - ${site?.metadata?.content?.name || site?.handle}`
|
||||
|
||||
return {
|
||||
title,
|
||||
}
|
||||
}
|
||||
|
||||
export default async function SiteArchivesPage({
|
||||
params,
|
||||
}: {
|
||||
params: {
|
||||
site: string
|
||||
}
|
||||
}) {
|
||||
const queryClient = getQueryClient()
|
||||
|
||||
const site = await fetchGetSite(params.site, queryClient)
|
||||
await prefetchGetPagesBySite(
|
||||
{
|
||||
characterId: site?.characterId,
|
||||
type: "post",
|
||||
visibility: PageVisibilityEnum.Published,
|
||||
limit: 100,
|
||||
},
|
||||
queryClient,
|
||||
)
|
||||
|
||||
const dehydratedState = dehydrate(queryClient)
|
||||
|
||||
return (
|
||||
<Hydrate state={dehydratedState}>
|
||||
<SiteArchives />
|
||||
</Hydrate>
|
||||
)
|
||||
}
|
||||
+23
-36
@@ -1,26 +1,21 @@
|
||||
// @ts-ignore
|
||||
import jsonfeedToRSS from "jsonfeed-to-rss"
|
||||
import { GetServerSideProps } from "next"
|
||||
|
||||
import { QueryClient } from "@tanstack/react-query"
|
||||
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { setHeader } from "~/lib/json-feed"
|
||||
import { renderPageContent } from "~/markdown"
|
||||
import { fetchGetComments, fetchGetSite } from "~/queries/site.server"
|
||||
import { NextServerResponse } from "~/lib/server-helper"
|
||||
import { getCommentsBySite, getSite } from "~/models/site.model"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||
const queryClient = new QueryClient()
|
||||
setHeader(ctx)
|
||||
const domainOrSubdomain = ctx.params!.site as string
|
||||
|
||||
const site = await fetchGetSite(domainOrSubdomain, queryClient)
|
||||
const comments = await fetchGetComments(
|
||||
{
|
||||
characterId: site?.characterId,
|
||||
},
|
||||
queryClient,
|
||||
)
|
||||
export async function GET(
|
||||
request: Request,
|
||||
{
|
||||
params,
|
||||
}: {
|
||||
params: {
|
||||
site: string
|
||||
}
|
||||
},
|
||||
) {
|
||||
const site = await getSite(params.site)
|
||||
const comments = await getCommentsBySite({
|
||||
characterId: site?.characterId,
|
||||
})
|
||||
|
||||
const link = getSiteLink({
|
||||
subdomain: site?.handle || "",
|
||||
@@ -53,10 +48,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||
return {
|
||||
id: comment.characterId + "-" + comment.noteId,
|
||||
title: `${name}: ${comment.metadata?.content?.content}`,
|
||||
content_html: `${name} commented on ${type} ${toTitle}: ${
|
||||
renderPageContent(comment.metadata?.content?.content || "")
|
||||
.contentHTML
|
||||
}`,
|
||||
content_html: `${name} commented on ${type} ${toTitle}: ${comment.metadata?.content?.content}`,
|
||||
url: `${link}/${
|
||||
comment.toNote?.metadata?.content?.attributes?.find(
|
||||
(attribute: any) => attribute.trait_type === "xlog_slug",
|
||||
@@ -68,16 +60,11 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||
}),
|
||||
}
|
||||
|
||||
ctx.res.write(
|
||||
ctx.query.format === "xml" ? jsonfeedToRSS(data) : JSON.stringify(data),
|
||||
)
|
||||
ctx.res.end()
|
||||
const format =
|
||||
new URLSearchParams(request.url.split("?")[1]).get("format") === "xml"
|
||||
? "xml"
|
||||
: "json"
|
||||
|
||||
return {
|
||||
props: {},
|
||||
}
|
||||
const res = new NextServerResponse()
|
||||
return res.status(200).rss(data, format)
|
||||
}
|
||||
|
||||
const SiteFeed: React.FC = () => null
|
||||
|
||||
export default SiteFeed
|
||||
@@ -0,0 +1,80 @@
|
||||
import { SITE_URL } from "~/lib/env"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { NextServerResponse } from "~/lib/server-helper"
|
||||
import { PageVisibilityEnum } from "~/lib/types"
|
||||
import { getPagesBySite } from "~/models/page.model"
|
||||
import { getSite } from "~/models/site.model"
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
{
|
||||
params,
|
||||
}: {
|
||||
params: {
|
||||
site: string
|
||||
}
|
||||
},
|
||||
) {
|
||||
const site = await getSite(params.site)
|
||||
const pages = await getPagesBySite({
|
||||
characterId: site?.characterId,
|
||||
type: "post",
|
||||
visibility: PageVisibilityEnum.Published,
|
||||
keepBody: true,
|
||||
})
|
||||
|
||||
const hasAudio = pages.list?.find((page) => page.metadata?.content?.audio)
|
||||
|
||||
const link = getSiteLink({
|
||||
subdomain: site?.handle || "",
|
||||
domain: site?.metadata?.content?.custom_domain,
|
||||
})
|
||||
const data = {
|
||||
version: "https://jsonfeed.org/version/1",
|
||||
title: site?.metadata?.content?.name,
|
||||
description: site?.metadata?.content?.bio,
|
||||
icon: site?.metadata?.content?.avatars?.[0],
|
||||
home_page_url: link,
|
||||
feed_url: `${link}/feed`,
|
||||
...(hasAudio && {
|
||||
_itunes: {
|
||||
image: site?.metadata?.content?.avatars?.[0],
|
||||
author: site?.metadata?.content?.name,
|
||||
summary: site?.metadata?.content?.bio,
|
||||
},
|
||||
}),
|
||||
items: pages.list?.map((page) => ({
|
||||
id: page.characterId + "-" + page.noteId,
|
||||
title: page.metadata?.content?.title,
|
||||
summary: page.metadata?.content?.summary,
|
||||
content_html: page.metadata?.content?.content,
|
||||
url: `${SITE_URL}/api/redirection?characterId=${page.characterId}¬eId=${page.noteId}`,
|
||||
image: page.metadata?.content?.cover,
|
||||
date_published: page.metadata?.content?.date_published,
|
||||
date_modified: page.updatedAt,
|
||||
tags: page.metadata?.content?.tags,
|
||||
author: site?.metadata?.content?.name,
|
||||
...(page.metadata?.content?.audio && {
|
||||
_itunes: {
|
||||
image: page.metadata?.content?.cover,
|
||||
summary: page.metadata?.content?.summary,
|
||||
},
|
||||
attachments: [
|
||||
{
|
||||
url: page.metadata?.content?.audio,
|
||||
mime_type: "audio/mpeg",
|
||||
title: page.metadata?.content?.title,
|
||||
},
|
||||
],
|
||||
}),
|
||||
})),
|
||||
}
|
||||
|
||||
const format =
|
||||
new URLSearchParams(request.url.split("?")[1]).get("format") === "xml"
|
||||
? "xml"
|
||||
: "json"
|
||||
|
||||
const res = new NextServerResponse()
|
||||
return res.status(200).rss(data, format)
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
import { Metadata } from "next"
|
||||
import { headers } from "next/headers"
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
import { Hydrate, dehydrate } from "@tanstack/react-query"
|
||||
|
||||
import { BlockchainInfo } from "~/components/common/BlockchainInfo"
|
||||
import { Style } from "~/components/common/Style"
|
||||
import { BackToTopFAB } from "~/components/site/BackToTopFAB"
|
||||
import SiteFooter from "~/components/site/SiteFooter"
|
||||
import { SiteHeader } from "~/components/site/SiteHeader"
|
||||
import { FABContainer } from "~/components/ui/FAB"
|
||||
import { SITE_URL } from "~/lib/env"
|
||||
import getQueryClient from "~/lib/query-client"
|
||||
import { ExpandedNote } from "~/lib/types"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { fetchGetPage } from "~/queries/page.server"
|
||||
import {
|
||||
fetchGetSite,
|
||||
prefetchGetSiteSubscriptions,
|
||||
prefetchGetSiteToSubscriptions,
|
||||
} from "~/queries/site.server"
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: {
|
||||
site: string
|
||||
}
|
||||
}): Promise<Metadata> {
|
||||
const queryClient = getQueryClient()
|
||||
|
||||
const site = await fetchGetSite(params.site, queryClient)
|
||||
|
||||
const title = site?.metadata?.content?.name || site?.handle
|
||||
const description = site?.metadata?.content?.bio
|
||||
const images =
|
||||
site?.metadata?.content?.avatars || `${SITE_URL}/assets/logo.svg`
|
||||
const twitterCreator =
|
||||
"@" +
|
||||
site?.metadata?.content?.connected_accounts
|
||||
?.find((account) => account?.endsWith?.("@twitter"))
|
||||
?.match(/csb:\/\/account:([^@]+)@twitter/)?.[1]
|
||||
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
themeColor: "#ffffff", // TODO
|
||||
alternates: {
|
||||
types: {
|
||||
"application/rss+xml": [
|
||||
{ url: "/feed?format=xml", title },
|
||||
{ url: "/feed/comments?format=xml", title: `Comments on ${title}` },
|
||||
],
|
||||
"application/feed+json": [
|
||||
{ url: "/feed", title },
|
||||
{ url: "/feed/comments", title: `Comments on ${title}` },
|
||||
],
|
||||
},
|
||||
},
|
||||
icons: images,
|
||||
openGraph: {
|
||||
siteName: title,
|
||||
description,
|
||||
images,
|
||||
},
|
||||
twitter: {
|
||||
card: "summary_large_image",
|
||||
title,
|
||||
description,
|
||||
images,
|
||||
site: "@_xLog",
|
||||
creator: twitterCreator,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default async function SiteLayout({
|
||||
children,
|
||||
params,
|
||||
}: {
|
||||
children?: React.ReactNode
|
||||
params: {
|
||||
site: string
|
||||
slug?: string
|
||||
tag?: string
|
||||
}
|
||||
}) {
|
||||
const queryClient = getQueryClient()
|
||||
|
||||
const site = await fetchGetSite(params.site, queryClient)
|
||||
|
||||
// https://github.com/vercel/next.js/issues/46618#issuecomment-1450416633
|
||||
// Issue: The type will not be updated when the page is redirected.
|
||||
const pathname = headers().get("x-pathname")
|
||||
let type: string
|
||||
switch (pathname) {
|
||||
case "/":
|
||||
type = "index"
|
||||
break
|
||||
case "/nft":
|
||||
type = "nft"
|
||||
break
|
||||
case "/archive":
|
||||
type = "archive"
|
||||
break
|
||||
case "/search":
|
||||
type = "search"
|
||||
break
|
||||
default:
|
||||
if (pathname?.startsWith("/tag/")) {
|
||||
type = "tag"
|
||||
} else {
|
||||
type = "post"
|
||||
}
|
||||
}
|
||||
|
||||
let page: ExpandedNote | undefined | null
|
||||
if (site?.characterId) {
|
||||
await Promise.all([
|
||||
prefetchGetSiteSubscriptions(
|
||||
{
|
||||
characterId: site.characterId,
|
||||
},
|
||||
queryClient,
|
||||
),
|
||||
prefetchGetSiteToSubscriptions(
|
||||
{
|
||||
characterId: site.characterId,
|
||||
},
|
||||
queryClient,
|
||||
),
|
||||
new Promise<void>(async (resolve) => {
|
||||
if (type === "post") {
|
||||
page = await fetchGetPage(
|
||||
{
|
||||
characterId: site.characterId,
|
||||
slug: pathname?.slice(1),
|
||||
useStat: true,
|
||||
},
|
||||
queryClient,
|
||||
)
|
||||
resolve()
|
||||
} else {
|
||||
resolve()
|
||||
}
|
||||
}),
|
||||
])
|
||||
} else {
|
||||
notFound()
|
||||
}
|
||||
|
||||
const dehydratedState = dehydrate(queryClient)
|
||||
|
||||
return (
|
||||
<Hydrate state={dehydratedState}>
|
||||
<div
|
||||
className={`xlog-page xlog-page-${type} xlog-user xlog-deprecated-class`}
|
||||
>
|
||||
<Style content={site?.metadata?.content?.css} />
|
||||
{site && <SiteHeader handle={params.site} />}
|
||||
<div
|
||||
className={cn(
|
||||
`xlog-post-id-${page?.characterId}-${page?.noteId}`,
|
||||
"xlog-deprecated-class xlog-post-area max-w-screen-md mx-auto px-5 pt-12 relative",
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
{site && (
|
||||
<div className="max-w-screen-md mx-auto pt-12 pb-10">
|
||||
<BlockchainInfo site={site} page={page || undefined} />
|
||||
</div>
|
||||
)}
|
||||
{/* @ts-expect-error Async Server Component */}
|
||||
<SiteFooter site={site || undefined} />
|
||||
<FABContainer>
|
||||
<BackToTopFAB />
|
||||
</FABContainer>
|
||||
</div>
|
||||
</Hydrate>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import { Metadata } from "next"
|
||||
import Script from "next/script"
|
||||
import type { Asset } from "unidata.js"
|
||||
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { UniMedia } from "~/components/ui/UniMedia"
|
||||
import { useTranslation } from "~/lib/i18n"
|
||||
import getQueryClient from "~/lib/query-client"
|
||||
import { fetchGetSite, getNFTs } from "~/queries/site.server"
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: {
|
||||
site: string
|
||||
}
|
||||
}): Promise<Metadata> {
|
||||
const queryClient = getQueryClient()
|
||||
|
||||
const site = await fetchGetSite(params.site, queryClient)
|
||||
|
||||
const title = `NFT - ${site?.metadata?.content?.name || site?.handle}`
|
||||
|
||||
return {
|
||||
title,
|
||||
}
|
||||
}
|
||||
|
||||
export default async function SiteNFTPage({
|
||||
params,
|
||||
}: {
|
||||
params: {
|
||||
site: string
|
||||
}
|
||||
}) {
|
||||
const queryClient = getQueryClient()
|
||||
|
||||
const site = await fetchGetSite(params.site, queryClient)
|
||||
const { t } = await useTranslation("common")
|
||||
|
||||
const nfts = await getNFTs(site?.owner)
|
||||
|
||||
return (
|
||||
<>
|
||||
<Script
|
||||
type="module"
|
||||
src="https://cdn.jsdelivr.net/npm/@google/model-viewer/dist/model-viewer.min.js"
|
||||
></Script>
|
||||
<h2 className="text-xl font-bold page-title">NFT {t("Showcase")}</h2>
|
||||
<div className="mt-8">
|
||||
<div className="grid grid-cols-3 md:grid-cols-4 gap-10">
|
||||
{nfts.list
|
||||
?.filter((nft: Asset) => nft.items?.[0]?.address)
|
||||
.map((nft: Asset) => (
|
||||
<UniLink
|
||||
key={nft.metadata?.proof}
|
||||
className="xlog-nft flex items-center flex-col"
|
||||
href={nft.related_urls?.[nft.related_urls.length - 1]}
|
||||
data-collection={nft.metadata?.collection_address}
|
||||
data-network={nft.metadata?.network}
|
||||
data-token-id={nft.metadata?.token_id}
|
||||
data-name={nft.name}
|
||||
>
|
||||
<UniMedia
|
||||
src={nft.items?.[0]?.address || ""}
|
||||
mime_type={nft.items?.[0].mime_type}
|
||||
/>
|
||||
<div className="text-xs mt-2 text-center font-medium">
|
||||
{nft.name}
|
||||
</div>
|
||||
</UniLink>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { SitePage } from "~/components/site/SitePage"
|
||||
import { SITE_URL } from "~/lib/env"
|
||||
import { useTranslation } from "~/lib/i18n"
|
||||
|
||||
export default async function NotFound() {
|
||||
const { t } = await useTranslation("site")
|
||||
|
||||
return (
|
||||
<SitePage
|
||||
page={
|
||||
{
|
||||
metadata: {
|
||||
content: {
|
||||
title: t("404 - Whoops, this page is gone."),
|
||||
content: `
|
||||
- [Back to Home](/)
|
||||
- [All posts](/archives)
|
||||
|
||||
`,
|
||||
},
|
||||
},
|
||||
} as any
|
||||
}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import { Hydrate, dehydrate } from "@tanstack/react-query"
|
||||
|
||||
import SiteHome from "~/components/site/SiteHome"
|
||||
import getQueryClient from "~/lib/query-client"
|
||||
import { PageVisibilityEnum } from "~/lib/types"
|
||||
import { prefetchGetPagesBySite } from "~/queries/page.server"
|
||||
import { fetchGetSite } from "~/queries/site.server"
|
||||
|
||||
async function SiteIndexPage({
|
||||
params,
|
||||
}: {
|
||||
params: {
|
||||
site: string
|
||||
}
|
||||
}) {
|
||||
const queryClient = getQueryClient()
|
||||
|
||||
const site = await fetchGetSite(params.site, queryClient)
|
||||
await prefetchGetPagesBySite(
|
||||
{
|
||||
characterId: site?.characterId,
|
||||
type: "post",
|
||||
visibility: PageVisibilityEnum.Published,
|
||||
useStat: true,
|
||||
},
|
||||
queryClient,
|
||||
)
|
||||
|
||||
const dehydratedState = dehydrate(queryClient)
|
||||
|
||||
return (
|
||||
<Hydrate state={dehydratedState}>
|
||||
<SiteHome handle={params.site} />
|
||||
</Hydrate>
|
||||
)
|
||||
}
|
||||
|
||||
export default SiteIndexPage
|
||||
@@ -0,0 +1,57 @@
|
||||
"use client"
|
||||
|
||||
import { PageContent } from "~/components/common/PageContent"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { useGetPage } from "~/queries/page"
|
||||
import { useGetSite } from "~/queries/site"
|
||||
|
||||
export default function SitePreviewPage({
|
||||
params,
|
||||
}: {
|
||||
params: {
|
||||
site: string
|
||||
previewId: string
|
||||
}
|
||||
}) {
|
||||
const site = useGetSite(params.site)
|
||||
|
||||
const page = useGetPage({
|
||||
characterId: site.data?.characterId,
|
||||
noteId:
|
||||
params.previewId && /\d+/.test(params.previewId)
|
||||
? +params.previewId
|
||||
: undefined,
|
||||
slug: params.previewId,
|
||||
useStat: true,
|
||||
})
|
||||
|
||||
const { t } = useTranslation("site")
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="fixed top-0 left-0 w-full text-center text-red-500 bg-gray-100 py-2 opacity-80 text-sm z-10">
|
||||
{t(
|
||||
"This address is in local editing preview mode and cannot be viewed by the public.",
|
||||
)}
|
||||
</div>
|
||||
<article>
|
||||
<div>
|
||||
{page.data?.metadata?.content?.tags?.includes("post") ? (
|
||||
<h2 className="xlog-post-title text-4xl font-bold">
|
||||
{page.data.metadata?.content?.title}
|
||||
</h2>
|
||||
) : (
|
||||
<h2 className="xlog-post-title text-xl font-bold page-title">
|
||||
{page.data?.metadata?.content?.title}
|
||||
</h2>
|
||||
)}
|
||||
</div>
|
||||
<PageContent
|
||||
className="mt-10"
|
||||
content={page.data?.metadata?.content?.content}
|
||||
toc={true}
|
||||
></PageContent>
|
||||
</article>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Metadata } from "next"
|
||||
|
||||
import { SearchInput } from "~/components/common/SearchInput"
|
||||
import { SiteSearch } from "~/components/site/SiteSearch"
|
||||
import getQueryClient from "~/lib/query-client"
|
||||
import { fetchGetSite } from "~/queries/site.server"
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
searchParams,
|
||||
}: {
|
||||
params: {
|
||||
site: string
|
||||
}
|
||||
searchParams: {
|
||||
[key: string]: string | string[] | undefined
|
||||
}
|
||||
}): Promise<Metadata> {
|
||||
const queryClient = getQueryClient()
|
||||
|
||||
const site = await fetchGetSite(params.site, queryClient)
|
||||
|
||||
const title = `Search: ${searchParams.q} - ${
|
||||
site?.metadata?.content?.name || site?.handle
|
||||
}`
|
||||
|
||||
return {
|
||||
title,
|
||||
}
|
||||
}
|
||||
|
||||
export default async function SiteSearchPage() {
|
||||
return (
|
||||
<>
|
||||
<div className="sm:-mx-5">
|
||||
<SearchInput />
|
||||
</div>
|
||||
<SiteSearch />
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { Metadata } from "next"
|
||||
|
||||
import { Hydrate, dehydrate } from "@tanstack/react-query"
|
||||
|
||||
import { SiteArchives } from "~/components/site/SiteArchives"
|
||||
import getQueryClient from "~/lib/query-client"
|
||||
import { PageVisibilityEnum } from "~/lib/types"
|
||||
import { prefetchGetPagesBySite } from "~/queries/page.server"
|
||||
import { fetchGetSite } from "~/queries/site.server"
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: {
|
||||
site: string
|
||||
tag: string
|
||||
}
|
||||
}): Promise<Metadata> {
|
||||
const queryClient = getQueryClient()
|
||||
|
||||
const site = await fetchGetSite(params.site, queryClient)
|
||||
|
||||
params.tag = decodeURIComponent(params.tag)
|
||||
const title = `Tag: ${params.tag} - ${
|
||||
site?.metadata?.content?.name || site?.handle
|
||||
}`
|
||||
|
||||
return {
|
||||
title,
|
||||
}
|
||||
}
|
||||
|
||||
export default async function SiteTagPage({
|
||||
params,
|
||||
}: {
|
||||
params: {
|
||||
site: string
|
||||
tag: string
|
||||
}
|
||||
}) {
|
||||
params.tag = decodeURIComponent(params.tag)
|
||||
const queryClient = getQueryClient()
|
||||
|
||||
const site = await fetchGetSite(params.site, queryClient)
|
||||
await prefetchGetPagesBySite(
|
||||
{
|
||||
characterId: site?.characterId,
|
||||
type: "post",
|
||||
visibility: PageVisibilityEnum.Published,
|
||||
limit: 100,
|
||||
tags: [params.tag],
|
||||
},
|
||||
queryClient,
|
||||
)
|
||||
|
||||
const dehydratedState = dehydrate(queryClient)
|
||||
|
||||
return (
|
||||
<Hydrate state={dehydratedState}>
|
||||
<SiteArchives />
|
||||
</Hydrate>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useState } from "react"
|
||||
|
||||
import { Indicator } from "@mantine/core"
|
||||
@@ -6,6 +5,7 @@ import { Indicator } from "@mantine/core"
|
||||
import { AchievementModal } from "~/components/common/AchievementModal"
|
||||
import { Image } from "~/components/ui/Image"
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import type { AchievementSection } from "~/models/site.model"
|
||||
|
||||
export const Badge = ({
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
import Tilt from "react-parallax-tilt"
|
||||
|
||||
import { Modal, Stepper } from "@mantine/core"
|
||||
@@ -8,6 +7,7 @@ import { BlockchainIcon } from "~/components/icons/BlockchainIcon"
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { Image } from "~/components/ui/Image"
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { cn } from "~/lib/utils"
|
||||
import type { AchievementSection } from "~/models/site.model"
|
||||
import { useMintAchievement } from "~/queries/site"
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
"use client"
|
||||
|
||||
import { Disclosure } from "@headlessui/react"
|
||||
|
||||
import { BlockchainIcon } from "~/components/icons/BlockchainIcon"
|
||||
import { CSB_SCAN } from "~/lib/env"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { toCid, toGateway, toIPFS } from "~/lib/ipfs-parser"
|
||||
import { ExpandedCharacter, ExpandedNote } from "~/lib/types"
|
||||
import { cn } from "~/lib/utils"
|
||||
@@ -13,7 +14,7 @@ export const BlockchainInfo: React.FC<{
|
||||
site?: ExpandedCharacter
|
||||
page?: ExpandedNote
|
||||
}> = ({ site, page }) => {
|
||||
const { t } = useTranslation(["common", "site"])
|
||||
const { t } = useTranslation("common")
|
||||
|
||||
const ipfs = (page ? page.metadata?.uri : site?.metadata?.uri) || ""
|
||||
const greenfieldId = useGetGreenfieldId(toCid(ipfs))
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
import { FollowingButton } from "~/components/common/FollowingButton"
|
||||
import { FollowingCount } from "~/components/common/FollowingCount"
|
||||
import { Titles } from "~/components/common/Titles"
|
||||
import { Avatar } from "~/components/ui/Avatar"
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
import type { ExpandedCharacter } from "~/lib/types"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { cn } from "~/lib/utils"
|
||||
import * as siteModel from "~/models/site.model"
|
||||
import { useGetCharacterCard } from "~/queries/site"
|
||||
|
||||
export const CharacterCard: React.FC<{
|
||||
siteId?: string
|
||||
@@ -27,25 +24,14 @@ export const CharacterCard: React.FC<{
|
||||
simple,
|
||||
style,
|
||||
}) => {
|
||||
const [firstOpen, setFirstOpen] = useState("")
|
||||
const [site, setSite] = useState<ExpandedCharacter>()
|
||||
const date = useDate()
|
||||
const { t } = useTranslation("common")
|
||||
|
||||
useEffect(() => {
|
||||
if (open && (firstOpen !== (siteId || address) || !site)) {
|
||||
if (siteId || address) {
|
||||
setFirstOpen(siteId || address || "")
|
||||
if (siteId) {
|
||||
siteModel.getSite(siteId).then((site) => setSite(site))
|
||||
} else if (address) {
|
||||
siteModel.getSiteByAddress(address).then((site) => setSite(site))
|
||||
}
|
||||
} else {
|
||||
setSite(undefined)
|
||||
}
|
||||
}
|
||||
}, [open, firstOpen, siteId, address, site])
|
||||
const { data: site } = useGetCharacterCard({
|
||||
siteId,
|
||||
address,
|
||||
enabled: open || false,
|
||||
})
|
||||
|
||||
return (
|
||||
<span
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
"use client"
|
||||
|
||||
import { useState } from "react"
|
||||
|
||||
import {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
import React, { useCallback, useState } from "react"
|
||||
import { Virtuoso } from "react-virtuoso"
|
||||
|
||||
import { Modal } from "~/components/ui/Modal"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { ExpandedCharacter } from "~/lib/types"
|
||||
|
||||
import { Button } from "../ui/Button"
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
"use client"
|
||||
|
||||
import { Virtuoso } from "react-virtuoso"
|
||||
|
||||
import { CommentInput } from "~/components/common/CommentInput"
|
||||
import { CommentItem } from "~/components/common/CommentItem"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { ExpandedNote } from "~/lib/types"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { useGetComments } from "~/queries/page"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { CharacterEntity, NoteEntity } from "crossbell.js"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useEffect } from "react"
|
||||
import { useForm } from "react-hook-form"
|
||||
|
||||
@@ -9,6 +8,7 @@ import { Popover } from "@headlessui/react"
|
||||
import { Avatar } from "~/components/ui/Avatar"
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { Input } from "~/components/ui/Input"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { useCommentPage, useUpdateComment } from "~/queries/page"
|
||||
|
||||
import { EmojiPicker } from "./EmojiPicker"
|
||||
@@ -33,7 +33,7 @@ export const CommentInput: React.FC<{
|
||||
const account = useAccountState((s) => s.computed.account)
|
||||
const commentPage = useCommentPage()
|
||||
const updateComment = useUpdateComment()
|
||||
const { t } = useTranslation(["common", "site"])
|
||||
const { t } = useTranslation("site")
|
||||
|
||||
const form = useForm({
|
||||
defaultValues: {
|
||||
@@ -94,9 +94,7 @@ export const CommentInput: React.FC<{
|
||||
multiline
|
||||
maxLength={600}
|
||||
className="mb-2"
|
||||
placeholder={
|
||||
t("Write a comment on the blockchain", { ns: "site" }) || ""
|
||||
}
|
||||
placeholder={t("Write a comment on the blockchain") || ""}
|
||||
{...form.register("content", {})}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import { CharacterEntity, NoteEntity } from "crossbell.js"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useState } from "react"
|
||||
|
||||
import { useAccountState } from "@crossbell/connect-kit"
|
||||
@@ -16,6 +17,7 @@ import { UniLink } from "~/components/ui/UniLink"
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
import { CSB_SCAN } from "~/lib/env"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
export const CommentItem: React.FC<{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
"use client"
|
||||
|
||||
import React, { useEffect, useState } from "react"
|
||||
|
||||
import {
|
||||
@@ -31,6 +32,7 @@ import { Button, type Variant, type VariantColor } from "~/components/ui/Button"
|
||||
import { Menu } from "~/components/ui/Menu"
|
||||
import { SITE_URL } from "~/lib/env"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
type HeaderLinkType = {
|
||||
@@ -227,7 +229,7 @@ export const ConnectButton: React.FC<{
|
||||
{isAllRead ? (
|
||||
<BellIcon
|
||||
className={`${
|
||||
size === "base" ? "w-6 h-6" : "w-5 h-5"
|
||||
size === "base" ? "w-7 h-7" : "w-6 h-6"
|
||||
} text-zinc-500 cursor-pointer sm:hover:animate-buzz-out`}
|
||||
onClick={showNotificationModal}
|
||||
/>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
"use client"
|
||||
|
||||
import { Switch } from "@headlessui/react"
|
||||
|
||||
import { useDarkModeSwitch, useIsDark } from "~/hooks/useDarkMode"
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
"use client"
|
||||
|
||||
import { useState } from "react"
|
||||
|
||||
import { useAccountState } from "@crossbell/connect-kit"
|
||||
import { useRefCallback } from "@crossbell/util-hooks"
|
||||
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { getSubscriptionsFromList } from "~/models/site.model"
|
||||
import { useSubscribeToSites } from "~/queries/site"
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Trans, useTranslation } from "next-i18next"
|
||||
import { useEffect } from "react"
|
||||
import { toast } from "react-hot-toast"
|
||||
|
||||
@@ -6,6 +5,7 @@ import { Button } from "~/components/ui/Button"
|
||||
import type { Variant } from "~/components/ui/Button"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { SITE_URL } from "~/lib/env"
|
||||
import { Trans, useTranslation } from "~/lib/i18n/client"
|
||||
import { ExpandedCharacter } from "~/lib/types"
|
||||
import { cn } from "~/lib/utils"
|
||||
import {
|
||||
@@ -23,7 +23,7 @@ export const FollowingButton: React.FC<{
|
||||
}> = ({ site, variant, className, size, loadingStatusChange }) => {
|
||||
const subscribeToSite = useSubscribeToSite()
|
||||
const unsubscribeFromSite = useUnsubscribeFromSite()
|
||||
const { t } = useTranslation("common")
|
||||
const { t, i18n } = useTranslation("common")
|
||||
|
||||
const handleClickSubscribe = () => {
|
||||
if (site?.characterId) {
|
||||
@@ -54,7 +54,7 @@ export const FollowingButton: React.FC<{
|
||||
subscribeToSite.reset()
|
||||
toast.success(
|
||||
<span>
|
||||
<Trans i18nKey="Successfully followed" ns="common">
|
||||
<Trans i18n={i18n} i18nKey="Successfully followed" ns="common">
|
||||
Hey there! You're all set to{" "}
|
||||
<UniLink className="underline" href={`${SITE_URL}/activities`}>
|
||||
keep up with your followed blogger's latest buzz here
|
||||
@@ -81,6 +81,12 @@ export const FollowingButton: React.FC<{
|
||||
loadingStatusChange,
|
||||
])
|
||||
|
||||
const isLoading = subscription.data
|
||||
? unsubscribeFromSite.isLoading || subscribeToSite.isLoading
|
||||
: unsubscribeFromSite.isLoading ||
|
||||
subscribeToSite.isLoading ||
|
||||
subscription.isLoading
|
||||
|
||||
return (
|
||||
<Button
|
||||
variant={subscription.data ? "text" : variant}
|
||||
@@ -93,13 +99,7 @@ export const FollowingButton: React.FC<{
|
||||
"opacity-60": subscription.data,
|
||||
},
|
||||
)}
|
||||
isLoading={
|
||||
subscription.data
|
||||
? unsubscribeFromSite.isLoading || subscribeToSite.isLoading
|
||||
: unsubscribeFromSite.isLoading ||
|
||||
subscribeToSite.isLoading ||
|
||||
subscription.isLoading
|
||||
}
|
||||
isLoading={isLoading}
|
||||
size={size}
|
||||
aria-label="follow"
|
||||
isAutoWidth
|
||||
@@ -117,7 +117,9 @@ export const FollowingButton: React.FC<{
|
||||
</>
|
||||
) : (
|
||||
<span className="inline-flex items-center">
|
||||
<span className="icon-[mingcute--user-add-fill] inline-block sm:mr-2"></span>{" "}
|
||||
{!isLoading && (
|
||||
<span className="icon-[mingcute--user-add-fill] inline-block sm:mr-2"></span>
|
||||
)}{" "}
|
||||
<span className="hidden sm:inline">{t("Follow")}</span>
|
||||
</span>
|
||||
)}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useState } from "react"
|
||||
|
||||
import { CharacterList } from "~/components/common/CharacterList"
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import {
|
||||
useGetSiteSubscriptions,
|
||||
useGetSiteToSubscriptions,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
"use client"
|
||||
|
||||
import Lottie, { type LottieRefCurrentProps } from "lottie-react"
|
||||
import React, { useRef } from "react"
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
"use client"
|
||||
|
||||
import { MutableRefObject, useEffect, useMemo } from "react"
|
||||
import { scroller } from "react-scroll"
|
||||
|
||||
import { PostToc } from "~/components/site/PostToc"
|
||||
import { useCodeCopy } from "~/hooks/useCodeCopy"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { calculateElementTop, cn } from "~/lib/utils"
|
||||
import { renderPageContent } from "~/markdown"
|
||||
|
||||
export const PageContent: React.FC<{
|
||||
@@ -42,10 +43,18 @@ export const PageContent: React.FC<{
|
||||
const hashChangeHandler = () => {
|
||||
const hash = decodeURIComponent(location.hash.slice(1))
|
||||
if (hash) {
|
||||
scroller.scrollTo(`user-content-${decodeURIComponent(hash)}`, {
|
||||
smooth: true,
|
||||
offset: -20,
|
||||
duration: 500,
|
||||
if (history.state?.preventScrollToToc) {
|
||||
history.state.preventScrollToToc = false
|
||||
return
|
||||
}
|
||||
const targetElement = document.querySelector(
|
||||
`#user-content-${decodeURIComponent(hash)}`,
|
||||
) as HTMLElement
|
||||
if (!targetElement) return
|
||||
|
||||
window.scrollTo({
|
||||
top: calculateElementTop(targetElement) - 20,
|
||||
behavior: "smooth",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useState } from "react"
|
||||
|
||||
import { PatronModal } from "~/components/common/PatronModal"
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { ExpandedCharacter } from "~/lib/types"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import confetti from "canvas-confetti"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useEffect, useRef, useState } from "react"
|
||||
import { toast } from "react-hot-toast"
|
||||
|
||||
@@ -11,6 +10,7 @@ import { Button } from "~/components/ui/Button"
|
||||
import { Modal } from "~/components/ui/Modal"
|
||||
import { CSB_SCAN, MIRA_LINK } from "~/lib/env"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { ExpandedCharacter, ExpandedNote } from "~/lib/types"
|
||||
import { useGetTips, useTipCharacter } from "~/queries/site"
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import confetti from "canvas-confetti"
|
||||
import { Trans, useTranslation } from "next-i18next"
|
||||
import { useEffect, useMemo, useRef, useState } from "react"
|
||||
|
||||
import { CharacterList } from "~/components/common/CharacterList"
|
||||
@@ -7,6 +8,7 @@ import { Modal } from "~/components/ui/Modal"
|
||||
import { Tooltip } from "~/components/ui/Tooltip"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { CSB_SCAN } from "~/lib/env"
|
||||
import { Trans, useTranslation } from "~/lib/i18n/client"
|
||||
import { cn } from "~/lib/utils"
|
||||
import {
|
||||
useCheckLike,
|
||||
@@ -24,7 +26,7 @@ export const ReactionLike: React.FC<{
|
||||
noteId?: number
|
||||
}> = ({ size, characterId, noteId }) => {
|
||||
const toggleLikePage = useToggleLikePage()
|
||||
const { t } = useTranslation("common")
|
||||
const { t, i18n } = useTranslation("common")
|
||||
|
||||
const [isLikeOpen, setIsLikeOpen] = useState(false)
|
||||
const [isLikeListOpen, setIsLikeListOpen] = useState(false)
|
||||
@@ -149,7 +151,7 @@ export const ReactionLike: React.FC<{
|
||||
title={t("Like successfully") || ""}
|
||||
>
|
||||
<div className="p-5">
|
||||
<Trans i18nKey="like stored">
|
||||
<Trans i18nKey="like stored" i18n={i18n}>
|
||||
Your like has been stored on the blockchain, view it on{" "}
|
||||
<UniLink
|
||||
className="text-accent"
|
||||
@@ -181,7 +183,7 @@ export const ReactionLike: React.FC<{
|
||||
title={t("Confirm to revert")}
|
||||
>
|
||||
<div className="p-5">
|
||||
<Trans i18nKey="like revert">
|
||||
<Trans i18nKey="like revert" i18n={i18n}>
|
||||
Do you really want to revert this like action?
|
||||
</Trans>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import confetti from "canvas-confetti"
|
||||
import { Trans, useTranslation } from "next-i18next"
|
||||
import { useEffect, useMemo, useRef, useState } from "react"
|
||||
|
||||
import { useAccountState } from "@crossbell/connect-kit"
|
||||
@@ -10,6 +11,7 @@ import { Modal } from "~/components/ui/Modal"
|
||||
import { Tooltip } from "~/components/ui/Tooltip"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { CSB_SCAN, CSB_XCHAR } from "~/lib/env"
|
||||
import { Trans, useTranslation } from "~/lib/i18n/client"
|
||||
import { noopArr } from "~/lib/noop"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { useCheckMint, useGetMints, useMintPage } from "~/queries/page"
|
||||
@@ -23,7 +25,7 @@ export const ReactionMint: React.FC<{
|
||||
characterId?: number
|
||||
}> = ({ size, noteId, characterId }) => {
|
||||
const mintPage = useMintPage()
|
||||
const { t } = useTranslation("common")
|
||||
const { t, i18n } = useTranslation("common")
|
||||
|
||||
const account = useAccountState((s) => s.computed.account)
|
||||
|
||||
@@ -136,7 +138,7 @@ export const ReactionMint: React.FC<{
|
||||
title={t("Mint successfully") || ""}
|
||||
>
|
||||
<div className="p-5">
|
||||
<Trans i18nKey="mint stored">
|
||||
<Trans i18nKey="mint stored" i18n={i18n}>
|
||||
This post has been minted to NFT by you, view it on{" "}
|
||||
<UniLink
|
||||
className="text-accent"
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
"use client"
|
||||
|
||||
import { useMemo, useRef, useState } from "react"
|
||||
|
||||
import { useAccountState } from "@crossbell/connect-kit"
|
||||
|
||||
import { PatronModal } from "~/components/common/PatronModal"
|
||||
import { Tooltip } from "~/components/ui/Tooltip"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { noopArr } from "~/lib/noop"
|
||||
import { ExpandedCharacter, ExpandedNote } from "~/lib/types"
|
||||
import { useGetTips } from "~/queries/site"
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
import Head from "next/head"
|
||||
|
||||
import { SITE_URL } from "~/lib/env"
|
||||
|
||||
export const SEOHead: React.FC<{
|
||||
siteName: string
|
||||
title: string | undefined
|
||||
description?: string | null
|
||||
image?: string | null
|
||||
icon?: string | null
|
||||
site?: string
|
||||
}> = ({ siteName, title, description, image, icon, site }) => {
|
||||
return (
|
||||
<Head>
|
||||
<title>{title ? `${title} - ${siteName}` : `${siteName}`}</title>
|
||||
<meta name="og:site_name" content={siteName} />
|
||||
<meta name="og:title" content={title} />
|
||||
<meta name="twitter:title" content={title} />
|
||||
<meta name="description" content={description || ""} />
|
||||
<meta name="og:description" content={description || ""} />
|
||||
<meta name="twitter:description" content={description || ""} />
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
{image && (
|
||||
<>
|
||||
<meta name="og:image" content={new URL(image, SITE_URL).toString()} />
|
||||
<meta
|
||||
name="twitter:image"
|
||||
content={new URL(image, SITE_URL).toString()}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<link rel="icon" href={icon || `${SITE_URL}/assets/logo.svg`}></link>
|
||||
{site ? (
|
||||
<>
|
||||
<link
|
||||
rel="alternate"
|
||||
href="/feed"
|
||||
title={siteName}
|
||||
type="application/feed+json"
|
||||
></link>
|
||||
<link
|
||||
rel="alternate"
|
||||
href="/feed?format=xml"
|
||||
title={siteName}
|
||||
type="application/rss+xml"
|
||||
></link>
|
||||
<link
|
||||
rel="alternate"
|
||||
href="/feed/comments"
|
||||
title={`Comments on ${siteName}`}
|
||||
type="application/feed+json"
|
||||
></link>
|
||||
<link
|
||||
rel="alternate"
|
||||
href="/feed/comments?format=xml"
|
||||
title={`Comments on ${siteName}`}
|
||||
type="application/rss+xml"
|
||||
></link>
|
||||
<link rel="manifest" href="/manifest.json" />
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<link
|
||||
rel="alternate"
|
||||
href="/feed/latest"
|
||||
title="xLog Latest"
|
||||
type="application/feed+json"
|
||||
></link>
|
||||
<link
|
||||
rel="alternate"
|
||||
href="/feed/latest?format=xml"
|
||||
title="xLog Latest"
|
||||
type="application/rss+xml"
|
||||
></link>
|
||||
<link
|
||||
rel="alternate"
|
||||
href="/feed/hottest/0"
|
||||
title="xLog Hot"
|
||||
type="application/feed+json"
|
||||
></link>
|
||||
<link
|
||||
rel="alternate"
|
||||
href="/feed/hottest/0?format=xml"
|
||||
title="xLog Hot"
|
||||
type="application/rss+xml"
|
||||
></link>
|
||||
<link
|
||||
rel="alternate"
|
||||
href="/feed/hottest/1"
|
||||
title="xLog Daily Hot"
|
||||
type="application/feed+json"
|
||||
></link>
|
||||
<link
|
||||
rel="alternate"
|
||||
href="/feed/hottest/1?format=xml"
|
||||
title="xLog Daily Hot"
|
||||
type="application/rss+xml"
|
||||
></link>
|
||||
<link
|
||||
rel="alternate"
|
||||
href="/feed/hottest/7"
|
||||
title="xLog Weekly Hot"
|
||||
type="application/feed+json"
|
||||
></link>
|
||||
<link
|
||||
rel="alternate"
|
||||
href="/feed/hottest/7?format=xml"
|
||||
title="xLog Weekly Hot"
|
||||
type="application/rss+xml"
|
||||
></link>
|
||||
<link
|
||||
rel="alternate"
|
||||
href="/feed/hottest/30"
|
||||
title="xLog Monthly Hot"
|
||||
type="application/feed+json"
|
||||
></link>
|
||||
<link
|
||||
rel="alternate"
|
||||
href="/feed/hottest/30?format=xml"
|
||||
title="xLog Monthly Hot"
|
||||
type="application/rss+xml"
|
||||
></link>
|
||||
</>
|
||||
)}
|
||||
</Head>
|
||||
)
|
||||
}
|
||||
@@ -1,20 +1,22 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
"use client"
|
||||
|
||||
import { useRouter, useSearchParams } from "next/navigation"
|
||||
import { useForm } from "react-hook-form"
|
||||
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
export const SearchInput: React.FC<{
|
||||
value?: string
|
||||
noBorder?: boolean
|
||||
onSubmit?: (value?: string) => void
|
||||
}> = ({ value, noBorder, onSubmit }) => {
|
||||
}> = ({ noBorder, onSubmit }) => {
|
||||
const router = useRouter()
|
||||
const { t } = useTranslation(["common", "site"])
|
||||
const searchParams = useSearchParams()
|
||||
const { t } = useTranslation("common")
|
||||
|
||||
const form = useForm({
|
||||
defaultValues: {
|
||||
content: value || "",
|
||||
content: searchParams?.get("q") || "",
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
"use client"
|
||||
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
|
||||
export const Time: React.FC<{
|
||||
isoString?: string
|
||||
}> = ({ isoString }) => {
|
||||
const date = useDate()
|
||||
const [isMounted, setIsMounted] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
setIsMounted(true)
|
||||
}, [])
|
||||
|
||||
if (!isoString) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<time
|
||||
dateTime={date.formatToISO(isoString || "")}
|
||||
className="xlog-post-date whitespace-nowrap"
|
||||
>
|
||||
{date.formatDate(
|
||||
isoString || "",
|
||||
undefined,
|
||||
isMounted ? undefined : "America/Los_Angeles",
|
||||
)}
|
||||
</time>
|
||||
)
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import { serverSideTranslations } from "next-i18next/serverSideTranslations"
|
||||
|
||||
import { languageDetector } from "~/lib/language-detector"
|
||||
|
||||
export const getServerSideProps = async (ctx: any) => {
|
||||
return {
|
||||
props: {
|
||||
...(await serverSideTranslations(languageDetector(ctx), [
|
||||
"common",
|
||||
"dashboard",
|
||||
"index",
|
||||
"site",
|
||||
])),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
|
||||
import { useIsMobileLayout } from "~/hooks/useMobileLayout"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
export const DashboardMain: React.FC<{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { NoteMetadata } from "crossbell.js"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useState } from "react"
|
||||
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
|
||||
import { PageContent } from "../common/PageContent"
|
||||
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
import { nanoid } from "nanoid"
|
||||
import { Trans, useTranslation } from "next-i18next"
|
||||
import Link from "next/link"
|
||||
import { useRouter } from "next/router"
|
||||
import {
|
||||
useParams,
|
||||
usePathname,
|
||||
useRouter,
|
||||
useSearchParams,
|
||||
} from "next/navigation"
|
||||
import { Fragment, useMemo, useState } from "react"
|
||||
|
||||
import { Menu } from "@headlessui/react"
|
||||
import { useQueryClient } from "@tanstack/react-query"
|
||||
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
import { Trans, useTranslation } from "~/lib/i18n/client"
|
||||
import { getPageVisibility } from "~/lib/page-helpers"
|
||||
import { readFiles } from "~/lib/read-files"
|
||||
import { setStorage } from "~/lib/storage"
|
||||
@@ -28,19 +33,23 @@ import { PagesManagerMenu } from "./PagesManagerMenu"
|
||||
export const PagesManager: React.FC<{
|
||||
isPost: boolean
|
||||
}> = ({ isPost }) => {
|
||||
const router = useRouter()
|
||||
const subdomain = router.query.subdomain as string
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
const site = useGetSite(subdomain)
|
||||
const searchParams = useSearchParams()
|
||||
const router = useRouter()
|
||||
const pathname = usePathname()
|
||||
|
||||
const visibility = useMemo<PageVisibilityEnum>(
|
||||
() =>
|
||||
router.query.visibility
|
||||
? (router.query.visibility as PageVisibilityEnum)
|
||||
searchParams?.get("visibility")
|
||||
? (searchParams?.get("visibility") as PageVisibilityEnum)
|
||||
: PageVisibilityEnum.All,
|
||||
[router.query.visibility],
|
||||
[searchParams],
|
||||
)
|
||||
|
||||
const { t } = useTranslation(["dashboard", "site"])
|
||||
const { t, i18n } = useTranslation("dashboard")
|
||||
const { t: siteT } = useTranslation("site")
|
||||
const date = useDate()
|
||||
|
||||
const pages = useGetPagesBySite({
|
||||
@@ -75,16 +84,14 @@ export const PagesManager: React.FC<{
|
||||
text: item.text,
|
||||
onClick: () => {
|
||||
const newQuery: Record<string, any> = {
|
||||
...router.query,
|
||||
...searchParams,
|
||||
visibility: item.value,
|
||||
}
|
||||
if (item.value === PageVisibilityEnum.All) {
|
||||
delete newQuery["visibility"]
|
||||
}
|
||||
const search = new URLSearchParams(newQuery).toString()
|
||||
router.push({
|
||||
search,
|
||||
})
|
||||
router.push(pathname + "?" + search)
|
||||
},
|
||||
active: item.value === visibility,
|
||||
}))
|
||||
@@ -136,7 +143,7 @@ export const PagesManager: React.FC<{
|
||||
const description = isPost ? (
|
||||
<>
|
||||
<p>
|
||||
<Trans i18nKey="posts description" ns="dashboard">
|
||||
<Trans i18n={i18n} i18nKey="posts description" ns="dashboard">
|
||||
Posts are entries listed in reverse chronological order on your site.
|
||||
Think of them as articles or updates that you share to offer up new
|
||||
content to your readers.{" "}
|
||||
@@ -149,7 +156,7 @@ export const PagesManager: React.FC<{
|
||||
) : (
|
||||
<>
|
||||
<p>
|
||||
<Trans i18nKey="pages description" ns="dashboard">
|
||||
<Trans i18n={i18n} i18nKey="pages description" ns="dashboard">
|
||||
Pages are static and are not affected by date. Think of them as more
|
||||
permanent fixtures of your site — an About page, and a Contact page
|
||||
are great examples of this.{" "}
|
||||
@@ -162,7 +169,7 @@ export const PagesManager: React.FC<{
|
||||
</Trans>
|
||||
</p>
|
||||
<p>
|
||||
<Trans i18nKey="pages add" ns="dashboard">
|
||||
<Trans i18n={i18n} i18nKey="pages add" ns="dashboard">
|
||||
After you create a page, you can{" "}
|
||||
<UniLink
|
||||
className="underline"
|
||||
@@ -228,7 +235,8 @@ export const PagesManager: React.FC<{
|
||||
)}
|
||||
|
||||
<div className="-mt-3">
|
||||
{!pages.data?.pages?.[0].count && (
|
||||
{pages.isLoading && <p className="py-3 px-3">{t("Loading")}...</p>}
|
||||
{!pages.isLoading && !pages.data?.pages?.[0].count && (
|
||||
<EmptyState resource={isPost ? "posts" : "pages"} />
|
||||
)}
|
||||
|
||||
@@ -349,7 +357,7 @@ export const PagesManager: React.FC<{
|
||||
onClick={pages.fetchNextPage as () => void}
|
||||
isLoading={pages.isFetchingNextPage}
|
||||
>
|
||||
{t("load more", {
|
||||
{siteT("load more", {
|
||||
name: t(
|
||||
isPost
|
||||
? "post"
|
||||
@@ -359,7 +367,6 @@ export const PagesManager: React.FC<{
|
||||
: ""),
|
||||
),
|
||||
count: (pages.data?.pages?.[0].count || 0) - currentLength,
|
||||
ns: "site",
|
||||
})}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
import { useParams } from "next/navigation"
|
||||
import React, { useState } from "react"
|
||||
import toast from "react-hot-toast"
|
||||
|
||||
@@ -8,6 +7,7 @@ import { useQueryClient } from "@tanstack/react-query"
|
||||
|
||||
import { type TabItem, Tabs } from "~/components/ui/Tabs"
|
||||
import { APP_NAME } from "~/lib/env"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { delStorage, getStorage, setStorage } from "~/lib/storage"
|
||||
import { ExpandedNote } from "~/lib/types"
|
||||
import { useCreateOrUpdatePage, useDeletePage } from "~/queries/page"
|
||||
@@ -23,10 +23,10 @@ export const PagesManagerBatchSelectActionTab: React.FC<{
|
||||
batchSelected: (string | number)[]
|
||||
setBatchSelected: (selected: string[]) => void
|
||||
}> = ({ isPost, isNotxLogContent, pages, batchSelected, setBatchSelected }) => {
|
||||
const { t } = useTranslation(["dashboard", "site"])
|
||||
const { t } = useTranslation("dashboard")
|
||||
|
||||
const router = useRouter()
|
||||
const subdomain = router.query.subdomain as string
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
import { useParams, useRouter } from "next/navigation"
|
||||
import { FC, useEffect, useState } from "react"
|
||||
import toast from "react-hot-toast"
|
||||
|
||||
@@ -9,6 +8,7 @@ import { useQueryClient } from "@tanstack/react-query"
|
||||
import { useGetState } from "~/hooks/useGetState"
|
||||
import { APP_NAME } from "~/lib/env"
|
||||
import { getNoteSlugFromNote, getTwitterShareUrl } from "~/lib/helpers"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { delStorage, getStorage, setStorage } from "~/lib/storage"
|
||||
import { ExpandedNote } from "~/lib/types"
|
||||
import { useCreateOrUpdatePage, useDeletePage } from "~/queries/page"
|
||||
@@ -17,8 +17,8 @@ import { useGetSite } from "~/queries/site"
|
||||
import { DeleteConfirmationModal } from "./DeleteConfirmationModal"
|
||||
|
||||
const usePageEditLink = (page: ExpandedNote, isPost: boolean) => {
|
||||
const router = useRouter()
|
||||
const subdomain = router.query.subdomain as string
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
|
||||
return `/dashboard/${subdomain}/editor?id=${page.noteId}&type=${
|
||||
isPost ? "post" : "page"
|
||||
@@ -35,14 +35,15 @@ export const PagesManagerMenu: FC<{
|
||||
page: ExpandedNote
|
||||
onClick: () => void
|
||||
}> = ({ isPost, page, onClick: onClose }) => {
|
||||
const { t } = useTranslation(["dashboard", "site"])
|
||||
const { t } = useTranslation("dashboard")
|
||||
|
||||
const isCrossbell = !page.metadata?.content?.sources?.includes("xlog")
|
||||
const router = useRouter()
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
const createOrUpdatePage = useCreateOrUpdatePage()
|
||||
|
||||
const editLink = usePageEditLink(page, isPost)
|
||||
const subdomain = router.query.subdomain as string
|
||||
const queryClient = useQueryClient()
|
||||
const deletePage = useDeletePage()
|
||||
|
||||
@@ -157,7 +158,7 @@ export const PagesManagerMenu: FC<{
|
||||
onClick() {
|
||||
const slug = getNoteSlugFromNote(page)
|
||||
if (!slug) return
|
||||
window.open(`/_site/${subdomain}/${slug}`)
|
||||
window.open(`/site/${subdomain}/${slug}`)
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useEffect, useRef, useState } from "react"
|
||||
import useOnClickOutside from "use-onclickoutside"
|
||||
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
|
||||
import { Button, ButtonGroup } from "../ui/Button"
|
||||
import { DeleteConfirmationModal } from "./DeleteConfirmationModal"
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
import { useParams, usePathname } from "next/navigation"
|
||||
import React from "react"
|
||||
|
||||
import { useXSettingsModal } from "@crossbell/connect-kit"
|
||||
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
|
||||
import { type TabItem, Tabs } from "../ui/Tabs"
|
||||
import { DashboardMain } from "./DashboardMain"
|
||||
|
||||
@@ -11,11 +12,12 @@ export const SettingsLayout: React.FC<{
|
||||
title: string
|
||||
children: React.ReactNode
|
||||
}> = ({ title, children }) => {
|
||||
const router = useRouter()
|
||||
const { t } = useTranslation("dashboard")
|
||||
const xSettingsModal = useXSettingsModal()
|
||||
|
||||
const subdomain = router.query.subdomain as string
|
||||
const pathname = usePathname()
|
||||
const params = useParams()
|
||||
const subdomain = params?.subdomain as string
|
||||
const tabItems: TabItem[] = [
|
||||
{ text: "General", href: `/dashboard/${subdomain}/settings/general` },
|
||||
{
|
||||
@@ -40,7 +42,7 @@ export const SettingsLayout: React.FC<{
|
||||
text: "Export data",
|
||||
href: `https://export.crossbell.io/?handle=${subdomain}`,
|
||||
},
|
||||
].map((item) => ({ ...item, active: router.asPath === item.href }))
|
||||
].map((item) => ({ ...item, active: pathname === item.href }))
|
||||
|
||||
return (
|
||||
<DashboardMain>
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
"use client"
|
||||
|
||||
import { useRouter } from "next/navigation"
|
||||
import React from "react"
|
||||
|
||||
import { useAccountState } from "@crossbell/connect-kit"
|
||||
|
||||
import { Button } from "~/components/ui/Button"
|
||||
|
||||
interface Props {
|
||||
connectedContent: React.ReactNode
|
||||
unconnectedContent: React.ReactNode
|
||||
}
|
||||
|
||||
export default function EntranceButton(props: Props) {
|
||||
const router = useRouter()
|
||||
const isConnected = useAccountState((s) => !!s.computed.account)
|
||||
|
||||
return (
|
||||
<Button
|
||||
className="text-accent h-10 mt-4 flex items-center"
|
||||
onClick={() => router.push("/dashboard")}
|
||||
size="2xl"
|
||||
variantColor="black"
|
||||
>
|
||||
{isConnected ? props.connectedContent : props.unconnectedContent}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
@@ -1,19 +1,22 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
"use client"
|
||||
|
||||
import Link from "next/link"
|
||||
import { useRouter } from "next/router"
|
||||
import { useRouter, useSearchParams } from "next/navigation"
|
||||
import { memo, useEffect, useState } from "react"
|
||||
import reactStringReplace from "react-string-replace"
|
||||
import { Virtuoso } from "react-virtuoso"
|
||||
|
||||
import { useAccountState } from "@crossbell/connect-kit"
|
||||
import { useAccountState, useConnectModal } from "@crossbell/connect-kit"
|
||||
import { Switch } from "@headlessui/react"
|
||||
|
||||
import { CharacterFloatCard } from "~/components/common/CharacterFloatCard"
|
||||
import { Titles } from "~/components/common/Titles"
|
||||
import PostCover from "~/components/site/PostCover"
|
||||
import { Image } from "~/components/ui/Image"
|
||||
import { Tabs } from "~/components/ui/Tabs"
|
||||
import { Tooltip } from "~/components/ui/Tooltip"
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { getStorage, setStorage } from "~/lib/storage"
|
||||
import { ExpandedNote } from "~/lib/types"
|
||||
import type { FeedType, SearchType } from "~/models/home.model"
|
||||
@@ -31,7 +34,7 @@ const Post = ({
|
||||
keyword?: string
|
||||
}) => {
|
||||
const router = useRouter()
|
||||
const { t } = useTranslation(["common", "site"])
|
||||
const { t } = useTranslation("common")
|
||||
const date = useDate()
|
||||
|
||||
if (
|
||||
@@ -39,7 +42,7 @@ const Post = ({
|
||||
post.metadata?.content?.score?.number !== undefined &&
|
||||
post.metadata.content.score.number <= filtering
|
||||
) {
|
||||
return <div></div>
|
||||
return <div className="h-[1px]"></div>
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -50,6 +53,7 @@ const Post = ({
|
||||
target="_blank"
|
||||
href={`/api/redirection?characterId=${post.characterId}`}
|
||||
className="flex items-center space-x-4 cursor-pointer"
|
||||
prefetch={false}
|
||||
>
|
||||
<span className="w-10 h-10 inline-block">
|
||||
<Image
|
||||
@@ -89,6 +93,7 @@ const Post = ({
|
||||
target="_blank"
|
||||
href={`/api/redirection?characterId=${post.characterId}¬eId=${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"
|
||||
prefetch={false}
|
||||
>
|
||||
<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">
|
||||
@@ -142,16 +147,7 @@ const Post = ({
|
||||
{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>
|
||||
)}
|
||||
<PostCover cover={post.metadata?.content.cover} />
|
||||
</Link>
|
||||
</div>
|
||||
)
|
||||
@@ -159,12 +155,15 @@ const Post = ({
|
||||
|
||||
const MemoedPost = memo(Post)
|
||||
|
||||
export const MainFeed: React.FC<{
|
||||
type?: FeedType
|
||||
export const HomeFeed: React.FC<{
|
||||
noteIds?: string[]
|
||||
keyword?: string
|
||||
}> = ({ type, noteIds, keyword }) => {
|
||||
const { t } = useTranslation(["common", "site"])
|
||||
type?: FeedType
|
||||
}> = ({ noteIds, keyword, type }) => {
|
||||
const { t } = useTranslation("common")
|
||||
const searchParams = useSearchParams()
|
||||
|
||||
const [feedType, setFeedType] = useState<FeedType>(type || "latest")
|
||||
|
||||
const currentCharacterId = useAccountState(
|
||||
(s) => s.computed.account?.characterId,
|
||||
@@ -174,15 +173,15 @@ export const MainFeed: React.FC<{
|
||||
const [searchType, setSearchType] = useState<SearchType>("latest")
|
||||
|
||||
const feed = useGetFeed({
|
||||
type: type,
|
||||
type: feedType,
|
||||
characterId: currentCharacterId,
|
||||
noteIds: noteIds,
|
||||
daysInterval: hotInterval,
|
||||
searchKeyword: keyword,
|
||||
searchKeyword: searchParams?.get("q") || undefined,
|
||||
searchType,
|
||||
})
|
||||
|
||||
const hasFiltering = type === "latest"
|
||||
const hasFiltering = feedType === "latest"
|
||||
|
||||
const [aiFiltering, setAiFiltering] = useState(true)
|
||||
|
||||
@@ -226,8 +225,35 @@ export const MainFeed: React.FC<{
|
||||
},
|
||||
]
|
||||
|
||||
const connectModal = useConnectModal()
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
text: "Latest",
|
||||
onClick: () => setFeedType("latest"),
|
||||
active: feedType === "latest",
|
||||
},
|
||||
{
|
||||
text: "Hottest",
|
||||
onClick: () => setFeedType("hot"),
|
||||
active: feedType === "hot",
|
||||
},
|
||||
{
|
||||
text: "Following",
|
||||
onClick: () => {
|
||||
if (!currentCharacterId) {
|
||||
connectModal.show()
|
||||
} else {
|
||||
setFeedType("following")
|
||||
}
|
||||
},
|
||||
active: feedType === "following",
|
||||
},
|
||||
]
|
||||
|
||||
return (
|
||||
<>
|
||||
{!type && <Tabs items={tabs} className="border-none text-lg"></Tabs>}
|
||||
<div className="space-y-10">
|
||||
{hasFiltering && (
|
||||
<div className="flex items-center text-zinc-500">
|
||||
@@ -263,10 +289,10 @@ export const MainFeed: React.FC<{
|
||||
</Switch>
|
||||
</div>
|
||||
)}
|
||||
{type === "hot" && (
|
||||
{feedType === "hot" && (
|
||||
<Tabs items={hotTabs} className="border-none text-sm -my-4"></Tabs>
|
||||
)}
|
||||
{type === "search" && (
|
||||
{feedType === "search" && (
|
||||
<Tabs items={searchTabs} className="border-none text-sm -my-4"></Tabs>
|
||||
)}
|
||||
|
||||
@@ -281,18 +307,19 @@ export const MainFeed: React.FC<{
|
||||
endReached={() => feed.hasNextPage && feed.fetchNextPage()}
|
||||
useWindowScroll
|
||||
data={feed.data?.pages}
|
||||
itemContent={(_, posts) =>
|
||||
posts?.list.map((post) => {
|
||||
itemContent={(_, posts) => {
|
||||
if (!posts?.list.length) return <div className="h-[1px]"></div>
|
||||
return posts?.list.map((post) => {
|
||||
return (
|
||||
<MemoedPost
|
||||
key={`${post.characterId}-${post.noteId}`}
|
||||
post={post}
|
||||
filtering={aiFiltering ? 60 : 0}
|
||||
keyword={keyword}
|
||||
keyword={searchParams?.get("q") || undefined}
|
||||
/>
|
||||
)
|
||||
})
|
||||
}
|
||||
}}
|
||||
></Virtuoso>
|
||||
|
||||
{feed.isFetching && feed.hasNextPage && <Loader />}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
"use client"
|
||||
|
||||
import { useState } from "react"
|
||||
|
||||
import { CharacterFloatCard } from "~/components/common/CharacterFloatCard"
|
||||
@@ -6,12 +7,13 @@ import { SearchInput } from "~/components/common/SearchInput"
|
||||
import { Image } from "~/components/ui/Image"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { useGetShowcase } from "~/queries/home"
|
||||
|
||||
import topics from "../../../data/topics.json"
|
||||
import { FollowAllButton } from "../common/FollowAllButton"
|
||||
|
||||
export function MainSidebar({ hideSearch }: { hideSearch?: boolean }) {
|
||||
export function HomeSidebar({ hideSearch }: { hideSearch?: boolean }) {
|
||||
const showcaseSites = useGetShowcase()
|
||||
const { t } = useTranslation("index")
|
||||
|
||||
@@ -52,6 +54,7 @@ export function MainSidebar({ hideSearch }: { hideSearch?: boolean }) {
|
||||
(s: { handle: string }) => s.handle,
|
||||
)}
|
||||
/>
|
||||
{showcaseSites.isLoading && <p>{t("Loading")}...</p>}
|
||||
<ul
|
||||
className={`overflow-y-clip relative text-left space-y-4 ${
|
||||
showcaseMore ? "" : "max-h-[540px]"
|
||||
@@ -0,0 +1,55 @@
|
||||
"use client"
|
||||
|
||||
import { usePathname } from "next/navigation"
|
||||
|
||||
import { Image } from "~/components/ui/Image"
|
||||
import { GITHUB_LINK } from "~/lib/env"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { UniLink } from "../ui/UniLink"
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
name: "Home",
|
||||
link: "/",
|
||||
},
|
||||
{
|
||||
name: "Activities",
|
||||
link: "/activities",
|
||||
},
|
||||
{
|
||||
name: (
|
||||
<Image
|
||||
className="no-optimization w-24"
|
||||
alt="github stars"
|
||||
src="https://img.shields.io/github/stars/Crossbell-Box/xLog?color=white&label=Stars&logo=github&style=social"
|
||||
/>
|
||||
),
|
||||
link: GITHUB_LINK,
|
||||
},
|
||||
]
|
||||
|
||||
export default function HomeTabs() {
|
||||
const pathname = usePathname()
|
||||
const { t } = useTranslation("index")
|
||||
|
||||
return (
|
||||
<>
|
||||
{tabs?.map((tab, index) => (
|
||||
<UniLink
|
||||
className={cn(
|
||||
"cursor-pointer items-center hidden sm:flex hover:text-accent text-lg",
|
||||
{
|
||||
"text-accent": pathname === tab.link,
|
||||
},
|
||||
)}
|
||||
key={tab.link}
|
||||
href={tab.link}
|
||||
>
|
||||
{typeof tab.name === "string" ? t(tab.name) : tab.name}
|
||||
</UniLink>
|
||||
))}
|
||||
</>
|
||||
)
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user