start of hero layout, mostly positioning
This commit is contained in:
23
src/utils/getCurrentStudy.ts
Normal file
23
src/utils/getCurrentStudy.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { siteData } from '../data/site';
|
||||
|
||||
type Study = {
|
||||
school: string;
|
||||
study: string;
|
||||
label: string;
|
||||
start: Date;
|
||||
end: Date | null;
|
||||
};
|
||||
|
||||
|
||||
function getStudy(studies: Study[]){
|
||||
if (studies.length === 0) return null;
|
||||
|
||||
return studies.reduce((latest, study) => {
|
||||
if (latest.end === null) return latest;
|
||||
if (study.end === null) return study;
|
||||
|
||||
return study.start.getTime() > latest.start.getTime() ? study : latest;
|
||||
});
|
||||
}
|
||||
|
||||
export const study = getStudy(siteData.studies)
|
||||
Reference in New Issue
Block a user