add eexiv whitepaper and recent documents list
This commit is contained in:
parent
53eba1cc38
commit
7c6785042d
6 changed files with 144 additions and 70 deletions
BIN
public/download/eexiv-white-paper/file2.pdf
Normal file
BIN
public/download/eexiv-white-paper/file2.pdf
Normal file
Binary file not shown.
63
src/app/components/RandomDocs.tsx
Normal file
63
src/app/components/RandomDocs.tsx
Normal file
|
@ -0,0 +1,63 @@
|
|||
import { epoch2datestring } from '@/app/utils/epoch2datestring'
|
||||
import { documents, topics as topicsList } from '@/app/db/data'
|
||||
import Link from 'next/link'
|
||||
|
||||
const RandomDocs = (): React.ReactNode[] => {
|
||||
// Convert the object keys into an array
|
||||
const keys = Object.keys(documents)
|
||||
|
||||
// Determine the number of keys to process (all if fewer than 10)
|
||||
const numKeysToProcess = keys.length < 10 ? keys.length : 10
|
||||
|
||||
// Shuffle the keys array if there are more than 10 keys
|
||||
if (keys.length > 10) {
|
||||
for (let i = keys.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1))
|
||||
;[keys[i], keys[j]] = [keys[j], keys[i]]
|
||||
}
|
||||
}
|
||||
|
||||
// Select keys based on numKeysToProcess
|
||||
const selectedKeys = keys.slice(0, numKeysToProcess)
|
||||
|
||||
// Iterate over each of the selected keys
|
||||
return selectedKeys.map((key, index) => {
|
||||
const { title, dates, type, topics } = documents[key].manifest
|
||||
let dateString = epoch2datestring(dates[dates.length - 1])
|
||||
let typeString = ''
|
||||
switch (type) {
|
||||
case 'report':
|
||||
typeString = 'report'
|
||||
break
|
||||
case 'presentation':
|
||||
typeString = 'presentation'
|
||||
break
|
||||
case 'white paper':
|
||||
typeString = 'white paper'
|
||||
break
|
||||
case 'datasheet':
|
||||
typeString = 'datasheet'
|
||||
break
|
||||
case 'dwm':
|
||||
typeString = 'DWM'
|
||||
break
|
||||
case 'guide':
|
||||
typeString = 'guide'
|
||||
break
|
||||
case 'other':
|
||||
typeString = 'document'
|
||||
break
|
||||
}
|
||||
|
||||
return (
|
||||
<div key={key}>
|
||||
<Link href={`/document/view/${key}`}>{title}</Link>, a {typeString}{' '}
|
||||
about {topicsList[topics[0]]['name']} published on {dateString}
|
||||
.
|
||||
<br />
|
||||
</div>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export default RandomDocs
|
70
src/app/components/RecentDocuments.tsx
Normal file
70
src/app/components/RecentDocuments.tsx
Normal file
|
@ -0,0 +1,70 @@
|
|||
import { epoch2datestring } from '@/app/utils/epoch2datestring'
|
||||
import { documents, topics as topicsList, Document } from '@/app/db/data'
|
||||
import Link from 'next/link'
|
||||
|
||||
function getThreeMostRecentDocuments(
|
||||
docs: Readonly<{ [key: string]: Document }>
|
||||
): { [key: string]: Document } {
|
||||
return Object.entries(docs)
|
||||
.filter(([_, document]) => document.manifest.status !== 'draft') // Exclude documents with status 'draft'
|
||||
.map(([slug, document]) => ({
|
||||
slug,
|
||||
document,
|
||||
latestDate: document.manifest.dates[document.manifest.dates.length - 1], // Get the last (latest) date
|
||||
}))
|
||||
.sort((a, b) => b.latestDate - a.latestDate) // Sort by the latest date, descending
|
||||
.slice(0, 3) // Take the top 3
|
||||
.reduce(
|
||||
(acc, { slug, document }) => {
|
||||
acc[slug] = document // Reconstruct the object with the top 3 documents
|
||||
return acc
|
||||
},
|
||||
{} as { [key: string]: Document }
|
||||
)
|
||||
}
|
||||
|
||||
const RecentDocuments = (): React.ReactNode[] => {
|
||||
// Convert the object keys into an array
|
||||
const keys = Object.keys(getThreeMostRecentDocuments(documents))
|
||||
|
||||
// Iterate over each of the selected keys
|
||||
return keys.map((key) => {
|
||||
const { title, dates, type, topics } = documents[key].manifest
|
||||
let dateString = epoch2datestring(dates[dates.length - 1])
|
||||
let typeString = ''
|
||||
switch (type) {
|
||||
case 'report':
|
||||
typeString = 'report'
|
||||
break
|
||||
case 'presentation':
|
||||
typeString = 'presentation'
|
||||
break
|
||||
case 'white paper':
|
||||
typeString = 'white paper'
|
||||
break
|
||||
case 'datasheet':
|
||||
typeString = 'datasheet'
|
||||
break
|
||||
case 'dwm':
|
||||
typeString = 'DWM'
|
||||
break
|
||||
case 'guide':
|
||||
typeString = 'guide'
|
||||
break
|
||||
case 'other':
|
||||
typeString = 'document'
|
||||
break
|
||||
}
|
||||
|
||||
return (
|
||||
<div key={key}>
|
||||
<Link href={`/document/view/${key}`}>{title}</Link>, a {typeString}{' '}
|
||||
about {topicsList[topics[0]]['name']} published on {dateString}
|
||||
.
|
||||
<br />
|
||||
</div>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export default RecentDocuments
|
|
@ -285,10 +285,10 @@ On Day 1 we will discuss the ins and outs of the robot. The Electrical Sub team
|
|||
title: 'eeXiv White Paper',
|
||||
authors: ['ywu', 'avenkatesh'],
|
||||
topics: ['eecs', 'frc'],
|
||||
dates: [1707811359],
|
||||
dates: [1707811359, 1707891311],
|
||||
type: 'white paper',
|
||||
latest: 1,
|
||||
status: 'draft',
|
||||
latest: 2,
|
||||
status: 'under review',
|
||||
keywords: [
|
||||
'eexiv',
|
||||
'white paper',
|
||||
|
|
|
@ -1,78 +1,16 @@
|
|||
import Link from 'next/link'
|
||||
import {
|
||||
documents,
|
||||
authors,
|
||||
topics as topicsList,
|
||||
affiliations,
|
||||
} from './db/data'
|
||||
import { epoch2datestring } from './utils/epoch2datestring'
|
||||
import { documents, authors, affiliations } from './db/data'
|
||||
import News from './components/News'
|
||||
import RandomDocs from './components/RandomDocs'
|
||||
import RecentDocuments from './components/RecentDocuments'
|
||||
|
||||
export default function Home() {
|
||||
const RandomDocs = (): React.ReactNode[] => {
|
||||
// Convert the object keys into an array
|
||||
const keys = Object.keys(documents)
|
||||
|
||||
// Determine the number of keys to process (all if fewer than 10)
|
||||
const numKeysToProcess = keys.length < 10 ? keys.length : 10
|
||||
|
||||
// Shuffle the keys array if there are more than 10 keys
|
||||
if (keys.length > 10) {
|
||||
for (let i = keys.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1))
|
||||
;[keys[i], keys[j]] = [keys[j], keys[i]]
|
||||
}
|
||||
}
|
||||
|
||||
// Select keys based on numKeysToProcess
|
||||
const selectedKeys = keys.slice(0, numKeysToProcess)
|
||||
|
||||
// Iterate over each of the selected keys
|
||||
return selectedKeys.map((key, index) => {
|
||||
const { title, dates, type, topics } = documents[key].manifest
|
||||
let dateString = epoch2datestring(dates[dates.length - 1])
|
||||
let typeString = ''
|
||||
switch (type) {
|
||||
case 'report':
|
||||
typeString = 'report'
|
||||
break
|
||||
case 'presentation':
|
||||
typeString = 'presentation'
|
||||
break
|
||||
case 'white paper':
|
||||
typeString = 'white paper'
|
||||
break
|
||||
case 'datasheet':
|
||||
typeString = 'datasheet'
|
||||
break
|
||||
case 'dwm':
|
||||
typeString = 'DWM'
|
||||
break
|
||||
case 'guide':
|
||||
typeString = 'guide'
|
||||
break
|
||||
case 'other':
|
||||
typeString = 'document'
|
||||
break
|
||||
}
|
||||
|
||||
return (
|
||||
<div key={index}>
|
||||
<Link href={`/document/view/${key}`}>{title}</Link>, a {typeString}{' '}
|
||||
about {topicsList[topics[0]]['name']} published on {dateString}
|
||||
.
|
||||
<br />
|
||||
</div>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const AuthorDisplay = () => {
|
||||
return Object.entries(authors).map(([author, data], index) => {
|
||||
let affiliationSlug = data.affiliation[0].split('@')[1]
|
||||
let affiliation = affiliations[affiliationSlug]
|
||||
return (
|
||||
<div key={index}>
|
||||
<div key={author}>
|
||||
<Link href={`/author/${author}`}>
|
||||
{data.name.first}
|
||||
{data.name.nickname ? ` "${data.name.nickname}" ` : ' '}
|
||||
|
@ -106,6 +44,9 @@ export default function Home() {
|
|||
</p>
|
||||
<News />
|
||||
<div className='grid grid-cols-1 space-y-2 mt-4 basis-full'>
|
||||
<hr className='mx-auto w-full h-1 border-0 bg-slate-200 my-2 rounded-md' />
|
||||
<span className='font-serif text-xl'>Recently released documents</span>
|
||||
<RecentDocuments />
|
||||
<hr className='mx-auto w-full h-1 border-0 bg-slate-200 my-2 rounded-md' />
|
||||
<span className='font-serif text-xl'>
|
||||
Selected documents in various disciplines
|
||||
|
|
|
@ -55,7 +55,7 @@ const miniSearch = new MiniSearch({
|
|||
authors: 2,
|
||||
abstract: 0.3,
|
||||
},
|
||||
fuzzy: 2,
|
||||
fuzzy: 0.2,
|
||||
prefix: true,
|
||||
},
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue