This commit is contained in:
Janis
2023-01-29 17:33:37 +01:00
parent 92ec33fea4
commit 0491b673aa
18 changed files with 600 additions and 156 deletions

View File

@@ -1,10 +1,12 @@
"use client";
import React from "react";
function AdminArticlesPage() {
return (
<div>
<h1>Page to manage articles</h1>
<a href="/admin/articles/create">create new article</a> <br />
<a href="/admin/articles/editor/0">create new article</a> <br />
<p>List of existing articles</p>
</div>
);

View File

@@ -1,9 +0,0 @@
import React from "react";
export default function AdminCategoriesCreate() {
return (
<div>
<h1>Create a new category</h1>
</div>
);
}

View File

@@ -0,0 +1,3 @@
export default async function Layout({ children }) {
return <div>{children}</div>;
}

View File

@@ -0,0 +1,180 @@
"use client";
import React, { useRef, useState } from "react";
import styles from "../../../../../styles/modules/CategoryEditor.module.scss";
import { Prisma } from "@prisma/client";
import "../../../../../styles/inputs.scss";
import "../../../../../styles/buttons.scss";
import { formatTextToUrlName } from "../../../../../utils";
import { isValidText } from "../../../../../validators";
import { CreateCategory, UpdateCategory } from "../../../../../types/api";
import urlJoin from "url-join";
import { useRouter } from "next/navigation";
import { useEffect } from "react";
import { apiUrl } from "../../../../global";
type CategoryWithSvg = Prisma.CategoryGetPayload<{ include: { svg: true } }>;
export default function CategoryEditor({ params }: { params: { categoryId: string } }) {
const router = useRouter();
const [title, setTitle] = useState<string>("");
const [color, setColor] = useState<string>("");
const [svgViewbox, setSvgViewbox] = useState<string>("");
const [svgPath, setSvgPath] = useState<string>("");
const titleRef = useRef(null);
const colorRef = useRef(null);
const svgViewboxRef = useRef(null);
const svgPathRef = useRef(null);
const errorTextRef = useRef(null);
function handleFormChange() {
setTitle(titleRef.current.value);
setColor(colorRef.current.value);
setSvgPath(svgPathRef.current.value);
setSvgViewbox(svgViewboxRef.current.value);
}
async function handleResponse(res: Response) {
const json = await res.json();
errorTextRef.current.innerText = json.error ?? "";
if (json.success) {
router.push(urlJoin(`/articles/`));
}
}
async function updateCategory() {
console.log("Update category");
const payload: UpdateCategory = {
id: params.categoryId,
title: titleRef.current.value,
color: colorRef.current.value,
svg: {
path: svgPathRef.current.value,
viewbox: svgViewboxRef.current.value,
},
};
console.log(payload);
await fetch("/api/categories/", {
method: "PUT",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
cache: "no-cache",
body: JSON.stringify(payload),
})
.then(handleResponse)
.catch(console.error);
}
async function createCategory() {
console.log("Create category");
const payload: CreateCategory = {
title: titleRef.current.value,
color: colorRef.current.value,
svg: {
path: svgPathRef.current.value,
viewbox: svgViewboxRef.current.value,
},
};
console.log(payload);
await fetch("/api/categories/", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
cache: "no-cache",
body: JSON.stringify(payload),
})
.then(handleResponse)
.catch(console.error);
}
useEffect(() => {
const fetchExistingCategory = async () => {
const result: Response = await fetch(urlJoin(apiUrl, `categories/${params.categoryId}`), {
cache: "no-cache",
});
const category = await result.json();
console.log(category);
if (category.code == "404") {
router.push(urlJoin(`/admin/categories/editor/0`));
} else {
titleRef.current.value = category.title;
colorRef.current.value = category.color;
svgPathRef.current.value = category.svg.path;
svgPathRef.current.value = category.svg.viewbox;
setTitle(category.title);
setColor(category.color);
setSvgPath(category.svg.path);
setSvgViewbox(category.svg.viewbox);
}
};
if (params.categoryId != "0") {
fetchExistingCategory().catch((err) => {
console.log(err);
});
}
}, []);
return (
<div className={styles.categoryEditor}>
<h1>{params.categoryId == "0" ? "Create new category" : "Update category"}</h1>
<div className={styles.formControl}>
<p className="text-error" ref={errorTextRef}></p>
<button
type="button"
onClick={() => {
if (params.categoryId != "0") {
updateCategory();
} else {
createCategory();
}
}}
>
{params.categoryId == "0" ? "Create category" : "Update category"}
</button>
</div>
<div className={styles.form}>
<div className={styles.title}>
<label htmlFor="title">Title</label>
<div className={styles.titleInputs}>
<input
onChange={handleFormChange}
className={!isValidText(title) && title ? "error" : ""}
type="text"
name="title"
placeholder="title"
ref={titleRef}
/>
<input
readOnly={true}
onChange={handleFormChange}
className={""}
type="text"
name="name"
value={title ? formatTextToUrlName(title) : ""}
/>
</div>
<div className={styles.svg}>
<label>SVG</label>
<div className={styles.svgInputs}>
<input onChange={handleFormChange} type="text" placeholder="svg path" ref={svgPathRef} />
<input onChange={handleFormChange} type="text" placeholder="0 0 512 512" ref={svgViewboxRef} />
</div>
</div>
<div className={styles.color}>
<label>Color</label>
<input onChange={handleFormChange} type="color" ref={colorRef} />
</div>
</div>
</div>
</div>
);
}

View File

@@ -4,7 +4,7 @@ export default function AdminCategoriesPage() {
return (
<div>
<h1>Page to manage categories</h1>
<a href="/admin/categories/create">create new category</a> <br />
<a href="/admin/categories/editor/0">create new category</a> <br />
<p>List of existing category</p>
</div>
);

View File

@@ -0,0 +1,26 @@
"use client";
import React, { useState } from "react";
import { Gallery as ReactGridGallery, Image as ImageType, ThumbnailImageProps } from "react-grid-gallery";
import Image from "next/image";
const ImageComponent = (props: ThumbnailImageProps) => {
const { src, alt, style, title } = props.imageProps;
const { width, height } = props.item;
return (
<Image
alt={alt}
src={src}
title={title || ""}
width={width}
height={height}
onClick={() => {
window.open(src);
}}
style={style}
/>
);
};
export default function Gallery({ images }: { images: ImageType[] }) {
return <ReactGridGallery images={images} enableImageSelection={false} thumbnailImageComponent={ImageComponent} />;
}

24
app/admin/images/page.tsx Normal file
View File

@@ -0,0 +1,24 @@
import React from "react";
import { Image } from "@prisma/client";
import { Image as GalleryImage } from "react-grid-gallery";
import urlJoin from "url-join";
import { apiUrl } from "../../global";
import Gallery from "./Gallery";
async function getImages(): Promise<GalleryImage[]> {
const result = await fetch(urlJoin(apiUrl, `images`), {
cache: "no-cache",
});
const imageData: Image[] = await result.json();
return imageData.map((img, i) => ({
width: img.width,
height: img.height,
src: img.url,
caption: img.name,
}));
}
export default async function page() {
return <Gallery images={await getImages()} />;
}

View File

@@ -35,7 +35,7 @@ async function GetRecentArticles(categoryName: string): Promise<any> {
}
async function GetCategory(categoryName: string): Promise<any> {
const result: Response = await fetch(urlJoin(apiUrl, `categories/${categoryName}`), {
const result: Response = await fetch(urlJoin(apiUrl, `categories/name/${categoryName}`), {
cache: "force-cache",
next: { revalidate: 3600 },
});

View File

@@ -9,6 +9,18 @@ const nextConfig = {
// Dangerously allow production builds to successfully complete even if your project has type errors.
ignoreBuildErrors: true,
},
images: {
remotePatterns: [
{
protocol: "https",
hostname: "c2.staticflickr.com",
},
{
protocol: "https",
hostname: "c4.staticflickr.com",
},
],
},
};
module.exports = nextConfig;

270
package-lock.json generated
View File

@@ -18,11 +18,13 @@
"eslint": "8.30.0",
"eslint-config-next": "13.0.7",
"marked": "^4.2.4",
"next": "^13.1.2-canary.2",
"next": "^13.1.6",
"next-gallery": "^1.1.0",
"prismjs": "^1.29.0",
"react": "18.2.0",
"react-code-blocks": "^0.0.9-0",
"react-dom": "18.2.0",
"react-grid-gallery": "^1.0.0",
"react-markdown": "^8.0.4",
"react-select": "^5.7.0",
"react-syntax-highlighter": "^15.5.0",
@@ -826,9 +828,9 @@
}
},
"node_modules/@next/env": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.1.2-canary.2.tgz",
"integrity": "sha512-NwEU6a4UDWdn/Pv+NiTzi22LSYWFElTBBNXQ1LlemtgJWVnrA6ZVMomzUfCYEgaQgAqqjFfJzW0qUiOuqM6mEA=="
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.1.6.tgz",
"integrity": "sha512-s+W9Fdqh5MFk6ECrbnVmmAOwxKQuhGMT7xXHrkYIBMBcTiOqNWhv5KbJIboKR5STXxNXl32hllnvKaffzFaWQg=="
},
"node_modules/@next/eslint-plugin-next": {
"version": "13.0.7",
@@ -844,9 +846,9 @@
"integrity": "sha512-39SzuoMI6jbrIzPs3KtXdKX03OrVp6Y7kRHcoVmOg69spiBzruPJ5x5DQSfN+OXqznbvVBNZBXnmdnSqs3qXiA=="
},
"node_modules/@next/swc-android-arm-eabi": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.1.2-canary.2.tgz",
"integrity": "sha512-gA83d7XQbRvFFkLjXTAgyp75VLdvZ+47RrXhXA7LYsh74Nk44A/sLTWfcnqN2uTQLZPdygQygGi3IUOpdlTRmw==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.1.6.tgz",
"integrity": "sha512-F3/6Z8LH/pGlPzR1AcjPFxx35mPqjE5xZcf+IL+KgbW9tMkp7CYi1y7qKrEWU7W4AumxX/8OINnDQWLiwLasLQ==",
"cpu": [
"arm"
],
@@ -859,9 +861,9 @@
}
},
"node_modules/@next/swc-android-arm64": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.1.2-canary.2.tgz",
"integrity": "sha512-hVfiIysPeK/XaUsod3l9+aePFQhJN5PZ5c8jjEMymyEKSn2Ssc/Nyqta2rKi3dnoE88R9BNG2wfAzbNAIfL0tQ==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.1.6.tgz",
"integrity": "sha512-cMwQjnB8vrYkWyK/H0Rf2c2pKIH4RGjpKUDvbjVAit6SbwPDpmaijLio0LWFV3/tOnY6kvzbL62lndVA0mkYpw==",
"cpu": [
"arm64"
],
@@ -874,9 +876,9 @@
}
},
"node_modules/@next/swc-darwin-arm64": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.1.2-canary.2.tgz",
"integrity": "sha512-3b9kUfPOz9zHOqcju2ttdWnB9xIJOfwWurpKY5mscdXkY6qykoT0CGOxT8NNaRmvW/48fwfPOFRdlkWOG4rlEg==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.1.6.tgz",
"integrity": "sha512-KKRQH4DDE4kONXCvFMNBZGDb499Hs+xcFAwvj+rfSUssIDrZOlyfJNy55rH5t2Qxed1e4K80KEJgsxKQN1/fyw==",
"cpu": [
"arm64"
],
@@ -889,9 +891,9 @@
}
},
"node_modules/@next/swc-darwin-x64": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.1.2-canary.2.tgz",
"integrity": "sha512-SK3H8cD77InkUOCWv0sWu4gvZ5UvPekiluTGo2g82AHyDn1e64jirQ1UHkPGni0zZ9Rud5SAMGLRgilToY42lg==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.1.6.tgz",
"integrity": "sha512-/uOky5PaZDoaU99ohjtNcDTJ6ks/gZ5ykTQDvNZDjIoCxFe3+t06bxsTPY6tAO6uEAw5f6vVFX5H5KLwhrkZCA==",
"cpu": [
"x64"
],
@@ -904,9 +906,9 @@
}
},
"node_modules/@next/swc-freebsd-x64": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.1.2-canary.2.tgz",
"integrity": "sha512-OdZkrvTVdzEOb2/CfoZkJWalnmifkqte+KdHdfP9Xm0DPKkeYJQCZv3p3d82h2Z/A+MLeFsD5Mh8EfELvW6oEw==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.1.6.tgz",
"integrity": "sha512-qaEALZeV7to6weSXk3Br80wtFQ7cFTpos/q+m9XVRFggu+8Ib895XhMWdJBzew6aaOcMvYR6KQ6JmHA2/eMzWw==",
"cpu": [
"x64"
],
@@ -919,9 +921,9 @@
}
},
"node_modules/@next/swc-linux-arm-gnueabihf": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.1.2-canary.2.tgz",
"integrity": "sha512-yYat5/WIU0s1g9+wmWZsTXnbPdDwt8BFG625iC//ZLDC6v4OlnuYWOsBMBrGxU3EbRF0p8TWbq6ug/eiLnRBXg==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.1.6.tgz",
"integrity": "sha512-OybkbC58A1wJ+JrJSOjGDvZzrVEQA4sprJejGqMwiZyLqhr9Eo8FXF0y6HL+m1CPCpPhXEHz/2xKoYsl16kNqw==",
"cpu": [
"arm"
],
@@ -934,9 +936,9 @@
}
},
"node_modules/@next/swc-linux-arm64-gnu": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.1.2-canary.2.tgz",
"integrity": "sha512-8TaScu2XT7836Sx1Y7Ll91wWL4QgcYhwAUu69WaG5AMRru7TRhOcDmJ0W/BirL5neNzIVOyNwFPP30uJFoJpYA==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.1.6.tgz",
"integrity": "sha512-yCH+yDr7/4FDuWv6+GiYrPI9kcTAO3y48UmaIbrKy8ZJpi7RehJe3vIBRUmLrLaNDH3rY1rwoHi471NvR5J5NQ==",
"cpu": [
"arm64"
],
@@ -949,9 +951,9 @@
}
},
"node_modules/@next/swc-linux-arm64-musl": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.1.2-canary.2.tgz",
"integrity": "sha512-2hreQre3hGSTfCqdYIZryuOMtgjb6D6JO60kG/QwxdJbE7rHajeprRpVmc49SK9DgeiSOmCA1c46AtadPzEX/A==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.1.6.tgz",
"integrity": "sha512-ECagB8LGX25P9Mrmlc7Q/TQBb9rGScxHbv/kLqqIWs2fIXy6Y/EiBBiM72NTwuXUFCNrWR4sjUPSooVBJJ3ESQ==",
"cpu": [
"arm64"
],
@@ -964,9 +966,9 @@
}
},
"node_modules/@next/swc-linux-x64-gnu": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.1.2-canary.2.tgz",
"integrity": "sha512-5qSVX6gO6iCMbQgaRrtior8OeRPnzbok42OLnMcQ+RWrhup457v4hMukR80itbjtvRs0uaWrf74kbrrWLQtiWQ==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.1.6.tgz",
"integrity": "sha512-GT5w2mruk90V/I5g6ScuueE7fqj/d8Bui2qxdw6lFxmuTgMeol5rnzAv4uAoVQgClOUO/MULilzlODg9Ib3Y4Q==",
"cpu": [
"x64"
],
@@ -979,9 +981,9 @@
}
},
"node_modules/@next/swc-linux-x64-musl": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.1.2-canary.2.tgz",
"integrity": "sha512-kqMNGkRfmacCUpbKjvyjzpm8LEZVGt1YptAs4RfJoDSbf6vUS9DPq8WkGzEdnBNR9rvmmXQ4/ob7dJmHYqTVMQ==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.1.6.tgz",
"integrity": "sha512-keFD6KvwOPzmat4TCnlnuxJCQepPN+8j3Nw876FtULxo8005Y9Ghcl7ACcR8GoiKoddAq8gxNBrpjoxjQRHeAQ==",
"cpu": [
"x64"
],
@@ -994,9 +996,9 @@
}
},
"node_modules/@next/swc-win32-arm64-msvc": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.1.2-canary.2.tgz",
"integrity": "sha512-QDzxsHkVlaFeDFhXdvWsrQ1fXH9eBH2ARQIWVu66I9y5zuDILiRbF2g3vhHZsdknFmGdM/rLPNq+I3kstJIdAA==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.1.6.tgz",
"integrity": "sha512-OwertslIiGQluFvHyRDzBCIB07qJjqabAmINlXUYt7/sY7Q7QPE8xVi5beBxX/rxTGPIbtyIe3faBE6Z2KywhQ==",
"cpu": [
"arm64"
],
@@ -1009,9 +1011,9 @@
}
},
"node_modules/@next/swc-win32-ia32-msvc": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.1.2-canary.2.tgz",
"integrity": "sha512-TgCuPsr+lQZPPID7jQfYFJ20gwbun7hSZcnVSZGDeQit+qiNPo34yNZfQo3GJXp9OVlKuWXkBrCgF5CZmabXhA==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.1.6.tgz",
"integrity": "sha512-g8zowiuP8FxUR9zslPmlju7qYbs2XBtTLVSxVikPtUDQedhcls39uKYLvOOd1JZg0ehyhopobRoH1q+MHlIN/w==",
"cpu": [
"ia32"
],
@@ -1024,9 +1026,9 @@
}
},
"node_modules/@next/swc-win32-x64-msvc": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.1.2-canary.2.tgz",
"integrity": "sha512-D44GRY2qonWr//Ecd43ZsaZzTUeBrFBUudBYYPfd+KkL+Jav5Y6xSOnqrr6dqciBAeEG1clBd6XkPcxcHhlUrw==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.1.6.tgz",
"integrity": "sha512-Ls2OL9hi3YlJKGNdKv8k3X/lLgc3VmLG3a/DeTkAd+lAituJp8ZHmRmm9f9SL84fT3CotlzcgbdaCDfFwFA6bA==",
"cpu": [
"x64"
],
@@ -6163,11 +6165,11 @@
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw=="
},
"node_modules/next": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/next/-/next-13.1.2-canary.2.tgz",
"integrity": "sha512-yL13fpqAHL9EWu36l595DnywLIiKQKvf1lnOEl07coan/OgM35SkNbOoP/KyWass/zfPg9/nk8pArHvmgJw6ag==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/next/-/next-13.1.6.tgz",
"integrity": "sha512-hHlbhKPj9pW+Cymvfzc15lvhaOZ54l+8sXDXJWm3OBNBzgrVj6hwGPmqqsXg40xO1Leq+kXpllzRPuncpC0Phw==",
"dependencies": {
"@next/env": "13.1.2-canary.2",
"@next/env": "13.1.6",
"@swc/helpers": "0.4.14",
"caniuse-lite": "^1.0.30001406",
"postcss": "8.4.14",
@@ -6180,19 +6182,19 @@
"node": ">=14.6.0"
},
"optionalDependencies": {
"@next/swc-android-arm-eabi": "13.1.2-canary.2",
"@next/swc-android-arm64": "13.1.2-canary.2",
"@next/swc-darwin-arm64": "13.1.2-canary.2",
"@next/swc-darwin-x64": "13.1.2-canary.2",
"@next/swc-freebsd-x64": "13.1.2-canary.2",
"@next/swc-linux-arm-gnueabihf": "13.1.2-canary.2",
"@next/swc-linux-arm64-gnu": "13.1.2-canary.2",
"@next/swc-linux-arm64-musl": "13.1.2-canary.2",
"@next/swc-linux-x64-gnu": "13.1.2-canary.2",
"@next/swc-linux-x64-musl": "13.1.2-canary.2",
"@next/swc-win32-arm64-msvc": "13.1.2-canary.2",
"@next/swc-win32-ia32-msvc": "13.1.2-canary.2",
"@next/swc-win32-x64-msvc": "13.1.2-canary.2"
"@next/swc-android-arm-eabi": "13.1.6",
"@next/swc-android-arm64": "13.1.6",
"@next/swc-darwin-arm64": "13.1.6",
"@next/swc-darwin-x64": "13.1.6",
"@next/swc-freebsd-x64": "13.1.6",
"@next/swc-linux-arm-gnueabihf": "13.1.6",
"@next/swc-linux-arm64-gnu": "13.1.6",
"@next/swc-linux-arm64-musl": "13.1.6",
"@next/swc-linux-x64-gnu": "13.1.6",
"@next/swc-linux-x64-musl": "13.1.6",
"@next/swc-win32-arm64-msvc": "13.1.6",
"@next/swc-win32-ia32-msvc": "13.1.6",
"@next/swc-win32-x64-msvc": "13.1.6"
},
"peerDependencies": {
"fibers": ">= 3.1.0",
@@ -6213,6 +6215,16 @@
}
}
},
"node_modules/next-gallery": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/next-gallery/-/next-gallery-1.1.0.tgz",
"integrity": "sha512-jwb3eUDUWSaMUawn1ZtDB0jmI8sCGCFasl5gkcvhs2Q3VZXW9tLddmceqTr4uiyjd1559NhiWgHe7W+DuuimVA==",
"peerDependencies": {
"next": ">= 13.1.1",
"react": ">= 17.0.2",
"react-dom": ">= 17.0.2"
}
},
"node_modules/next/node_modules/postcss": {
"version": "8.4.14",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz",
@@ -7180,6 +7192,14 @@
"react": "^18.2.0"
}
},
"node_modules/react-grid-gallery": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/react-grid-gallery/-/react-grid-gallery-1.0.0.tgz",
"integrity": "sha512-S1gr6WXBlPFVrE0x2BHuu7jhyaB61mabcMQyx+8KCgAyKzGza0WF67AfAnS9Q00aurFEq4IP8eqb2Bk5F4RAmQ==",
"peerDependencies": {
"react": ">=16.14.0"
}
},
"node_modules/react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
@@ -9664,9 +9684,9 @@
}
},
"@next/env": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.1.2-canary.2.tgz",
"integrity": "sha512-NwEU6a4UDWdn/Pv+NiTzi22LSYWFElTBBNXQ1LlemtgJWVnrA6ZVMomzUfCYEgaQgAqqjFfJzW0qUiOuqM6mEA=="
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.1.6.tgz",
"integrity": "sha512-s+W9Fdqh5MFk6ECrbnVmmAOwxKQuhGMT7xXHrkYIBMBcTiOqNWhv5KbJIboKR5STXxNXl32hllnvKaffzFaWQg=="
},
"@next/eslint-plugin-next": {
"version": "13.0.7",
@@ -9682,81 +9702,81 @@
"integrity": "sha512-39SzuoMI6jbrIzPs3KtXdKX03OrVp6Y7kRHcoVmOg69spiBzruPJ5x5DQSfN+OXqznbvVBNZBXnmdnSqs3qXiA=="
},
"@next/swc-android-arm-eabi": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.1.2-canary.2.tgz",
"integrity": "sha512-gA83d7XQbRvFFkLjXTAgyp75VLdvZ+47RrXhXA7LYsh74Nk44A/sLTWfcnqN2uTQLZPdygQygGi3IUOpdlTRmw==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.1.6.tgz",
"integrity": "sha512-F3/6Z8LH/pGlPzR1AcjPFxx35mPqjE5xZcf+IL+KgbW9tMkp7CYi1y7qKrEWU7W4AumxX/8OINnDQWLiwLasLQ==",
"optional": true
},
"@next/swc-android-arm64": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.1.2-canary.2.tgz",
"integrity": "sha512-hVfiIysPeK/XaUsod3l9+aePFQhJN5PZ5c8jjEMymyEKSn2Ssc/Nyqta2rKi3dnoE88R9BNG2wfAzbNAIfL0tQ==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.1.6.tgz",
"integrity": "sha512-cMwQjnB8vrYkWyK/H0Rf2c2pKIH4RGjpKUDvbjVAit6SbwPDpmaijLio0LWFV3/tOnY6kvzbL62lndVA0mkYpw==",
"optional": true
},
"@next/swc-darwin-arm64": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.1.2-canary.2.tgz",
"integrity": "sha512-3b9kUfPOz9zHOqcju2ttdWnB9xIJOfwWurpKY5mscdXkY6qykoT0CGOxT8NNaRmvW/48fwfPOFRdlkWOG4rlEg==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.1.6.tgz",
"integrity": "sha512-KKRQH4DDE4kONXCvFMNBZGDb499Hs+xcFAwvj+rfSUssIDrZOlyfJNy55rH5t2Qxed1e4K80KEJgsxKQN1/fyw==",
"optional": true
},
"@next/swc-darwin-x64": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.1.2-canary.2.tgz",
"integrity": "sha512-SK3H8cD77InkUOCWv0sWu4gvZ5UvPekiluTGo2g82AHyDn1e64jirQ1UHkPGni0zZ9Rud5SAMGLRgilToY42lg==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.1.6.tgz",
"integrity": "sha512-/uOky5PaZDoaU99ohjtNcDTJ6ks/gZ5ykTQDvNZDjIoCxFe3+t06bxsTPY6tAO6uEAw5f6vVFX5H5KLwhrkZCA==",
"optional": true
},
"@next/swc-freebsd-x64": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.1.2-canary.2.tgz",
"integrity": "sha512-OdZkrvTVdzEOb2/CfoZkJWalnmifkqte+KdHdfP9Xm0DPKkeYJQCZv3p3d82h2Z/A+MLeFsD5Mh8EfELvW6oEw==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.1.6.tgz",
"integrity": "sha512-qaEALZeV7to6weSXk3Br80wtFQ7cFTpos/q+m9XVRFggu+8Ib895XhMWdJBzew6aaOcMvYR6KQ6JmHA2/eMzWw==",
"optional": true
},
"@next/swc-linux-arm-gnueabihf": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.1.2-canary.2.tgz",
"integrity": "sha512-yYat5/WIU0s1g9+wmWZsTXnbPdDwt8BFG625iC//ZLDC6v4OlnuYWOsBMBrGxU3EbRF0p8TWbq6ug/eiLnRBXg==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.1.6.tgz",
"integrity": "sha512-OybkbC58A1wJ+JrJSOjGDvZzrVEQA4sprJejGqMwiZyLqhr9Eo8FXF0y6HL+m1CPCpPhXEHz/2xKoYsl16kNqw==",
"optional": true
},
"@next/swc-linux-arm64-gnu": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.1.2-canary.2.tgz",
"integrity": "sha512-8TaScu2XT7836Sx1Y7Ll91wWL4QgcYhwAUu69WaG5AMRru7TRhOcDmJ0W/BirL5neNzIVOyNwFPP30uJFoJpYA==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.1.6.tgz",
"integrity": "sha512-yCH+yDr7/4FDuWv6+GiYrPI9kcTAO3y48UmaIbrKy8ZJpi7RehJe3vIBRUmLrLaNDH3rY1rwoHi471NvR5J5NQ==",
"optional": true
},
"@next/swc-linux-arm64-musl": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.1.2-canary.2.tgz",
"integrity": "sha512-2hreQre3hGSTfCqdYIZryuOMtgjb6D6JO60kG/QwxdJbE7rHajeprRpVmc49SK9DgeiSOmCA1c46AtadPzEX/A==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.1.6.tgz",
"integrity": "sha512-ECagB8LGX25P9Mrmlc7Q/TQBb9rGScxHbv/kLqqIWs2fIXy6Y/EiBBiM72NTwuXUFCNrWR4sjUPSooVBJJ3ESQ==",
"optional": true
},
"@next/swc-linux-x64-gnu": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.1.2-canary.2.tgz",
"integrity": "sha512-5qSVX6gO6iCMbQgaRrtior8OeRPnzbok42OLnMcQ+RWrhup457v4hMukR80itbjtvRs0uaWrf74kbrrWLQtiWQ==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.1.6.tgz",
"integrity": "sha512-GT5w2mruk90V/I5g6ScuueE7fqj/d8Bui2qxdw6lFxmuTgMeol5rnzAv4uAoVQgClOUO/MULilzlODg9Ib3Y4Q==",
"optional": true
},
"@next/swc-linux-x64-musl": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.1.2-canary.2.tgz",
"integrity": "sha512-kqMNGkRfmacCUpbKjvyjzpm8LEZVGt1YptAs4RfJoDSbf6vUS9DPq8WkGzEdnBNR9rvmmXQ4/ob7dJmHYqTVMQ==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.1.6.tgz",
"integrity": "sha512-keFD6KvwOPzmat4TCnlnuxJCQepPN+8j3Nw876FtULxo8005Y9Ghcl7ACcR8GoiKoddAq8gxNBrpjoxjQRHeAQ==",
"optional": true
},
"@next/swc-win32-arm64-msvc": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.1.2-canary.2.tgz",
"integrity": "sha512-QDzxsHkVlaFeDFhXdvWsrQ1fXH9eBH2ARQIWVu66I9y5zuDILiRbF2g3vhHZsdknFmGdM/rLPNq+I3kstJIdAA==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.1.6.tgz",
"integrity": "sha512-OwertslIiGQluFvHyRDzBCIB07qJjqabAmINlXUYt7/sY7Q7QPE8xVi5beBxX/rxTGPIbtyIe3faBE6Z2KywhQ==",
"optional": true
},
"@next/swc-win32-ia32-msvc": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.1.2-canary.2.tgz",
"integrity": "sha512-TgCuPsr+lQZPPID7jQfYFJ20gwbun7hSZcnVSZGDeQit+qiNPo34yNZfQo3GJXp9OVlKuWXkBrCgF5CZmabXhA==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.1.6.tgz",
"integrity": "sha512-g8zowiuP8FxUR9zslPmlju7qYbs2XBtTLVSxVikPtUDQedhcls39uKYLvOOd1JZg0ehyhopobRoH1q+MHlIN/w==",
"optional": true
},
"@next/swc-win32-x64-msvc": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.1.2-canary.2.tgz",
"integrity": "sha512-D44GRY2qonWr//Ecd43ZsaZzTUeBrFBUudBYYPfd+KkL+Jav5Y6xSOnqrr6dqciBAeEG1clBd6XkPcxcHhlUrw==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.1.6.tgz",
"integrity": "sha512-Ls2OL9hi3YlJKGNdKv8k3X/lLgc3VmLG3a/DeTkAd+lAituJp8ZHmRmm9f9SL84fT3CotlzcgbdaCDfFwFA6bA==",
"optional": true
},
"@nodelib/fs.scandir": {
@@ -13536,24 +13556,24 @@
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw=="
},
"next": {
"version": "13.1.2-canary.2",
"resolved": "https://registry.npmjs.org/next/-/next-13.1.2-canary.2.tgz",
"integrity": "sha512-yL13fpqAHL9EWu36l595DnywLIiKQKvf1lnOEl07coan/OgM35SkNbOoP/KyWass/zfPg9/nk8pArHvmgJw6ag==",
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/next/-/next-13.1.6.tgz",
"integrity": "sha512-hHlbhKPj9pW+Cymvfzc15lvhaOZ54l+8sXDXJWm3OBNBzgrVj6hwGPmqqsXg40xO1Leq+kXpllzRPuncpC0Phw==",
"requires": {
"@next/env": "13.1.2-canary.2",
"@next/swc-android-arm-eabi": "13.1.2-canary.2",
"@next/swc-android-arm64": "13.1.2-canary.2",
"@next/swc-darwin-arm64": "13.1.2-canary.2",
"@next/swc-darwin-x64": "13.1.2-canary.2",
"@next/swc-freebsd-x64": "13.1.2-canary.2",
"@next/swc-linux-arm-gnueabihf": "13.1.2-canary.2",
"@next/swc-linux-arm64-gnu": "13.1.2-canary.2",
"@next/swc-linux-arm64-musl": "13.1.2-canary.2",
"@next/swc-linux-x64-gnu": "13.1.2-canary.2",
"@next/swc-linux-x64-musl": "13.1.2-canary.2",
"@next/swc-win32-arm64-msvc": "13.1.2-canary.2",
"@next/swc-win32-ia32-msvc": "13.1.2-canary.2",
"@next/swc-win32-x64-msvc": "13.1.2-canary.2",
"@next/env": "13.1.6",
"@next/swc-android-arm-eabi": "13.1.6",
"@next/swc-android-arm64": "13.1.6",
"@next/swc-darwin-arm64": "13.1.6",
"@next/swc-darwin-x64": "13.1.6",
"@next/swc-freebsd-x64": "13.1.6",
"@next/swc-linux-arm-gnueabihf": "13.1.6",
"@next/swc-linux-arm64-gnu": "13.1.6",
"@next/swc-linux-arm64-musl": "13.1.6",
"@next/swc-linux-x64-gnu": "13.1.6",
"@next/swc-linux-x64-musl": "13.1.6",
"@next/swc-win32-arm64-msvc": "13.1.6",
"@next/swc-win32-ia32-msvc": "13.1.6",
"@next/swc-win32-x64-msvc": "13.1.6",
"@swc/helpers": "0.4.14",
"caniuse-lite": "^1.0.30001406",
"postcss": "8.4.14",
@@ -13572,6 +13592,12 @@
}
}
},
"next-gallery": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/next-gallery/-/next-gallery-1.1.0.tgz",
"integrity": "sha512-jwb3eUDUWSaMUawn1ZtDB0jmI8sCGCFasl5gkcvhs2Q3VZXW9tLddmceqTr4uiyjd1559NhiWgHe7W+DuuimVA==",
"requires": {}
},
"node-emoji": {
"version": "1.11.0",
"resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.11.0.tgz",
@@ -14304,6 +14330,12 @@
"scheduler": "^0.23.0"
}
},
"react-grid-gallery": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/react-grid-gallery/-/react-grid-gallery-1.0.0.tgz",
"integrity": "sha512-S1gr6WXBlPFVrE0x2BHuu7jhyaB61mabcMQyx+8KCgAyKzGza0WF67AfAnS9Q00aurFEq4IP8eqb2Bk5F4RAmQ==",
"requires": {}
},
"react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",

View File

@@ -22,11 +22,13 @@
"eslint": "8.30.0",
"eslint-config-next": "13.0.7",
"marked": "^4.2.4",
"next": "^13.1.2-canary.2",
"next": "^13.1.6",
"next-gallery": "^1.1.0",
"prismjs": "^1.29.0",
"react": "18.2.0",
"react-code-blocks": "^0.0.9-0",
"react-dom": "18.2.0",
"react-grid-gallery": "^1.0.0",
"react-markdown": "^8.0.4",
"react-select": "^5.7.0",
"react-syntax-highlighter": "^15.5.0",

View File

@@ -0,0 +1,31 @@
import { Request, Response } from "express";
import prisma from "../../../lib/prisma";
import { Category } from "@prisma/client";
import { ResponseError } from "../../../types/responseErrors";
export default async function handler(req: Request, res: Response) {
res.setHeader("Content-Type", "application/json");
const categoryId: string = req.query.categoryId.toString() ?? undefined;
await prisma.category
.findUnique({ where: { id: categoryId }, include: { svg: true } })
.then((result: Category) => {
if (result !== null) {
res.end(JSON.stringify(result));
} else {
const error: ResponseError = {
code: "404",
message: "No category with this id found!",
};
res.status(404).send(JSON.stringify(error));
}
})
.catch((err) => {
const error: ResponseError = {
code: "500",
message: err,
};
res.status(500).send(JSON.stringify(error));
});
}

View File

@@ -1,23 +1,129 @@
import { Request, Response } from "express";
import prisma from "../../../lib/prisma";
import { Category } from "@prisma/client";
import { Prisma } from "@prisma/client";
import { Category, Svg } from "@prisma/client";
import { ResponseError } from "../../../types/responseErrors";
import { formatTextToUrlName } from "../../../utils";
import { isValidText } from "../../../validators";
import { title } from "process";
export default async function handler(req: Request, res: Response) {
res.setHeader("Content-Type", "application/json");
await prisma.category
.findMany({ include: { svg: true } })
.then((result: Category[]) => {
if (result !== null) {
res.end(JSON.stringify(result));
} else {
console.log("No categories found");
if (req.method == "GET") {
await prisma.category
.findMany({ include: { svg: true } })
.then((result: Category[]) => {
if (result !== null) {
res.end(JSON.stringify(result));
} else {
console.log("No categories found");
res.end(JSON.stringify([]));
}
})
.catch((err) => {
console.log(err);
res.end(JSON.stringify([]));
}
})
.catch((err) => {
console.log(err);
res.end(JSON.stringify([]));
});
});
} else if (req.method == "POST") {
const data: any = req.body;
if (!isValidText(data.title)) {
res.send(JSON.stringify({ target: "title", error: "Not a valid title" }));
return;
}
data.name = formatTextToUrlName(data.title);
data.svg.viewbox = data.svg.viewbox.length > 1 ? data.svg.viewbox : null;
console.log(data);
await prisma.svg
.create({ data: data.svg })
.then(
async (svgData) => {
await prisma.category
.create({
data: { title: data.title, name: data.name, color: data.name, svgId: svgData.id },
include: { svg: true },
})
.then(
(data) => {
res.send(JSON.stringify({ success: true, data: data }));
},
(errorReason) => {
if (errorReason.code === "P2002") {
res.send(JSON.stringify({ target: errorReason.meta.target[0], error: "Already exists" }));
}
}
)
.catch((err) => {
console.error(err);
res.sendStatus(500).end();
});
},
(errorReason) => {
res.sendStatus(500).end(errorReason);
}
)
.catch((err) => {
console.error(err);
res.sendStatus(500).end();
});
} else if (req.method == "PUT") {
const data: any = req.body;
if (!isValidText(data.title)) {
res.send(JSON.stringify({ target: "title", error: "Not a valid title" }));
return;
}
data.name = formatTextToUrlName(data.title);
console.log(data);
const newSvg: Prisma.SvgUncheckedUpdateInput = {
viewbox: data.svg.viewbox,
path: data.svg.path,
};
const newCategory: Prisma.CategoryUncheckedUpdateInput = {
title: data.title,
name: data.name,
color: data.color,
};
await prisma.category
.update({
data: newCategory,
where: { id: data.id },
include: { svg: true },
})
.then(
async (categoryData) => {
console.log("2");
await prisma.svg
.update({ data: newSvg, where: { id: categoryData.svg.id } })
.then(
(svgData) => {
console.log("3");
res.send(JSON.stringify({ success: true, data: categoryData }));
},
(errorReason) => {
res.sendStatus(500).end(errorReason);
}
)
.catch((err) => {
console.error(err);
res.sendStatus(500).end();
});
},
(errorReason) => {
console.log(errorReason);
if (errorReason.code === "P2002") {
res.send(JSON.stringify({ target: errorReason.meta.target[0], error: "Already exists" }));
}
}
)
.catch((err) => {
console.error(err);
res.sendStatus(500).end();
});
}
}

View File

@@ -1,7 +1,9 @@
import { Request, Response } from "express";
import prisma from "../../../lib/prisma";
import { Category } from "@prisma/client";
import { ResponseError } from "../../../types/responseErrors";
import prisma from "../../../../lib/prisma";
import { ResponseError } from "../../../../types/responseErrors";
export default async function handler(req: Request, res: Response) {
res.setHeader("Content-Type", "application/json");

11
pages/api/images/index.ts Normal file
View File

@@ -0,0 +1,11 @@
import { Request, Response } from "express";
import prisma from "../../../lib/prisma";
import { Prisma } from "@prisma/client";
export default async function handler(req: Request, res: Response) {
res.setHeader("Content-Type", "application/json");
if (req.method == "GET") {
res.send(await prisma.image.findMany())
}
}

View File

@@ -12,22 +12,22 @@ model Article {
name String @unique
title String @unique
introduction String @default("")
imageId Int?
imageId String?
image Image? @relation(fields: [imageId], references: [id])
markdown String
contentTable Json?
categoryId Int
categoryId String
category Category @relation(fields: [categoryId], references: [id])
dateCreated DateTime @default(now())
dateUpdated DateTime @default(now())
}
model Category {
id Int @id @default(autoincrement())
id String @id @default(uuid())
name String @unique
title String @unique
color String @unique
svgId Int
color String
svgId String
svg Svg @relation(fields: [svgId], references: [id])
Article Article[]
dateCreated DateTime @default(now())
@@ -35,17 +35,18 @@ model Category {
}
model Image {
id Int @id @default(autoincrement())
id String @id @default(uuid())
name String @unique
alt String @default("")
url String @default("")
width Int
height Int
dateCreated DateTime @default(now())
Article Article[]
}
model Svg {
id Int @id @default(autoincrement())
name String @unique
id String @id @default(uuid())
path String @default("")
viewbox String @default("0 0 512 512")
Category Category[]

View File

@@ -0,0 +1,2 @@
.categoryEditor {
}

View File

@@ -19,3 +19,22 @@ export interface UpdateArticle {
contentTable?: Prisma.JsonArray
imageId?: number;
}
export interface CreateCategory {
title: string;
svg: {
path: string;
viewbox: string;
}
color: string;
}
export interface UpdateCategory {
id: string;
title?: string;
svg?: {
path?: string;
viewbox?: string;
}
color?: string;
}