diff --git a/public/download/eexiv-white-paper/file2.pdf b/public/download/eexiv-white-paper/file2.pdf new file mode 100644 index 0000000..7d9bc2d Binary files /dev/null and b/public/download/eexiv-white-paper/file2.pdf differ diff --git a/src/app/components/RandomDocs.tsx b/src/app/components/RandomDocs.tsx new file mode 100644 index 0000000..0f492d9 --- /dev/null +++ b/src/app/components/RandomDocs.tsx @@ -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 ( +
+ {title}, a {typeString}{' '} + about {topicsList[topics[0]]['name']} published on {dateString} + . +
+
+ ) + }) +} + +export default RandomDocs diff --git a/src/app/components/RecentDocuments.tsx b/src/app/components/RecentDocuments.tsx new file mode 100644 index 0000000..d12dabd --- /dev/null +++ b/src/app/components/RecentDocuments.tsx @@ -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 ( +
+ {title}, a {typeString}{' '} + about {topicsList[topics[0]]['name']} published on {dateString} + . +
+
+ ) + }) +} + +export default RecentDocuments diff --git a/src/app/db/data.ts b/src/app/db/data.ts index a909d4a..482db35 100644 --- a/src/app/db/data.ts +++ b/src/app/db/data.ts @@ -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', diff --git a/src/app/page.tsx b/src/app/page.tsx index bf3a457..3af3ee2 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -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 ( -
- {title}, a {typeString}{' '} - about {topicsList[topics[0]]['name']} published on {dateString} - . -
-
- ) - }) - } - const AuthorDisplay = () => { return Object.entries(authors).map(([author, data], index) => { let affiliationSlug = data.affiliation[0].split('@')[1] let affiliation = affiliations[affiliationSlug] return ( -
+
{data.name.first} {data.name.nickname ? ` "${data.name.nickname}" ` : ' '} @@ -106,6 +44,9 @@ export default function Home() {

+
+ Recently released documents +
Selected documents in various disciplines diff --git a/src/app/utils/search.worker.ts b/src/app/utils/search.worker.ts index b8f2820..0beeb70 100644 --- a/src/app/utils/search.worker.ts +++ b/src/app/utils/search.worker.ts @@ -55,7 +55,7 @@ const miniSearch = new MiniSearch({ authors: 2, abstract: 0.3, }, - fuzzy: 2, + fuzzy: 0.2, prefix: true, }, })