diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 37224185..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["next/core-web-vitals", "next/typescript"] -} diff --git a/.gitignore b/.gitignore index 3dba35c6..5ef6a520 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,14 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. -.env # dependencies /node_modules /.pnp -.pnp.js -.yarn/install-state.gz - +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/versions # testing /coverage @@ -26,9 +28,10 @@ npm-debug.log* yarn-debug.log* yarn-error.log* +.pnpm-debug.log* -# local env files -.env*.local +# env files (can opt-in for committing if needed) +.env* # vercel .vercel diff --git a/README.md b/README.md index 6c0bba70..e215bc4c 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,36 @@ -# TinyMind +This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). -TinyMind is a website that lets you write and sync your blog posts, short thoughts, and memos by signing in with GitHub. Here's how it works: +## Getting Started -1. We create a public repo called "tinymind-blog" in your GitHub account. -2. When you write anything on our webpage, it automatically commits to your `yourname/tinymind-blog` repo. -3. This ensures a seamless way to create content and maintain data persistence. +First, run the development server: -## Data Privacy & Permissions +```bash +npm run dev +# or +yarn dev +# or +pnpm dev +# or +bun dev +``` -We only have write access to your public repositories. Your privacy matters: +Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. -- Content stored only in your GitHub repo -- No data kept on our servers -- You have full control through your GitHub account +You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. -## TODO +This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. -- [ ] Create a page to showcase all public writers using TinyMind (creator list) -- [ ] Implement shareable user main pages (like https://tinywind.me/mazzzystar) +## Learn More -## Tech Stack +To learn more about Next.js, take a look at the following resources: -Built with Next.js, React, TypeScript, NextAuth.js, and Tailwind CSS. +- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. +- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. -## Contribute +You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! -Contributions are welcome! Feel free to submit a Pull Request. +## Deploy on Vercel -## License +The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. -[Your chosen license here] +Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. diff --git a/app/api/auth/[...nextauth]/route.ts b/app/api/auth/[...nextauth]/route.ts deleted file mode 100644 index a8ed0a88..00000000 --- a/app/api/auth/[...nextauth]/route.ts +++ /dev/null @@ -1,6 +0,0 @@ -import NextAuth from "next-auth" -import { authOptions } from "@/lib/auth" - -const handler = NextAuth(authOptions) - -export { handler as GET, handler as POST } \ No newline at end of file diff --git a/app/api/github/route.ts b/app/api/github/route.ts deleted file mode 100644 index 545171da..00000000 --- a/app/api/github/route.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { NextRequest, NextResponse } from 'next/server'; -import { getServerSession } from "next-auth/next"; -import { authOptions } from "@/lib/auth"; -import { createBlogPost, createThought, getBlogPosts, getThoughts } from '@/lib/githubApi'; - -export async function POST(request: NextRequest) { - try { - console.log('POST request received'); - const session = await getServerSession(authOptions); - - if (!session || !session.accessToken) { - console.log('No valid session found'); - return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); - } - - const { action, ...data } = await request.json(); - console.log('Action:', action); - console.log('Data:', JSON.stringify(data, null, 2)); - - switch (action) { - case 'createBlogPost': - await createBlogPost(data.title, data.content, session.accessToken); - return NextResponse.json({ message: 'Blog post created successfully' }); - case 'createThought': - await createThought(data.content, data.image, session.accessToken); - return NextResponse.json({ message: 'Thought created successfully' }); - default: - return NextResponse.json({ error: 'Invalid action' }, { status: 400 }); - } - } catch (error) { - console.error('Error in /api/github POST:', error); - if (error instanceof Error) { - console.error('Error stack:', error.stack); - return NextResponse.json({ error: error.message, stack: error.stack }, { status: 500 }); - } - return NextResponse.json({ error: 'An unexpected error occurred' }, { status: 500 }); - } -} - -export async function GET(request: NextRequest) { - try { - const session = await getServerSession(authOptions); - - if (!session || !session.accessToken) { - console.log('No valid session found'); - return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); - } - - const { searchParams } = new URL(request.url); - const action = searchParams.get('action'); - - switch (action) { - case 'getBlogPosts': - const posts = await getBlogPosts(session.accessToken); - return NextResponse.json(posts); - case 'getThoughts': - const thoughts = await getThoughts(session.accessToken); - return NextResponse.json(thoughts); - default: - return NextResponse.json({ error: 'Invalid action' }, { status: 400 }); - } - } catch (error) { - console.error('Error in /api/github GET:', error); - if (error instanceof Error) { - return NextResponse.json({ error: error.message }, { status: 500 }); - } - return NextResponse.json({ error: 'An unexpected error occurred' }, { status: 500 }); - } -} \ No newline at end of file diff --git a/app/blog/[id]/page.tsx b/app/blog/[id]/page.tsx deleted file mode 100644 index 6a74e442..00000000 --- a/app/blog/[id]/page.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import { getServerSession } from "next-auth/next"; -import { authOptions } from "@/lib/auth"; -import { getBlogPost } from "@/lib/githubApi"; -import Link from "next/link"; -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; -import { format } from "date-fns"; - -function decodeTitle(title: string): string { - try { - return decodeURIComponent(title); - } catch { - return title; - } -} - -export default async function BlogPost({ params }: { params: { id: string } }) { - const session = await getServerSession(authOptions); - - if (!session) { - return ( - - -

Please sign in to view this post

- - Sign in - -
-
- ); - } - - const post = await getBlogPost(params.id, session.accessToken as string); - - if (!post) { - return ( - - -

Post not found

-
-
- ); - } - - const decodedTitle = decodeTitle(post.title); - const formattedDate = format(new Date(post.date), "MMMM d, yyyy"); - - return ( - - - {decodedTitle} -

{formattedDate}

-
- -
-
-
- - - ); -} diff --git a/app/blog/page.tsx b/app/blog/page.tsx deleted file mode 100644 index 787ede2e..00000000 --- a/app/blog/page.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { getServerSession } from "next-auth/next"; -import { authOptions } from "@/lib/auth"; -import BlogList from "@/components/BlogList"; -import { getBlogPosts } from "@/lib/githubApi"; -import GitHubSignInButton from "@/components/GitHubSignInButton"; - -export default async function BlogPage() { - const session = await getServerSession(authOptions); - - if (!session || !session.accessToken) { - return ; - } - - try { - const posts = await getBlogPosts(session.accessToken); - return ; - } catch (error) { - console.error("Error fetching blog posts:", error); - return ( -
- An error occurred while fetching blog posts: {(error as Error).message} -
- ); - } -} diff --git a/app/editor/page.tsx b/app/editor/page.tsx deleted file mode 100644 index 78718117..00000000 --- a/app/editor/page.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { getServerSession } from "next-auth/next"; -import { authOptions } from "@/lib/auth"; -import EditorComponent from "@/components/Editor"; -import GitHubSignInButton from "@/components/GitHubSignInButton"; - -export default async function EditorPage() { - const session = await getServerSession(authOptions); - - if (!session) { - return ; - } - - return ; -} diff --git a/app/favicon.ico b/app/favicon.ico deleted file mode 100644 index 9778fdeb..00000000 Binary files a/app/favicon.ico and /dev/null differ diff --git a/app/fonts/GeistMonoVF.woff b/app/fonts/GeistMonoVF.woff deleted file mode 100644 index f2ae185c..00000000 Binary files a/app/fonts/GeistMonoVF.woff and /dev/null differ diff --git a/app/fonts/GeistVF.woff b/app/fonts/GeistVF.woff deleted file mode 100644 index 1b62daac..00000000 Binary files a/app/fonts/GeistVF.woff and /dev/null differ diff --git a/app/globals.css b/app/globals.css deleted file mode 100644 index 46947be4..00000000 --- a/app/globals.css +++ /dev/null @@ -1,66 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; -@layer base { - :root { - --background: 0 0% 100%; - --foreground: 0 0% 3.9%; - --card: 0 0% 100%; - --card-foreground: 0 0% 3.9%; - --popover: 0 0% 100%; - --popover-foreground: 0 0% 3.9%; - --primary: 0 0% 9%; - --primary-foreground: 0 0% 98%; - --secondary: 0 0% 96.1%; - --secondary-foreground: 0 0% 9%; - --muted: 0 0% 96.1%; - --muted-foreground: 0 0% 45.1%; - --accent: 0 0% 96.1%; - --accent-foreground: 0 0% 9%; - --destructive: 0 84.2% 60.2%; - --destructive-foreground: 0 0% 98%; - --border: 0 0% 89.8%; - --input: 0 0% 89.8%; - --ring: 0 0% 3.9%; - --chart-1: 12 76% 61%; - --chart-2: 173 58% 39%; - --chart-3: 197 37% 24%; - --chart-4: 43 74% 66%; - --chart-5: 27 87% 67%; - --radius: 0.5rem - } - .dark { - --background: 0 0% 3.9%; - --foreground: 0 0% 98%; - --card: 0 0% 3.9%; - --card-foreground: 0 0% 98%; - --popover: 0 0% 3.9%; - --popover-foreground: 0 0% 98%; - --primary: 0 0% 98%; - --primary-foreground: 0 0% 9%; - --secondary: 0 0% 14.9%; - --secondary-foreground: 0 0% 98%; - --muted: 0 0% 14.9%; - --muted-foreground: 0 0% 63.9%; - --accent: 0 0% 14.9%; - --accent-foreground: 0 0% 98%; - --destructive: 0 62.8% 30.6%; - --destructive-foreground: 0 0% 98%; - --border: 0 0% 14.9%; - --input: 0 0% 14.9%; - --ring: 0 0% 83.1%; - --chart-1: 220 70% 50%; - --chart-2: 160 60% 45%; - --chart-3: 30 80% 55%; - --chart-4: 280 65% 60%; - --chart-5: 340 75% 55% - } -} -@layer base { - * { - @apply border-border; - } - body { - @apply bg-background text-foreground; - } -} \ No newline at end of file diff --git a/app/layout.tsx b/app/layout.tsx deleted file mode 100644 index 06b34d7d..00000000 --- a/app/layout.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import type { Metadata } from "next"; -import { Inter } from "next/font/google"; -import "./globals.css"; -import Header from "@/components/Header"; -import { SessionProvider } from "../components/SessionProvider"; -import Link from "next/link"; -import { FiPlus } from "react-icons/fi"; -import { Button } from "@/components/ui/button"; -import Script from "next/script"; -import Footer from "@/components/Footer"; - -const inter = Inter({ subsets: ["latin"] }); - -export const metadata: Metadata = { - title: "TinyMind - Write and sync your blog & memo data with GitHub", - description: - "Create a GitHub account and write blogs, thoughts, and notes using this website. Your data will be automatically saved in a GitHub repository, which means your data will never be lost as long as GitHub exists.p", -}; - -export default function RootLayout({ - children, -}: { - children: React.ReactNode; -}) { - return ( - - - - - - -
-
{children}
-