Add Next SEO and clean some code

This commit is contained in:
mbaharip
2023-04-27 15:02:13 +07:00
parent 40712d9f3c
commit 3868e2e789
23 changed files with 118 additions and 1297 deletions
-38
View File
@@ -33,44 +33,6 @@ export function buildQuery({
return query.join(" and ");
}
export async function _checkProtected(id: string) {
try {
const files = await drive.files.list({
q: id ? buildQuery({ id }) : buildQuery({}),
fields: "files(id)",
});
return {
protected: files.data.files?.length,
id: files.data.files?.[0].id || null,
};
} catch (error: any) {
return {
protected: false,
id: null,
};
}
}
export async function _validateFolderPassword(
passwordFileId: string,
password: string,
) {
try {
const folderPassword = await drive.files.get(
{
fileId: passwordFileId,
alt: "media",
},
{ responseType: "text" },
);
return folderPassword.data === password;
} catch (error: any) {
return false;
}
}
export async function validateProtected(
fileId: string | TFileParent[],
passwordHash?: string,
+1 -5
View File
@@ -4,7 +4,6 @@ import {
BsBoxFill,
BsDatabaseFill,
BsFileEarmarkBinaryFill,
BsFileEarmarkBreakFill,
BsFileEarmarkCodeFill,
BsFileEarmarkFill,
BsFileEarmarkFontFill,
@@ -13,14 +12,11 @@ import {
BsFileEarmarkPdfFill,
BsFileEarmarkPlayFill,
BsFileEarmarkRichtextFill,
BsFileEarmarkRuledFill,
BsFileEarmarkSlidesFill,
BsFileEarmarkSpreadsheetFill,
BsFileEarmarkTextFill,
BsFileEarmarkWordFill,
BsFileEarmarkZipFill,
BsFillDatabaseFill,
BsFolderFill,
} from "react-icons/bs";
import ModelPreview from "@components/FilePreview/ModelPreview";
import AudioPreview from "@components/FilePreview/AudioPreview";
@@ -33,7 +29,7 @@ import CodePreview from "@components/FilePreview/CodePreview";
import TextPreview from "@components/FilePreview/TextPreview";
import VideoPreview from "@components/FilePreview/VideoPreview";
export default function findMimeType(extension: string): string {
function findMimeType(extension: string): string {
return mime.lookup(extension) || "application/octet-stream";
}
-11
View File
@@ -4,17 +4,6 @@ import { FilesResponse } from "@/types/googleapis";
const fetcher = async <T>(url: string, headers: Record<string, string> = {}) =>
axios.get<T>(url, { headers }).then((res) => res.data);
function getNextKey(
pageIndex: number,
previousPageData: FilesResponse,
): string | null {
if (previousPageData && !previousPageData.nextPageToken) {
return null;
}
const pageToken = previousPageData ? previousPageData.nextPageToken : "";
return `/api/files?pageToken=${pageToken}`;
}
export function buildNextKey(apiURL: string) {
return (pageIndex: number, previousPageData: FilesResponse) => {
if (previousPageData && !previousPageData.nextPageToken) {