|
1 | | -import alzheimersDisease from '../../example-data/alzheimers-disease.json'; |
2 | | -import alzheimersDiagnosis from '../../example-data/alzheimers-diagnosis.json'; |
3 | | -import alzheimersNeuroinflammation from '../../example-data/alzheimers-neuroinflammation.json'; |
4 | | -// import alzheimersTherapeutics from '../../example-data/alzheimers-therapeutics.json'; |
5 | | - |
6 | | -const ALZHEIMERS_DISEASE_ID = 'alzheimers-disease'; |
7 | | -const ALZHEIMERS_DIAGNOSIS_ID = 'alzheimers-diagnosis'; |
8 | | -const ALZHEIMERS_NEUROINFLAMMATION_ID = 'alzheimers-neuroinflammation'; |
9 | | -// const ALZHEIMERS_THERAPEUTICS = 'alzheimers-therapeutics'; |
| 1 | +import data from '../../example-data/data.json'; |
10 | 2 |
|
11 | 3 | const toDate = o => { |
12 | 4 | o.date = new Date(o.date); |
13 | 5 | return o; |
14 | 6 | }; |
15 | 7 | const byDate = (a, b) => { return b.date - a.date; }; |
16 | | -export const categories = [ |
17 | | - { |
18 | | - id: ALZHEIMERS_DISEASE_ID, |
19 | | - name: 'Alzheimer\'s Disease', |
20 | | - description: 'Latest research reports about AD in the clinic and at the bench.' |
21 | | - }, |
22 | | - { |
23 | | - id: ALZHEIMERS_DIAGNOSIS_ID, |
24 | | - name: 'Alzheimer\'s Disease: Diagnosis', |
25 | | - description: 'Diagnostics, biomarkers and their relationship to AD phenotypes.' |
26 | | - }, |
27 | | - { |
28 | | - id: ALZHEIMERS_NEUROINFLAMMATION_ID, |
29 | | - name: 'Alzheimer\'s Disease: Neuroinflammation', |
30 | | - description: 'Relationships between neuroinflammation and amyloid and tau pathologies and its effect on disease trajectory.' |
31 | | - } |
32 | | - // , |
33 | | - // { |
34 | | - // id: ALZHEIMERS_THERAPEUTICS, |
35 | | - // name: 'Alzheimer\'s Disease: Therapeutics', |
36 | | - // description: 'Nonpharmacological and pharmacological management of the cognitive and behavioral symptoms of AD.' |
37 | | - // } |
38 | | -]; |
39 | | - |
| 8 | +export const categories = data.map(({ id, name, description, img }) => ({ id, name, description, img })); |
40 | 9 | export const getPapers = ({ id, limit = 20 }) => { |
41 | | - let papers; |
42 | | - |
43 | | - switch (id) { |
44 | | - case ALZHEIMERS_DISEASE_ID: |
45 | | - papers = alzheimersDisease; |
46 | | - break; |
47 | | - case ALZHEIMERS_DIAGNOSIS_ID: |
48 | | - papers = alzheimersDiagnosis; |
49 | | - break; |
50 | | - case ALZHEIMERS_NEUROINFLAMMATION_ID: |
51 | | - papers = alzheimersNeuroinflammation; |
52 | | - break; |
53 | | - // case ALZHEIMERS_THERAPEUTICS: |
54 | | - // papers = alzheimersTherapeutics; |
55 | | - // break; |
56 | | - default: |
57 | | - console.error(`Unable to load ${id}.`); |
58 | | - } |
59 | | - papers = papers.map(toDate).sort(byDate).slice(1, limit); |
| 10 | + let papers = []; |
| 11 | + const category = data.find(cat => cat.id === id); |
| 12 | + papers = category && category.papers.map(toDate).sort(byDate).slice(1, limit); |
60 | 13 | return papers; |
61 | 14 | }; |
62 | 15 |
|
|
0 commit comments