Skip to content

Commit

Permalink
Merge pull request #110 from nih-sparc/condense-contentful-types
Browse files Browse the repository at this point in the history
Condense contentful types
  • Loading branch information
egauzens authored May 21, 2024
2 parents eb3a2fd + 4370d5b commit 3443c45
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components/Footer/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>
<div class="footer__info--blurb">
<p>
{{ footerData.copy }}
{{ footerData.footerDescription }}
</p>
</div>
<div class="footer__info--social">
Expand Down
2 changes: 1 addition & 1 deletion components/LearnMoreCard/LearnMoreCard.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="learn-more-card">
<a class="link1" :href="aboutDetailsItem.fields.link"
<a class="link1" :href="aboutDetailsItem.fields.url"
v-html="aboutDetailsItem.fields ? highlightMatches(aboutDetailsItem.fields.title, $route.query.search) : ''"
/>
<p
Expand Down
1 change: 0 additions & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ export default defineNuxtConfig({
CTF_CDA_ACCESS_TOKEN: process.env.CTF_CDA_ACCESS_TOKEN,
CTF_API_HOST: process.env.CTF_API_HOST || 'preview.contentful.com',
ctf_home_page_id: '4qJ9WUWXg09FAUvCnbGxBY',
ctf_footer_copy_id: 'wpik0A2sDOy9IQEoKpkKG',
ctf_portal_notification_entry_id: 'XiVlrkTXeKxTyN1Q2oY2Q',
ctf_contact_us_form_options_id: '79rwRA0rUqUj6rc913BFsz',
ctf_project_id: 'sparcAward',
Expand Down
26 changes: 23 additions & 3 deletions pages/datasets/[datasetId].vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,25 @@ const getDownloadsSummary = async (config, axios) => {
}
}
const getOrganizationNames = async (algoliaIndex) => {
try {
await algoliaIndex.search('', {
sortFacetValuesBy: 'alpha',
facets: 'pennsieve.organization.name',
}).then(({ facets }) => {
return facets['pennsieve.organization.name'].keys()
})
} catch (error) {
return [
'SPARC',
'SPARC Consortium',
'RE-JOIN',
'HEAL PRECISION',
"IT'IS Foundation"
]
}
}
const tabs = [
{
label: 'Abstract',
Expand Down Expand Up @@ -234,7 +253,7 @@ export default {
const datasetTypeName = typeFacet !== undefined ? typeFacet.children[0].label : 'dataset'
const store = useMainStore()
try {
let [datasetDetails, versions, downloadsSummary] = await Promise.all([
let [datasetDetails, versions, downloadsSummary, sparcOrganizationNames] = await Promise.all([
getDatasetDetails(
config,
datasetId,
Expand All @@ -244,6 +263,7 @@ export default {
),
getDatasetVersions(config, datasetId, $axios),
getDownloadsSummary(config, $axios),
getOrganizationNames(algoliaIndex)
])
datasetDetails = propOr(datasetDetails, 'data', datasetDetails)
Expand Down Expand Up @@ -399,8 +419,8 @@ export default {
]
})
const showTombstone = propOr(false, 'isUnpublished', datasetDetails)
// Redirect them to doi if user tries to navifate directly to a dataset ID that is not a part of SPARC
if (!SPARC_ORGANIZATION_NAMES.includes(propOr('', 'organizationName', datasetDetails)) && !isEmpty(doiLink) && !showTombstone)
// Redirect them to doi if user tries to navigate directly to a dataset ID that is not a part of SPARC
if (!sparcOrganizationNames.includes(propOr('', 'organizationName', datasetDetails)) && !isEmpty(doiLink) && !showTombstone)
{
navigateTo(doiLink, { external: true, redirectCode: 301 })
}
Expand Down
5 changes: 3 additions & 2 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ export const useMainStore = defineStore('main', {
},
async fetchFooterData() {
try {
const response = await useNuxtApp().$contentfulClient.getEntry(useRuntimeConfig().public.ctf_footer_copy_id)
this.setFooterData(response.fields)
const response = await useNuxtApp().$contentfulClient.getEntry(useRuntimeConfig().public.ctf_home_page_id)
const { footerDescription, learnMoreLinks, policiesLinks, helpUsImproveLinks, stayUpdatedLinks } = response.fields
this.setFooterData({ footerDescription, learnMoreLinks, policiesLinks, helpUsImproveLinks, stayUpdatedLinks })
} catch (e) {
console.error(e)
}
Expand Down

0 comments on commit 3443c45

Please sign in to comment.