in the middle of fixing
This commit is contained in:
parent
5bfcf96987
commit
7e5649c648
3 changed files with 22 additions and 9 deletions
|
@ -88,7 +88,7 @@ export const loadAllAuthors = (): Promise<{ [key: string]: Author }> => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const loadAuthor = (id: string): Promise<Author> => {
|
export const loadAuthors = (authorIds: string[]): Promise<Author> => {
|
||||||
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,7 +1,18 @@
|
||||||
import { authors } from '../data'
|
import { authors, Author } from '../data'
|
||||||
|
|
||||||
|
const checkIsStringArray = (data: unknown): data is string[] => {
|
||||||
|
if (Array.isArray(data)) {
|
||||||
|
return data.every((d) => typeof d === 'string')
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
onmessage = (e) => {
|
onmessage = (e) => {
|
||||||
if (e.data === 'LOAD') {
|
let authorIds: string[] = []
|
||||||
self.postMessage(authors)
|
let authors = []
|
||||||
}
|
checkIsStringArray(e.data) && (authorIds = e.data as string[])
|
||||||
|
|
||||||
|
authorIds.forEach(id => {
|
||||||
|
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
'use client'
|
'use client'
|
||||||
import { useState } from 'react'
|
import { useState, useEffect } 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 { loadAllAuthors } from '@/app/db/loaders'
|
import { loadAllAuthors } from '@/app/db/loaders'
|
||||||
|
@ -19,7 +19,9 @@ const VersionChooser = ({
|
||||||
})
|
})
|
||||||
if (error) throw error
|
if (error) throw error
|
||||||
|
|
||||||
let authorList = data
|
useEffect(() => {
|
||||||
|
console.log(data)
|
||||||
|
}, [data])
|
||||||
|
|
||||||
const { file } = doc
|
const { file } = doc
|
||||||
const { authors, latest } = doc.manifest
|
const { authors, latest } = doc.manifest
|
||||||
|
@ -52,7 +54,7 @@ const VersionChooser = ({
|
||||||
const bibtex = `@article{
|
const bibtex = `@article{
|
||||||
author={${authors
|
author={${authors
|
||||||
.map((a: string, i) => {
|
.map((a: string, i) => {
|
||||||
const author = authorList[a].name.first + ' ' + authorList[a].name.last
|
const author = data[a].name.first + ' ' + data[a].name.last
|
||||||
if (i === 0) return author
|
if (i === 0) return author
|
||||||
else if (i === authors.length - 1) return ` and ${author}`
|
else if (i === authors.length - 1) return ` and ${author}`
|
||||||
else return `, ${author}`
|
else return `, ${author}`
|
||||||
|
|
Loading…
Reference in a new issue