Skip to content

Commit 6e0690b

Browse files
authored
Merge pull request #50 from dailybruin/bryson/issuuLinks
Created a dictionary of non-templated links, may need to have a discussion about format with prime in the future.
2 parents 0040268 + c2e3b63 commit 6e0690b

File tree

1 file changed

+37
-16
lines changed

1 file changed

+37
-16
lines changed

src/templates/issue.tsx

+37-16
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,42 @@ export const query = graphql`
3838
}
3939
`
4040

41+
// the link is determined by the filename on upload oops so be careful!
42+
const specialIssuuLinks = {
43+
2018: {
44+
spring: 'https://e.issuu.com/anonymous-embed.html?u=dailybruin&d=finalpdf',
45+
},
46+
2020: {
47+
winter: 'https://e.issuu.com/anonymous-embed.html?u=dailybruin&d=master',
48+
},
49+
2021: {
50+
winter: 'https://e.issuu.com/embed.html?d=prime_winter_21&u=dailybruin',
51+
spring: 'https://e.issuu.com/anonymous-embed.html?u=dailybruin&d=prime_w21',
52+
},
53+
2022: {
54+
fall: 'https://e.issuu.com/embed.html?d=prime_f22_full_mag_&u=dailybruin',
55+
},
56+
2023: {
57+
winter:
58+
'https://e.issuu.com/embed.html?d=prime_w23_full_mag_pages&u=dailybruin',
59+
spring:
60+
'https://e.issuu.com/embed.html?d=prime_s23_full_mag_pages&u=dailybruin',
61+
},
62+
}
63+
64+
const getIssuuComponent = (year: number, season: string) => {
65+
if (season === 'summer') return null // summer issues are not magazines
66+
67+
if (specialIssuuLinks[year] && specialIssuuLinks[year][season]) {
68+
return <Magazine link={specialIssuuLinks[year][season]} />
69+
}
70+
71+
let defaultIssuuLink = `https://e.issuu.com/anonymous-embed.html?u=dailybruin&d=prime${season}${year}`
72+
if (year > 2017 || (year === 2017 && season === 'fall'))
73+
defaultIssuuLink = `https://e.issuu.com/anonymous-embed.html?u=dailybruin&d=prime_${season}_${year}`
74+
return <Magazine link={defaultIssuuLink} />
75+
}
76+
4177
export default ({ data, pageContext }) => {
4278
let articles = []
4379
data.allPrimeArticle.edges.forEach(edge => {
@@ -55,19 +91,6 @@ export default ({ data, pageContext }) => {
5591
const term = pageContext.term
5692
const season = term.substring(0, term.length - 2)
5793
const year = '20' + term.substring(term.length - 2, term.length)
58-
let issuuLink = `https://e.issuu.com/anonymous-embed.html?u=dailybruin&d=prime${season}${year}`
59-
if (parseInt(year) > 2017 || (parseInt(year) === 2017 && season === 'fall'))
60-
issuuLink = `https://e.issuu.com/anonymous-embed.html?u=dailybruin&d=prime_${season}_${year}`
61-
if (term === 'spring18')
62-
issuuLink =
63-
'https://e.issuu.com/anonymous-embed.html?u=dailybruin&d=finalpdf'
64-
if (term == 'winter20')
65-
issuuLink = 'https://e.issuu.com/anonymous-embed.html?u=dailybruin&d=master'
66-
if (term == 'winter21')
67-
issuuLink = `https://e.issuu.com/anonymous-embed.html?u=dailybruin&d=prime_w21`
68-
if (term == 'spring21')
69-
issuuLink = `https://e.issuu.com/anonymous-embed.html?u=dailybruin&d=prime_spring_21`
70-
// the link is determined by the filename on upload oops so be careful!
7194
const formatTerm = season + ' ' + year
7295
const articleCards = []
7396
articles.forEach((article, i) => {
@@ -150,9 +173,7 @@ export default ({ data, pageContext }) => {
150173
>
151174
<ArticleGrid>{articleCards}</ArticleGrid>
152175
</div>
153-
{term != 'summer20' && term != 'summer21' && (
154-
<Magazine link={issuuLink} />
155-
)}
176+
{getIssuuComponent(parseInt(year), season)}
156177
<Footer />
157178
</div>
158179
</div>

0 commit comments

Comments
 (0)