mirror of
https://github.com/Nezumi-2711/onedrive-vercel-index.git
synced 2026-09-22 20:01:46 +00:00
Standalone raw file redirects (#428)
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { useRouter } from 'next/router'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
|
||||
import FourOhFour from '../FourOhFour'
|
||||
import Loading from '../Loading'
|
||||
import { DownloadButton } from '../DownloadBtnGtoup'
|
||||
import useAxiosGet from '../../utils/fetchOnMount'
|
||||
import useFileContent from '../../utils/fetchOnMount'
|
||||
import { DownloadBtnContainer, PreviewContainer } from './Containers'
|
||||
|
||||
const parseDotUrl = (content: string): string | undefined => {
|
||||
@@ -14,9 +15,10 @@ const parseDotUrl = (content: string): string | undefined => {
|
||||
}
|
||||
|
||||
const TextPreview = ({ file }) => {
|
||||
const { asPath } = useRouter()
|
||||
const { t } = useTranslation()
|
||||
|
||||
const { response: content, error, validating } = useAxiosGet(file['@microsoft.graph.downloadUrl'])
|
||||
const { response: content, error, validating } = useFileContent(`/api/raw/?path=${asPath}`, asPath)
|
||||
if (error) {
|
||||
return (
|
||||
<PreviewContainer>
|
||||
@@ -49,11 +51,11 @@ const TextPreview = ({ file }) => {
|
||||
<DownloadBtnContainer>
|
||||
<div className="flex justify-center">
|
||||
<DownloadButton
|
||||
onClickCallback={() => window.open(parseDotUrl(content) || '')}
|
||||
onClickCallback={() => window.open(parseDotUrl(content) ?? '')}
|
||||
btnColor="blue"
|
||||
btnText={t('Open URL')}
|
||||
btnIcon="external-link-alt"
|
||||
btnTitle={t('Open URL{{url}}', { url: ' ' + parseDotUrl(content) || '' })}
|
||||
btnTitle={t('Open URL{{url}}', { url: ' ' + parseDotUrl(content) ?? '' })}
|
||||
/>
|
||||
</div>
|
||||
</DownloadBtnContainer>
|
||||
|
||||
Reference in New Issue
Block a user