fix: dashboard local pages missing

This commit is contained in:
DIYgod
2022-11-18 16:26:37 +00:00
parent 9490d032c7
commit 46cf7ad853
5 changed files with 29 additions and 7 deletions
+3
View File
@@ -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) {
+2 -2
View File
@@ -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",
+2 -2
View File
@@ -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,
+2 -2
View File
@@ -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
View File
@@ -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 () => {