vercel-edge-deploy-test
This commit is contained in:
parent
e6e19d74cd
commit
a186dc4d3f
|
@ -8,7 +8,7 @@ import sassDts from 'vite-plugin-sass-dts'
|
|||
const isVercel = Boolean(process?.env.VERCEL)
|
||||
const isNetlify = Boolean(process?.env.NETLIFY)
|
||||
const isBun = Boolean(process.env.BUN)
|
||||
const runtime = isNetlify ? 'netlify' : isVercel ? 'vercel' : isBun ? 'bun' : 'node'
|
||||
const runtime = isNetlify ? 'netlify' : isVercel ? 'vercel_edge' : isBun ? 'bun' : 'node'
|
||||
console.info(`[app.config] build for ${runtime}!`)
|
||||
|
||||
const polyfillOptions = {
|
||||
|
|
|
@ -15,17 +15,13 @@ const fetchAuthorsWithStat = async (offset = 0, order?: string) => {
|
|||
return await authorsFetcher()
|
||||
}
|
||||
|
||||
export const fetchAllAuthors = async () => {
|
||||
const authorsAllFetcher = loadAuthorsAll()
|
||||
return await authorsAllFetcher()
|
||||
}
|
||||
|
||||
export const route = {
|
||||
load: async ({ location: { query } }: RouteLoadFuncArgs) => {
|
||||
const by = query.by
|
||||
const isAll = !by || by === 'name'
|
||||
const authorsAllFetcher = loadAuthorsAll()
|
||||
return {
|
||||
authors: isAll && (await fetchAllAuthors()),
|
||||
authors: isAll && (await authorsAllFetcher()),
|
||||
authorsByFollowers: await fetchAuthorsWithStat(10, 'followers'),
|
||||
authorsByShouts: await fetchAuthorsWithStat(10, 'shouts')
|
||||
} as AllAuthorsData
|
||||
|
@ -38,13 +34,14 @@ type AllAuthorsData = { authors: Author[]; authorsByFollowers: Author[]; authors
|
|||
|
||||
export default function AllAuthorsPage(props: RouteSectionProps<AllAuthorsData>) {
|
||||
const { t } = useLocalize()
|
||||
const { addAuthors } = useAuthors()
|
||||
const { addAuthors, authorsSorted } = useAuthors()
|
||||
|
||||
// async load data: from ssr or fetch
|
||||
const data = createAsync<AllAuthorsData>(async () => {
|
||||
if (props.data) return props.data
|
||||
const authorsAllFetcher = loadAuthorsAll()
|
||||
return {
|
||||
authors: await fetchAllAuthors(),
|
||||
authors: authorsSorted() || await authorsAllFetcher(),
|
||||
authorsByFollowers: await fetchAuthorsWithStat(10, 'followers'),
|
||||
authorsByShouts: await fetchAuthorsWithStat(10, 'shouts')
|
||||
} as AllAuthorsData
|
||||
|
|
|
@ -2,21 +2,27 @@ import { RouteDefinition, RouteSectionProps, createAsync } from '@solidjs/router
|
|||
import { InboxView } from '~/components/Views/Inbox/Inbox'
|
||||
import { PageLayout } from '~/components/_shared/PageLayout'
|
||||
import { ShowOnlyOnClient } from '~/components/_shared/ShowOnlyOnClient'
|
||||
import { useAuthors } from '~/context/authors'
|
||||
import { useLocalize } from '~/context/localize'
|
||||
import { loadAuthorsAll } from '~/graphql/api/public'
|
||||
import { Author } from '~/graphql/schema/core.gen'
|
||||
import { fetchAllAuthors } from '../author/(all-authors)'
|
||||
|
||||
export const route = {
|
||||
load: async () => {
|
||||
const authorsAllFetcher = loadAuthorsAll()
|
||||
return {
|
||||
authors: await fetchAllAuthors()
|
||||
authors: await authorsAllFetcher()
|
||||
}
|
||||
}
|
||||
} satisfies RouteDefinition
|
||||
|
||||
export const InboxPage = (props: RouteSectionProps<{ authors: Author[] }>) => {
|
||||
const { t } = useLocalize()
|
||||
const authors = createAsync(async () => props.data.authors || (await fetchAllAuthors()))
|
||||
const { authorsSorted } = useAuthors()
|
||||
const authors = createAsync(async () => {
|
||||
const authorsAllFetcher = loadAuthorsAll()
|
||||
return props.data.authors || authorsSorted() || (await authorsAllFetcher())
|
||||
})
|
||||
|
||||
return (
|
||||
<PageLayout hideFooter={true} title={t('Inbox')}>
|
||||
|
|
|
@ -6,14 +6,15 @@ import { ShowOnlyOnClient } from '~/components/_shared/ShowOnlyOnClient'
|
|||
import { useInbox } from '~/context/inbox'
|
||||
import { useLocalize } from '~/context/localize'
|
||||
import { useSession } from '~/context/session'
|
||||
import { loadAuthorsAll } from '~/graphql/api/public'
|
||||
import { Chat } from '~/graphql/schema/chat.gen'
|
||||
import { Author } from '~/graphql/schema/core.gen'
|
||||
import { fetchAllAuthors } from '../author/(all-authors)'
|
||||
|
||||
export const route = {
|
||||
load: async () => {
|
||||
const authorsAllFetcher = loadAuthorsAll()
|
||||
return {
|
||||
authors: await fetchAllAuthors()
|
||||
authors: await authorsAllFetcher()
|
||||
}
|
||||
}
|
||||
} satisfies RouteDefinition
|
||||
|
@ -24,7 +25,10 @@ export const ChatPage = (props: RouteSectionProps<{ authors: Author[] }>) => {
|
|||
const { createChat, chats } = useInbox()
|
||||
const [chat, setChat] = createSignal<Chat>()
|
||||
const { session } = useSession()
|
||||
const authors = createAsync(async () => props.data.authors || (await fetchAllAuthors()))
|
||||
const authors = createAsync(async () => {
|
||||
const authorsAllFetcher = loadAuthorsAll()
|
||||
return props.data.authors || (await authorsAllFetcher())
|
||||
})
|
||||
|
||||
onMount(async () => {
|
||||
if (params.id.includes('-')) {
|
||||
|
|
|
@ -38,14 +38,17 @@ export type TopicPageProps = { articles?: Shout[]; topics: Topic[]; authors?: Au
|
|||
|
||||
export default function TopicPage(props: RouteSectionProps<TopicPageProps>) {
|
||||
const { t } = useLocalize()
|
||||
const { addTopics } = useTopics()
|
||||
const { addTopics, sortedTopics } = useTopics()
|
||||
const [loadingError, setLoadingError] = createSignal(false)
|
||||
|
||||
const topic = createAsync(async () => {
|
||||
try {
|
||||
const ttt: Topic[] = props.data.topics || (await fetchAllTopics()) || []
|
||||
addTopics(ttt)
|
||||
console.debug('[route.topic] all topics loaded')
|
||||
let ttt: Topic[] = sortedTopics()
|
||||
if (!ttt) {
|
||||
ttt = props.data.topics || (await fetchAllTopics()) || []
|
||||
addTopics(ttt)
|
||||
console.debug('[route.topic] all topics loaded')
|
||||
}
|
||||
const t = ttt.find((x) => x.slug === props.params.slug)
|
||||
return t
|
||||
} catch (_error) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user