fix EVERYTHING for REAL
This commit is contained in:
parent
04f5504e8e
commit
1dbc8de107
4 changed files with 27 additions and 15 deletions
|
@ -91,6 +91,7 @@ export const loadAllAuthors = (): Promise<{ [key: string]: Author }> => {
|
||||||
export const loadAuthors = (
|
export const loadAuthors = (
|
||||||
authorIds: string[]
|
authorIds: string[]
|
||||||
): Promise<{ [key: string]: Author }> => {
|
): Promise<{ [key: string]: Author }> => {
|
||||||
|
'use client'
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (typeof Worker !== 'undefined') {
|
if (typeof Worker !== 'undefined') {
|
||||||
const worker = new Worker(
|
const worker = new Worker(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { documents } from '@/app/db/data'
|
'use client'
|
||||||
import { Zilla_Slab } from 'next/font/google'
|
import { Zilla_Slab } from 'next/font/google'
|
||||||
import { epoch2datestring } from '@/app/utils/epoch2datestring'
|
import { epoch2datestring } from '@/app/utils/epoch2datestring'
|
||||||
import {
|
import {
|
||||||
|
@ -12,16 +12,26 @@ import { ItemBadge, Status } from '@/app/components/Badges'
|
||||||
import { notFound } from 'next/navigation'
|
import { notFound } from 'next/navigation'
|
||||||
import VersionChooser from './VersionChooser'
|
import VersionChooser from './VersionChooser'
|
||||||
import crypto from 'crypto'
|
import crypto from 'crypto'
|
||||||
import loadingStyles from './loading.module.css'
|
|
||||||
import { Suspense } from 'react'
|
import { Suspense } from 'react'
|
||||||
|
import { loadDocument } from '@/app/db/loaders'
|
||||||
|
import { useSuspenseQuery } from '@tanstack/react-query'
|
||||||
|
|
||||||
const zillaSlab = Zilla_Slab({ subsets: ['latin'], weight: ['500'] })
|
const zillaSlab = Zilla_Slab({ subsets: ['latin'], weight: ['500'] })
|
||||||
|
|
||||||
const DocumentViewer = ({ slug }: Readonly<{ slug: string }>) => {
|
const DocumentViewer = ({ slug }: Readonly<{ slug: string }>) => {
|
||||||
const doc = documents[slug]
|
const { data, error } = useSuspenseQuery({
|
||||||
|
queryKey: [slug],
|
||||||
|
queryFn: () => {
|
||||||
|
const data = loadDocument(slug)
|
||||||
|
return data
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if (error) throw error
|
||||||
|
let doc = data
|
||||||
|
// const doc = documents[slug]
|
||||||
const { manifest, abstract, citation } = doc
|
const { manifest, abstract, citation } = doc
|
||||||
|
|
||||||
if (!manifest) return notFound()
|
// if (!manifest) return notFound()
|
||||||
const {
|
const {
|
||||||
title,
|
title,
|
||||||
authors,
|
authors,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
'use client'
|
'use client'
|
||||||
import { useState, useEffect } from 'react'
|
import { useState } from 'react'
|
||||||
import { Document } from '@/app/db/data'
|
import { Document } from '@/app/db/data'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { loadAuthors } from '@/app/db/loaders'
|
import { loadAuthors } from '@/app/db/loaders'
|
||||||
|
@ -19,10 +19,6 @@ const VersionChooser = ({
|
||||||
})
|
})
|
||||||
if (error) throw error
|
if (error) throw error
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
console.log(data)
|
|
||||||
}, [data])
|
|
||||||
|
|
||||||
const { file } = doc
|
const { file } = doc
|
||||||
const { authors, latest } = doc.manifest
|
const { authors, latest } = doc.manifest
|
||||||
const date = epoch2date(doc.manifest.dates[doc.manifest.dates.length - 1])
|
const date = epoch2date(doc.manifest.dates[doc.manifest.dates.length - 1])
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
|
'use client'
|
||||||
import DocumentViewer from './DocumentViewer'
|
import DocumentViewer from './DocumentViewer'
|
||||||
import { documents } from '@/app/db/data'
|
import ErrorBoundary from '@/app/utils/ErrorBoundary'
|
||||||
|
|
||||||
export function generateStaticParams() {
|
// export function generateStaticParams() {
|
||||||
const docsList = Object.keys(documents)
|
// const docsList = Object.keys(documents)
|
||||||
return docsList.map((doc) => ({ doc }))
|
// return docsList.map((doc) => ({ doc }))
|
||||||
}
|
// }
|
||||||
|
|
||||||
export default function Page({
|
export default function Page({
|
||||||
params,
|
params,
|
||||||
}: Readonly<{ params: { slug: string } }>) {
|
}: Readonly<{ params: { slug: string } }>) {
|
||||||
return <DocumentViewer slug={params.slug} />
|
return (
|
||||||
|
<ErrorBoundary>
|
||||||
|
<DocumentViewer slug={params.slug} />
|
||||||
|
</ErrorBoundary>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue