fix: dashboard local pages missing
This commit is contained in:
@@ -247,6 +247,9 @@ export async function getPagesBySite(
|
||||
pages.total++
|
||||
}
|
||||
})
|
||||
pages.list = pages.list.sort(
|
||||
(a, b) => +new Date(b.date_published) - +new Date(a.date_published),
|
||||
)
|
||||
}
|
||||
|
||||
if (pages?.list) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { SiteArchives } from "~/components/site/SiteArchives"
|
||||
import { Profile, Notes } from "~/lib/types"
|
||||
import { dehydrate, QueryClient } from "@tanstack/react-query"
|
||||
import { useGetPagesBySite } from "~/queries/page"
|
||||
import { useGetPagesBySiteLite } from "~/queries/page"
|
||||
import { PageVisibilityEnum } from "~/lib/types"
|
||||
import type { ReactElement } from "react"
|
||||
|
||||
@@ -33,7 +33,7 @@ function SiteArchivesPage({
|
||||
posts: Notes
|
||||
domainOrSubdomain: string
|
||||
}) {
|
||||
const posts = useGetPagesBySite({
|
||||
const posts = useGetPagesBySiteLite({
|
||||
site: domainOrSubdomain,
|
||||
take: 100,
|
||||
type: "post",
|
||||
|
||||
@@ -3,7 +3,7 @@ import { SiteHome } from "~/components/site/SiteHome"
|
||||
import { SiteLayout } from "~/components/site/SiteLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/site/SiteLayout.server"
|
||||
import { dehydrate, QueryClient } from "@tanstack/react-query"
|
||||
import { useGetPagesBySite } from "~/queries/page"
|
||||
import { useGetPagesBySiteLite } from "~/queries/page"
|
||||
import { PageVisibilityEnum } from "~/lib/types"
|
||||
import type { ReactElement } from "react"
|
||||
|
||||
@@ -21,7 +21,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||
}
|
||||
|
||||
function SiteIndexPage({ domainOrSubdomain }: { domainOrSubdomain: string }) {
|
||||
const posts = useGetPagesBySite({
|
||||
const posts = useGetPagesBySiteLite({
|
||||
site: domainOrSubdomain,
|
||||
type: "post",
|
||||
visibility: PageVisibilityEnum.Published,
|
||||
|
||||
@@ -5,7 +5,7 @@ import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { SiteArchives } from "~/components/site/SiteArchives"
|
||||
import { Profile, Notes } from "~/lib/types"
|
||||
import { dehydrate, QueryClient } from "@tanstack/react-query"
|
||||
import { useGetPagesBySite } from "~/queries/page"
|
||||
import { useGetPagesBySiteLite } from "~/queries/page"
|
||||
import { PageVisibilityEnum } from "~/lib/types"
|
||||
import type { ReactElement } from "react"
|
||||
|
||||
@@ -38,7 +38,7 @@ function SiteTagPage({
|
||||
domainOrSubdomain: string
|
||||
tag: string
|
||||
}) {
|
||||
const posts = useGetPagesBySite({
|
||||
const posts = useGetPagesBySiteLite({
|
||||
site: domainOrSubdomain,
|
||||
take: 100,
|
||||
type: "post",
|
||||
|
||||
+20
-1
@@ -8,7 +8,7 @@ import * as pageModel from "~/models/page.model"
|
||||
import { useUnidata } from "./unidata"
|
||||
import { useContract } from "./crossbell"
|
||||
|
||||
export const useGetPagesBySite = (
|
||||
export const useGetPagesBySiteLite = (
|
||||
input: Parameters<typeof pageModel.getPagesBySite>[0],
|
||||
) => {
|
||||
return useInfiniteQuery({
|
||||
@@ -29,6 +29,25 @@ export const useGetPagesBySite = (
|
||||
})
|
||||
}
|
||||
|
||||
export const useGetPagesBySite = (
|
||||
input: Parameters<typeof pageModel.getPagesBySite>[0],
|
||||
) => {
|
||||
const unidata = useUnidata()
|
||||
return useInfiniteQuery({
|
||||
queryKey: ["getPagesBySite", input.site, input],
|
||||
queryFn: async ({ pageParam }) => {
|
||||
return pageModel.getPagesBySite(
|
||||
{
|
||||
...input,
|
||||
cursor: pageParam,
|
||||
},
|
||||
unidata,
|
||||
)
|
||||
},
|
||||
getNextPageParam: (lastPage) => lastPage.cursor,
|
||||
})
|
||||
}
|
||||
|
||||
export const useGetPage = (input: Parameters<typeof pageModel.getPage>[0]) => {
|
||||
const unidata = useUnidata()
|
||||
return useQuery(["getPage", input.page, input], async () => {
|
||||
|
||||
Reference in New Issue
Block a user