feat: Optimize page style & add Markdown support.

This commit is contained in:
blueeon
2024-03-28 17:57:24 +08:00
parent 179669e399
commit 0a867ebb2d
14 changed files with 792 additions and 120 deletions
+18
View File
@@ -0,0 +1,18 @@
import Link from "next/link";
import Image from "next/image";
export default function Footer() {
return (
<footer className=" flex w-full justify-center py-4 items-center
bg-indigo-50 backdrop-blur-2xl font-mono text-sm px-4 lg:px-0
">
<p className="px-6 py-3 rounded-full flex justify-center items-center gap-2
">
<span>© 2024</span>
<Link href="https://github.com/gcui-art/suno-api/">
gcui-art/suno-api
</Link>
</p>
</footer>
);
}
+50
View File
@@ -0,0 +1,50 @@
import Link from "next/link";
import Image from "next/image";
import Logo from "./Logo";
export default function Header() {
return (
<nav className=" flex w-full justify-center py-4 items-center
border-b border-gray-300 backdrop-blur-2xl font-mono text-sm px-4 lg:px-0">
<div className="max-w-3xl flex w-full items-center justify-between">
<div className="font-medium text-xl text-indigo-900 flex items-center gap-2">
<Logo className="w-4 h-4" />
<Link href='/'>
Suno API
</Link>
</div>
<div className="flex items-center justify-center gap-1 text-sm font-light text-indigo-900/90">
<p className="p-2 lg:px-6 lg:py-3 rounded-full flex justify-center items-center
lg:hover:bg-indigo-300 duration-200
">
<Link href="/">
Get Started
</Link>
</p>
<p className="p-2 lg:px-6 lg:py-3 rounded-full flex justify-center items-center
lg:hover:bg-indigo-300 duration-200
">
<Link href="/docs">
API Docs
</Link>
</p>
<p className="p-2 lg:px-6 lg:py-3 rounded-full flex justify-center items-center
lg:hover:bg-indigo-300 duration-200
">
<a href="https://github.com/gcui-art/suno-api/"
target="_blank"
className="flex items-center justify-center gap-1">
<span className="">
<Image src="/github-mark.png" alt="GitHub Logo" width={20} height={20} />
</span>
<span>Github</span>
</a>
</p>
</div>
</div>
</nav>
);
}
+13
View File
@@ -0,0 +1,13 @@
export default function Logo({ className = '', ...props }) {
return (
<span className=" bg-indigo-900 rounded-full p-2">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" className={className}
fill="none" stroke="#ffffff" stroke-width="1"
stroke-linecap="round" stroke-linejoin="round">
<path d="M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3" />
</svg>
</span>
);
}
+22
View File
@@ -0,0 +1,22 @@
'use client';
/**
*
* @param param0
* @returns
*/
export default function Section({
children,
className
}: {
children?: React.ReactNode | string,
className?: string
}) {
return (
<section className={`mx-auto w-full px-4 lg:px-0 ${className}`} >
<div className=" max-w-3xl mx-auto">
{children}
</div>
</section>
);
};
+5 -6
View File
@@ -1,14 +1,13 @@
import React from 'react';
import Swagger from './Swagger';
import Swagger from '../components/Swagger';
import spec from './swagger-suno-api.json'; // 直接导入JSON文件
import Section from '../components/Section';
export default async function Docs() {
// const spec = await getApiDocs();
export default function Docs() {
return (
<main className="flex min-h-screen flex-col items-center p-24 bg-white">
<Section className="">
<Swagger spec={spec} />
</main>
</Section>
);
}
+1 -9
View File
@@ -4,18 +4,10 @@
:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-start-rgb: 255, 255, 255;
--background-end-rgb: 255, 255, 255;
}
@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}
}
body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
+9 -1
View File
@@ -1,6 +1,8 @@
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
import Header from "./components/Header";
import Footer from "./components/Footer";
const inter = Inter({ subsets: ["latin"] });
@@ -18,7 +20,13 @@ export default function RootLayout({
}>) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
<body className={`${inter.className} overflow-y-scroll`} >
<Header />
<main className="flex flex-col items-center m-auto w-full">
{children}
</main>
<Footer />
</body>
</html>
);
}
+51 -99
View File
@@ -1,108 +1,60 @@
import Image from "next/image";
import Section from "./components/Section";
import Markdown from 'react-markdown';
export default function Home() {
const markdown = `
## Introduction
Suno.ai v3 is an amazing AI music service. Although the official API is not yet available, we couldn't wait to integrate its capabilities somewhere.
We discovered that some users have similar needs, so we decided to open-source this project, hoping you'll like it.
## Features
- Perfectly implements the creation API from \`app.suno.ai\`
- Supports \`Custom Mode\`
- One-click deployment to Vercel
- In addition to the standard API, it also adapts to the API Schema of Agent platforms like GPTs and Coze, so you can use it as a tool/plugin/Action for LLMs and integrate it into any AI Agent.
- Permissive open-source license, allowing you to freely integrate and modify.
## Getting Started
### 1. Obtain the cookie of your app.suno.ai account
### 2. Clone and deploy this project
### 3. Configure suno-api
### 4. Run suno api
### 5. Create more freely
`;
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<div className="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
Suno API
</p>
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
className="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
By{" "}
<a href="https://github.com/gcui-art/">
gcui.art
</a>
</a>
<>
<Section className="">
<div className="flex flex-col m-auto py-20 text-center items-center justify-center gap-4 bg-indigo-900/10 my-8 rounded-2xl border">
<span className=" px-5 py-1 text-xs font-light border rounded-full border-indigo-900 uppercase">Unofficial</span>
<h1 className="font-bold text-7xl flex text-indigo-900">
Suno AI API
</h1>
<p className="text-indigo-900/80 text-lg">
Deploy your own Suno AI API with just one click.
</p>
</div>
</div>
<div className="relative flex place-items-center
before:absolute before:h-[300px] before:w-full sm:before:w-[480px] before:-translate-x-1/2 before:rounded-full
before:bg-gradient-radial before:from-white before:to-transparent
before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-full sm:after:w-[240px] after:translate-x-1/3
after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl
after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700 before:dark:opacity-10 after:dark:from-sky-900 after:dark:via-[#0141ff] after:dark:opacity-40 before:lg:h-[360px] z-[-1]">
<h1 className=" font-bold text-2xl">
Easily integrate Suno AI into your GPTs and other agents.
</h1>
</Section>
<Section className="my-10">
<article className="prose lg:prose-lg max-w-3xl border-t pt-10">
<Markdown>
{markdown}
</Markdown>
</article>
</Section>
</div>
<div className="mb-32 grid text-center lg:max-w-5xl lg:w-full lg:mb-0 lg:grid-cols-4 lg:text-left">
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Docs{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Find in-depth information about Next.js features and API.
</p>
</a>
<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Learn{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Learn about Next.js in an interactive course with&nbsp;quizzes!
</p>
</a>
<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Templates{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Explore starter templates for Next.js.
</p>
</a>
<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Deploy{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50 text-balance`}>
Instantly deploy your Next.js site to a shareable URL with Vercel.
</p>
</a>
</div>
</main>
</>
);
}