diff --git a/apps/web/.eslintrc.js b/apps/tutorials/.eslintrc.js similarity index 100% rename from apps/web/.eslintrc.js rename to apps/tutorials/.eslintrc.js diff --git a/apps/web/README.md b/apps/tutorials/README.md similarity index 100% rename from apps/web/README.md rename to apps/tutorials/README.md diff --git a/apps/web/next-env.d.ts b/apps/tutorials/next-env.d.ts similarity index 100% rename from apps/web/next-env.d.ts rename to apps/tutorials/next-env.d.ts diff --git a/apps/web/next.config.js b/apps/tutorials/next.config.js similarity index 100% rename from apps/web/next.config.js rename to apps/tutorials/next.config.js diff --git a/apps/web/package.json b/apps/tutorials/package.json similarity index 95% rename from apps/web/package.json rename to apps/tutorials/package.json index dc1e52ad0b2..0617f75e998 100644 --- a/apps/web/package.json +++ b/apps/tutorials/package.json @@ -1,5 +1,5 @@ { - "name": "web", + "name": "tutorials", "version": "0.0.0", "private": true, "scripts": { diff --git a/apps/tutorials/postcss.config.js b/apps/tutorials/postcss.config.js new file mode 100644 index 00000000000..29c447cb54b --- /dev/null +++ b/apps/tutorials/postcss.config.js @@ -0,0 +1 @@ +module.exports = require('config/postcss.config') diff --git a/apps/tutorials/src/pages/index.tsx b/apps/tutorials/src/pages/index.tsx new file mode 100644 index 00000000000..7a9fbb9e83c --- /dev/null +++ b/apps/tutorials/src/pages/index.tsx @@ -0,0 +1,22 @@ +import { fetchPosts, DevPost } from '../utils/api' + +export default function Tutorials({ posts }: { posts: DevPost[] }) { + return ( +
+

Tutorials

+ {posts.map((x) => ( +
+

{x.title}

+

{x.description}

+
+ ))} +
+ ) +} + +export async function getServerSideProps() { + const posts = await fetchPosts() + return { + props: { posts }, + } +} diff --git a/apps/tutorials/src/utils/api.ts b/apps/tutorials/src/utils/api.ts new file mode 100644 index 00000000000..13c5bd9041f --- /dev/null +++ b/apps/tutorials/src/utils/api.ts @@ -0,0 +1,55 @@ +const username = 'supabase' +const postsUrl = `https://dev.to/api/articles?username=${username}` + +// Defines a Post returned from the DEV API +export type DevPost = { + id: Number + title: string + description: string + slug: string + url: string + path: string + readable_publish_date: string + published_at: string + tags: string + tag_list: string[] + comments_count: Number + public_reactions_count: Number + positive_reactions_count: Number + published: boolean + first_published_at: string + edited_at: string + user: { + username: string + name: string + profile_image_90: string + cover_image_90: string + profile_image_original: string + cover_image_original: string + location: string + website: string + bio: string + twitter_username: string + github_username: string + dribbble_username: string + path: string + } + organization: { + id: Number + name: string + slug: string + profile_image_90: string + profile_imag: string + } +} + +export async function fetchPosts() { + try { + const res = await fetch(postsUrl) + const data: DevPost[] = await res.json() + return data + } catch (err) { + console.log(err) + return [] + } +} diff --git a/apps/tutorials/tailwind.config.js b/apps/tutorials/tailwind.config.js new file mode 100644 index 00000000000..9c2af498997 --- /dev/null +++ b/apps/tutorials/tailwind.config.js @@ -0,0 +1 @@ +module.exports = require('config/tailwind.config') diff --git a/apps/web/tsconfig.json b/apps/tutorials/tsconfig.json similarity index 100% rename from apps/web/tsconfig.json rename to apps/tutorials/tsconfig.json diff --git a/apps/web/src/pages/index.tsx b/apps/web/src/pages/index.tsx deleted file mode 100644 index 6ec0887ce02..00000000000 --- a/apps/web/src/pages/index.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { Button } from "ui"; - -export default function Web() { - return ( -
-

Web

-
- ); -}