diff --git a/api/data-provider.js b/api/data-provider.js index d0f7e5c0..76e0c48e 100644 --- a/api/data-provider.js +++ b/api/data-provider.js @@ -5,14 +5,8 @@ const API_V3_URL = process.env.API_URL.replace('/internal', '/v3') const requestV3 = (url, ...args) => request(`${API_V3_URL}${url}`, ...args) -// eslint-disable-next-line camelcase -const fetchMetadata = async (id, search_id) => { - const split = search_id?.split('-') - const isUndefined = split?.some((item) => item === undefined) - const { data } = await requestV3( - // eslint-disable-next-line camelcase - `/data-providers/${id}${!isUndefined || search_id ? `?t=${search_id}` : ''}` - ) +const fetchMetadata = async (id) => { + const { data } = await requestV3(`/data-providers/${id}`) return data } diff --git a/api/works.js b/api/works.js index ef819489..dac82ae3 100644 --- a/api/works.js +++ b/api/works.js @@ -1,14 +1,7 @@ import apiRequest from './index' -// eslint-disable-next-line camelcase -const fetchWork = async (id, search_id) => { - const split = search_id?.split('-') - const isUndefined = split?.some((item) => item === undefined) - const url = new URL( - // eslint-disable-next-line camelcase - `/v3/works/${id}${!isUndefined || search_id ? `?t=${search_id}` : ''}`, - process.env.API_URL - ).href +const fetchWork = async (id) => { + const url = new URL(`/v3/works/${id}`, process.env.API_URL).href const { data } = await apiRequest(url) return data diff --git a/package-lock.json b/package-lock.json index b6da8297..1de866a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3109,9 +3109,9 @@ } }, "node_modules/@oacore/design": { - "version": "5.0.18", - "resolved": "https://npm.pkg.github.com/download/@oacore/design/5.0.18/56293ca30af76825e768b4920d9d034256eb7b57", - "integrity": "sha512-L7f29KZDF3nfXeGBcCbiADYcVRZZWGA5sxCvSIMflTuHMNpee2SZ7A9EsOki/pvO0PMaunjGzkw0xBaDZ3OQIw==", + "version": "5.0.22", + "resolved": "https://npm.pkg.github.com/download/@oacore/design/5.0.22/ed15a0f4fc51555a93a0f9f727e0de28915dee0c", + "integrity": "sha512-ea+3KL837xLSnsGlWMAH0Ndcx58hBBky1kOXBS3dkpHYLnac0Me8i56TEkd4QoDntJzoMochhgr0bnFDLvsL6w==", "hasInstallScript": true, "license": "UNLICENSED", "dependencies": { @@ -21669,9 +21669,9 @@ } }, "@oacore/design": { - "version": "5.0.18", - "resolved": "https://npm.pkg.github.com/download/@oacore/design/5.0.18/56293ca30af76825e768b4920d9d034256eb7b57", - "integrity": "sha512-L7f29KZDF3nfXeGBcCbiADYcVRZZWGA5sxCvSIMflTuHMNpee2SZ7A9EsOki/pvO0PMaunjGzkw0xBaDZ3OQIw==", + "version": "5.0.22", + "resolved": "https://npm.pkg.github.com/download/@oacore/design/5.0.22/ed15a0f4fc51555a93a0f9f727e0de28915dee0c", + "integrity": "sha512-ea+3KL837xLSnsGlWMAH0Ndcx58hBBky1kOXBS3dkpHYLnac0Me8i56TEkd4QoDntJzoMochhgr0bnFDLvsL6w==", "requires": { "@babel/runtime": "^7.12.1", "@mdi/svg": "^5.8.55", diff --git a/pages/data-providers/[id].jsx b/pages/data-providers/[id].jsx index 3156206a..bc0a0f49 100644 --- a/pages/data-providers/[id].jsx +++ b/pages/data-providers/[id].jsx @@ -30,10 +30,11 @@ export async function getServerSideProps({ query: searchParams, }) { const { id } = routeParams - const { q = '', offset = 0, limit = 10, sort = 'recency', t } = searchParams + const { q = '', offset = 0, limit = 10, sort = 'recency' } = searchParams + const data = {} try { - const dataProvider = await fetchMetadata(id, t) + const dataProvider = await fetchMetadata(id) const dataProviderStats = await fetchStats(id) Object.assign(data, { diff --git a/pages/works/[id].jsx b/pages/works/[id].jsx index 5d892f90..38172e12 100644 --- a/pages/works/[id].jsx +++ b/pages/works/[id].jsx @@ -16,18 +16,13 @@ import { checkLogo, checkMembership } from 'utils/data-providers-transform' const LOCALE = 'en-GB' const CITATION_STYLES = ['apa', 'bibtex'] -export async function getServerSideProps({ - params: routeParams, - query: searchParams, - req, -}) { +export async function getServerSideProps({ params: routeParams, req }) { const { id } = routeParams - const { t } = searchParams const data = {} try { - const rawWork = await fetchWork(id, t) + const rawWork = await fetchWork(id) const { fullText: _, ...work } = rawWork const outputs = await fetchWorkOutputs(id) diff --git a/templates/search/index.jsx b/templates/search/index.jsx index 90b4d61c..79643032 100644 --- a/templates/search/index.jsx +++ b/templates/search/index.jsx @@ -110,7 +110,7 @@ const SearchTemplate = observe(({ data }) => { /> )} - + {data.currentPage === 1000 && (
Our search interface allows you to see only the first 10.000 diff --git a/templates/search/results.jsx b/templates/search/results.jsx index 96256ae4..fa1c29c5 100644 --- a/templates/search/results.jsx +++ b/templates/search/results.jsx @@ -6,7 +6,7 @@ import { checkType } from '../../utils/data-providers-transform' import { formatDate } from 'utils/helpers' -const Results = ({ works, searchId }) => +const Results = ({ works }) => works.map( ({ id, @@ -35,42 +35,6 @@ const Results = ({ works, searchId }) => memberType?.billing_type === 'supporting' || memberType?.billing_type === 'sustaining' - const generateMetadataLink = (baseLink, propSearchId, propId) => - `${baseLink}/?t=${propSearchId}-${propId}` - - const modifiedReaderLink = readerLink - ?.replace(/(https:\/\/)(core\.ac\.uk)/, '$1api.$2') - .replace('/reader/', '/reader-ui/') - - const renderFullTextLink = ({ - fullTextLink: innerFullTextLink, - downloadLink: innerDownloadLink, - modifiedReaderLink: innerModifiedReaderLink, - searchId: innerSearchId, - id: innerId, - }) => { - if ( - innerFullTextLink == null && - innerDownloadLink == null && - innerModifiedReaderLink == null - ) - return null - if ( - (innerFullTextLink && innerFullTextLink.includes('core')) || - (innerDownloadLink && innerDownloadLink.includes('core')) || - (innerModifiedReaderLink && - innerModifiedReaderLink.includes('api.core')) - ) { - return generateMetadataLink( - innerModifiedReaderLink, - innerSearchId, - innerId - ) - } - if (innerDownloadLink) return innerDownloadLink - return innerFullTextLink - } - return ( variant="outlined" className={styles.searchResults} useLogo={!!checkBillingType()} - searchId={searchId} - renderRedirectLink data={{ - workId: id, + id, title, author: authors, publicationVenue: publicationVenue || null, publicationDate: publicationDate || null, thumbnailUrl: thumbnailLink || `//core.ac.uk/image/${id}/medium`, - metadataLink: - generateMetadataLink(metadataLink, searchId, id) || - generateMetadataLink(displayLink, searchId, id), - fullTextLink: renderFullTextLink({ - fullTextLink, - downloadLink, - modifiedReaderLink, - searchId, - id, - }), + metadataLink: metadataLink || displayLink, + fullTextLink: fullTextLink || readerLink || downloadLink, dataProviders: dataProviders || [], isRecommended: memberType?.billing_type === 'sustaining', }}