mirror of
https://github.com/Nezumi-2711/next-gdrive-index.git
synced 2026-09-22 20:01:36 +00:00
update: add siteConfig argument to set replace value
This commit is contained in:
+12
-8
@@ -1,7 +1,7 @@
|
||||
import { decodeBase64url, encodeBase64url } from "@oslojs/encoding";
|
||||
import { GoogleAuth } from "google-auth-library";
|
||||
import { JSONClient } from "google-auth-library/build/src/auth/googleauth";
|
||||
import { drive_v3, google } from "googleapis";
|
||||
import { decodeBase64, decodeBase64url, encodeBase64, encodeBase64url } from "@oslojs/encoding";
|
||||
import { type GoogleAuth } from "google-auth-library";
|
||||
import { type JSONClient } from "google-auth-library/build/src/auth/googleauth";
|
||||
import { type drive_v3, google } from "googleapis";
|
||||
import "server-only";
|
||||
|
||||
class EncryptionService {
|
||||
@@ -58,12 +58,16 @@ class EncryptionService {
|
||||
}
|
||||
}
|
||||
|
||||
const base64Encode = (text: string) => {
|
||||
type B64Type = "url" | "standard";
|
||||
export const base64Encode = (text: string, type: B64Type = "url") => {
|
||||
const data = new TextEncoder().encode(text);
|
||||
if (type === "standard") return encodeBase64(data);
|
||||
return encodeBase64url(data);
|
||||
};
|
||||
const base64Decode = <T = unknown>(encoded: string): T => {
|
||||
const decoded = decodeBase64url(encoded);
|
||||
export const base64Decode = <T = unknown>(encoded: string, type: B64Type = "url"): T => {
|
||||
let decoded: Uint8Array<ArrayBufferLike>;
|
||||
if (type === "standard") decoded = decodeBase64(encoded);
|
||||
else decoded = decodeBase64url(encoded);
|
||||
return new TextDecoder().decode(decoded) as T;
|
||||
};
|
||||
|
||||
@@ -106,7 +110,7 @@ class GoogleDriveService {
|
||||
version: "v3",
|
||||
auth: this.auth,
|
||||
fetchImplementation: (url, init) =>
|
||||
fetch(url, {
|
||||
fetch(url as string | URL, {
|
||||
...init,
|
||||
cache: "no-store",
|
||||
}),
|
||||
|
||||
+14
-7
@@ -1,8 +1,8 @@
|
||||
import { type ClassValue, clsx } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { z } from "zod";
|
||||
import { type z } from "zod";
|
||||
|
||||
import { Schema_Breadcrumb } from "~/types/schema";
|
||||
import { Schema_Breadcrumb, Schema_Config_Site } from "~/types/schema";
|
||||
|
||||
import config from "config";
|
||||
|
||||
@@ -10,19 +10,26 @@ export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
|
||||
export function formatFooterContent(text: string[]): string {
|
||||
export function formatFooterContent(
|
||||
text: { value: string }[],
|
||||
siteConfig?: z.infer<typeof Schema_Config_Site>,
|
||||
): string {
|
||||
const data = siteConfig ?? config.siteConfig;
|
||||
const formatMap = {
|
||||
year: new Date().getFullYear().toString(),
|
||||
repository: "[Source Code](https://github.com/mbaharip/next-gdrive-index)",
|
||||
poweredBy: `Powered by [next-gdrive-index v${config.version}](https://github.com/mbaharip/next-gdrive-index)`,
|
||||
author: config.siteConfig.siteAuthor ?? "mbaharip",
|
||||
author: data.siteAuthor ?? "mbaharip",
|
||||
version: config.version ?? "0.0.0",
|
||||
siteName: config.siteConfig.siteName ?? "next-gdrive-index",
|
||||
handle: config.siteConfig.twitterHandle ?? "@__mbaharip__",
|
||||
siteName: data.siteName ?? "next-gdrive-index",
|
||||
handle: data.twitterHandle ?? "@__mbaharip__",
|
||||
creator: "mbaharip",
|
||||
};
|
||||
|
||||
return text.join("\n").replace(/{{\s*(\w+)\s*}}/g, (_, key) => formatMap[key as keyof typeof formatMap] ?? "");
|
||||
return text
|
||||
.map((item) => item.value.trim())
|
||||
.join("\n")
|
||||
.replace(/{{\s*(\w+)\s*}}/g, (_, key) => formatMap[key as keyof typeof formatMap] ?? "");
|
||||
}
|
||||
|
||||
export function formatDate(date: string | number | Date, options?: Intl.DateTimeFormatOptions): string {
|
||||
|
||||
Reference in New Issue
Block a user