Post Management
diff --git a/src/components/server/admin/views/sidebar.tsx b/src/components/server/admin/views/sidebar.tsx
index 64f5956..a632bad 100644
--- a/src/components/server/admin/views/sidebar.tsx
+++ b/src/components/server/admin/views/sidebar.tsx
@@ -1,13 +1,15 @@
import './sidebar.css'
import { Button, NavLink } from 'react-bootstrap';
-import { SidebarEntry } from '@/app/admin/page';
import React, { ReactNode, useState } from 'react';
import Link from 'next/link';
import { headers } from 'next/headers';
-
+export type SidebarEntry = {
+ label:string;
+ view:string;
+ }
type Props = {
children?:ReactNode;
diff --git a/src/components/shared/news/article.tsx b/src/components/shared/news/article.tsx
index 829a832..dc31b0d 100644
--- a/src/components/shared/news/article.tsx
+++ b/src/components/shared/news/article.tsx
@@ -1,17 +1,42 @@
+
import Tagbar from "@/components/shared/news/tagbar";
import "/public/global.css"
import "@/app/index.css"
import styles from "./article.module.css"
+import { serialize } from 'next-mdx-remote/serialize'
+import { MDXComponents, MDXContent } from "mdx/types";
+import { MDXRemote } from 'next-mdx-remote/rsc'
-export default function Article(params: { id: string|undefined, title: string|undefined, content: string|undefined, date?:string|undefined } ) {
+export async function ExampleComponent(){
+ return (
+
aaa
+ )
+}
+
+export default async function Article(params: { id: string|undefined, title: string|undefined, content: string|undefined, date?:string|undefined } ) {
+
+
+ const components = { ExampleComponent }
+
return (
{params.title}
- {params.content}
+
+
+
);
-}
\ No newline at end of file
+}
+
+// export const getStaticProps: GetStaticProps<{
+// mdxSource: MDXRemoteSerializeResult
+// }> = async () => {
+// const mdxSource = await serialize('some *mdx* content:
')
+// return { props: { mdxSource } }
+// }
diff --git a/src/mdx-components.tsx b/src/mdx-components.tsx
new file mode 100644
index 0000000..cf1adda
--- /dev/null
+++ b/src/mdx-components.tsx
@@ -0,0 +1,7 @@
+import type { MDXComponents } from 'mdx/types'
+
+export function useMDXComponents(components: MDXComponents): MDXComponents {
+ return {
+ ...components,
+ }
+}
\ No newline at end of file
diff --git a/src/model/Attachment.ts b/src/model/Attachment.ts
new file mode 100644
index 0000000..79627a8
--- /dev/null
+++ b/src/model/Attachment.ts
@@ -0,0 +1,31 @@
+import { Association, BelongsToGetAssociationMixin, BelongsToManyGetAssociationsMixin, DataTypes, ForeignKey, InferAttributes, InferCreationAttributes, Model, NonAttribute, Sequelize } from "@sequelize/core";
+import { Post } from "./Post";
+
+import { SqliteDialect } from '@sequelize/sqlite3';
+import { Attribute, AutoIncrement, BelongsTo, BelongsToMany, NotNull, PrimaryKey, Unique } from "@sequelize/core/decorators-legacy";
+
+export class Attachment extends Model
, InferCreationAttributes> {
+ @PrimaryKey
+ @AutoIncrement
+ @Attribute(DataTypes.INTEGER)
+ @Unique
+ declare id: number;
+ @Attribute(DataTypes.STRING)
+ declare path: string
+
+ // Associations
+ @Attribute(DataTypes.INTEGER)
+ @NotNull
+ declare postid: number;
+ @BelongsTo(()=>Post,{foreignKey: 'postid', inverse: {type: "hasMany", as: 'attachments'}})
+ declare post?:NonAttribute;
+ declare static associations: {
+ posts: Association;
+ };
+}
+
+const sequelize = new Sequelize({
+ dialect: SqliteDialect,
+ storage: 'db.sqlite',
+ models: [Attachment]
+})
diff --git a/src/model/Post.ts b/src/model/Post.ts
index 7d3032c..7caed96 100644
--- a/src/model/Post.ts
+++ b/src/model/Post.ts
@@ -5,6 +5,7 @@ import { Attribute, AutoIncrement, BelongsTo, BelongsToMany, CreatedAt, Default,
import { Tag } from "./Tag";
import { PostTag } from "./PostTag";
import { Project } from "./Project";
+import { Attachment } from "./Attachment";
export class Post extends Model, InferCreationAttributes> {
@@ -45,6 +46,10 @@ export class Post extends Model, InferCreationAttributesTag, { through: { model: ()=>PostTag, unique: false}, inverse: {as: 'taggedPosts'} })
declare postTags?:NonAttribute;
+
+ /** Defined by {@link Attachment.post} */
+ declare Attachments:NonAttribute[];
+
declare getUser: BelongsToGetAssociationMixin;
diff --git a/src/providers/providers.tsx b/src/providers/providers.tsx
index 673f8ff..c64d301 100644
--- a/src/providers/providers.tsx
+++ b/src/providers/providers.tsx
@@ -10,20 +10,11 @@ export type AuthProps = {
auth?: Attributes
user?: Attributes
}
+
let p: AuthProps = {}
-export type AdminViewProps = {
- view: string;
-}
-
-let avp: AdminViewProps = {
- view: "home",
-}
-
-export const AdminViewContext = createContext(avp);
export const AuthContext = createContext(p);
-
interface Props {
children?: ReactNode;
params?: any;
@@ -31,6 +22,6 @@ interface Props {
export default function Providers(props:Props){
return (
- {props.children}
+ {props.children}
)
}
\ No newline at end of file