diff --git a/commons/graphql/queries.ts b/commons/graphql/queries.ts new file mode 100644 index 0000000..e7d16bd --- /dev/null +++ b/commons/graphql/queries.ts @@ -0,0 +1,12 @@ +import gql from "graphql-tag"; + +export const ARTICLE_FOR_HOME = gql` + query ArticlesForHome { + articles { + id + title + content + publishedAt + } + } +`; diff --git a/pages/_app.module.css b/pages/_app.module.css index 923095b..becf2af 100644 --- a/pages/_app.module.css +++ b/pages/_app.module.css @@ -2,5 +2,15 @@ @apply flex; } .sidebar { - @apply md:w-64 w-32; + @apply md:w-64 w-32 flex-none; +} +.primary { + @apply flex-auto; + @apply bg-gray-100 text-gray-700; + .wrapper { + @apply mx-auto max-w-screen-xl; + } +} +.pageHeader { + @apply p-3 bg-gray-50 flex justify-between; } \ No newline at end of file diff --git a/pages/_app.tsx b/pages/_app.tsx index f2be730..ba8613f 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,16 +1,43 @@ -import '../styles/globals.css' +import "../styles/globals.css"; import "tailwindcss/tailwind.css"; -import React from 'react'; -import { GlobalSidebar } from '../components/layouts/global-sidebar'; -import styles from './_app.module.css'; +import React from "react"; +import { GlobalSidebar } from "../components/layouts/global-sidebar"; +import styles from "./_app.module.css"; +import { ApolloProvider } from "@apollo/client"; +import { client } from "../commons/graphql/client"; function MyApp({ Component, pageProps }) { return ( -
- - -
+ +
+ +
+
+

{"Ivan Li 的个人博客"}

+
+ + +
+
+
+ +
+
+
+
); } -export default MyApp +function switchTheme(mode: "light" | "dark" | "auto") { + if (mode === "auto") { + mode = "light"; + } + + if (mode === "dark") { + document.documentElement.classList.add("dark"); + } else { + document.documentElement.classList.remove("dark"); + } +} + +export default MyApp; diff --git a/pages/index.module.css b/pages/index.module.css new file mode 100644 index 0000000..1eac3d5 --- /dev/null +++ b/pages/index.module.css @@ -0,0 +1,17 @@ +.index { + ol { + } +} + +.item { + @apply my-2 mx-4 px-3 overflow-hidden; + @apply rounded-md shadow-sm hover:shadow; + @apply bg-gray-50 hover:bg-white; + + .title { + @apply text-lg my-2; + } + .description { + @apply text-sm text-gray-600 leading-6 my-2; + } +} diff --git a/pages/index.tsx b/pages/index.tsx index d89f259..e149619 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,5 +1,23 @@ -import styles from '../styles/home.module.css'; +import { useQuery } from '@apollo/client'; +import { Article } from '../commons/graphql/generated'; +import { ARTICLE_FOR_HOME } from '../commons/graphql/queries'; +import styles from './index.module.css'; export default function Index() { - return
TEST
; + const { data, loading } = useQuery<{articles: Article[]}>(ARTICLE_FOR_HOME); + + return
+
    + { + data?.articles?.map(article => ) + } +
+
; +} + +function Item({article}: {article: Article}) { + return
  • +

    {article.title}

    +

    {article.content}

    +
  • } \ No newline at end of file