diff --git a/package.json b/package.json index 34d83a4..60054e4 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "postbuild": "next-sitemap", "start": "next start", "lint": "next lint", - "generate": "graphql-codegen --config graphql-codegen.js" + "generate": "graphql-codegen --config graphql-codegen.js", + "tsc": "tsc" }, "dependencies": { "@fontsource/material-icons": "^4.5.4", diff --git a/src/components/Img.tsx b/src/components/Img.tsx index e60a372..d62dee3 100644 --- a/src/components/Img.tsx +++ b/src/components/Img.tsx @@ -53,6 +53,16 @@ export enum ImageQuality { Og = "og", } +export function getAssetFilename(path: string): string { + let result = path.split("/"); + result = result[result.length - 1].split("."); + result = result + .splice(0, result.length - 1) + .join(".") + .split("_"); + return result[0]; +} + export function getAssetURL(url: string, quality: ImageQuality): string { let newUrl = url; newUrl = newUrl.replace(/^\/uploads/u, `/${quality}`); diff --git a/src/queries/helpers.ts b/src/queries/helpers.ts index 9e9897c..87da78b 100644 --- a/src/queries/helpers.ts +++ b/src/queries/helpers.ts @@ -443,3 +443,8 @@ export function getPreferredLanguage( } return undefined; } + +export function isInteger(value: string): boolean { + // eslint-disable-next-line require-unicode-regexp + return /^[+-]?[0-9]+$/.test(value); +} \ No newline at end of file