update download logic and 404 redirect
This commit is contained in:
parent
86473b9880
commit
c898ddf51c
1 changed files with 20 additions and 18 deletions
|
@ -1,4 +1,3 @@
|
||||||
'use client'
|
|
||||||
import styles from './documentViewer.module.css'
|
import styles from './documentViewer.module.css'
|
||||||
import { Zilla_Slab } from 'next/font/google'
|
import { Zilla_Slab } from 'next/font/google'
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
|
@ -8,8 +7,8 @@ import {
|
||||||
topics as topicList,
|
topics as topicList,
|
||||||
authors as authorList,
|
authors as authorList,
|
||||||
} from '../../../db/data'
|
} from '../../../db/data'
|
||||||
import { navigate } from '../../../actions'
|
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
|
import { notFound } from 'next/navigation'
|
||||||
|
|
||||||
const zillaSlab = Zilla_Slab({ subsets: ['latin'], weight: ['500'] })
|
const zillaSlab = Zilla_Slab({ subsets: ['latin'], weight: ['500'] })
|
||||||
|
|
||||||
|
@ -32,7 +31,7 @@ export default function Page({
|
||||||
}: Readonly<{ params: { slug: string } }>) {
|
}: Readonly<{ params: { slug: string } }>) {
|
||||||
const doc = documents[params.slug]
|
const doc = documents[params.slug]
|
||||||
if (!doc) {
|
if (!doc) {
|
||||||
navigate('/404')
|
notFound()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const { abstract, file } = doc
|
const { abstract, file } = doc
|
||||||
|
@ -148,22 +147,25 @@ export default function Page({
|
||||||
<p className='my-4 text-xl text-slate-600 font-serif '>{abstract}</p>
|
<p className='my-4 text-xl text-slate-600 font-serif '>{abstract}</p>
|
||||||
<p className='my-2'>{generateTopics()}</p>
|
<p className='my-2'>{generateTopics()}</p>
|
||||||
<p className='my-2'>{generateCode()}</p>
|
<p className='my-2'>{generateCode()}</p>
|
||||||
<button
|
<Link
|
||||||
className='bg-blue-600 text-slate-100 hover:bg-blue-400 font-semibold rounded py-2 px-4 my-2'
|
href={`/download/${params.slug}/file${latest}.${file}`}
|
||||||
onClick={handleDownloadLatest}
|
download={`${params.slug}-rev-${latest}.pdf`}
|
||||||
|
target='_blank'
|
||||||
>
|
>
|
||||||
Download{' '}
|
<button className='bg-blue-600 text-slate-100 hover:bg-blue-400 font-semibold rounded py-2 px-4 my-2'>
|
||||||
{(() => {
|
Download{' '}
|
||||||
switch (file) {
|
{(() => {
|
||||||
case 'other':
|
switch (file) {
|
||||||
return <></>
|
case 'other':
|
||||||
case 'tar.gz':
|
return <></>
|
||||||
return 'Tarball'
|
case 'tar.gz':
|
||||||
default:
|
return 'Tarball'
|
||||||
return file.toUpperCase()
|
default:
|
||||||
}
|
return file.toUpperCase()
|
||||||
})()}
|
}
|
||||||
</button>
|
})()}
|
||||||
|
</button>
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue