From 43cdb2c4ad96417f7832d379c9fcb8348ebe6200 Mon Sep 17 00:00:00 2001 From: log101 Date: Tue, 7 May 2024 19:35:30 +0300 Subject: [PATCH] feat: add category pages --- README.md | 55 +-------------- src/components/Header.astro | 13 ++-- src/components/Post.astro | 18 +++++ src/content/config.ts | 7 ++ src/pages/category/[category].astro | 15 +++++ src/pages/index.astro | 17 +---- src/scripts/gol.js | 100 ---------------------------- src/styles/home.css | 7 +- 8 files changed, 58 insertions(+), 174 deletions(-) create mode 100644 src/components/Post.astro create mode 100644 src/pages/category/[category].astro delete mode 100644 src/scripts/gol.js diff --git a/README.md b/README.md index 1db3fb3..5e3edf8 100644 --- a/README.md +++ b/README.md @@ -1,54 +1 @@ -# Astro Starter Kit: Basics - -```sh -npm create astro@latest -- --template basics -``` - -[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics) -[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/basics) -[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/basics/devcontainer.json) - -> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun! - -![just-the-basics](https://github.com/withastro/astro/assets/2244813/a0a5533c-a856-4198-8470-2d67b1d7c554) - -## 🚀 Project Structure - -Inside of your Astro project, you'll see the following folders and files: - -```text -/ -├── public/ -│ └── favicon.svg -├── src/ -│ ├── components/ -│ │ └── Card.astro -│ ├── layouts/ -│ │ └── Layout.astro -│ └── pages/ -│ └── index.astro -└── package.json -``` - -Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name. - -There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components. - -Any static assets, like images, can be placed in the `public/` directory. - -## 🧞 Commands - -All commands are run from the root of the project, from a terminal: - -| Command | Action | -| :------------------------ | :----------------------------------------------- | -| `npm install` | Installs dependencies | -| `npm run dev` | Starts local dev server at `localhost:4321` | -| `npm run build` | Build your production site to `./dist/` | -| `npm run preview` | Preview your build locally, before deploying | -| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` | -| `npm run astro -- --help` | Get help using the Astro CLI | - -## 👀 Want to learn more? - -Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat). +> Geçmesi imkansız geçmiş, gelmesi imkansız gelecek... diff --git a/src/components/Header.astro b/src/components/Header.astro index d730f03..2cf6059 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -1,5 +1,5 @@ --- - +import { CATEGORIES } from "../content/config"; ---
@@ -17,10 +17,13 @@

diff --git a/src/components/Post.astro b/src/components/Post.astro new file mode 100644 index 0000000..7fe3ecb --- /dev/null +++ b/src/components/Post.astro @@ -0,0 +1,18 @@ +--- +const { data } = Astro.props; +--- + +
+ +

{data.title}

+ +

{data.summary}

+
diff --git a/src/content/config.ts b/src/content/config.ts index b0b65f6..ac195a4 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -1,5 +1,12 @@ import { z, defineCollection } from "astro:content"; +export const CATEGORIES = { + fikir: "Fikir", + teknik: "Teknik", + edebiyat: "BabĂĽr'ĂĽn SerĂĽvenleri", + ansiklopedi: "Ansiklopedi", +}; + const blogCollection = defineCollection({ type: "content", schema: z.object({ diff --git a/src/pages/category/[category].astro b/src/pages/category/[category].astro new file mode 100644 index 0000000..57db597 --- /dev/null +++ b/src/pages/category/[category].astro @@ -0,0 +1,15 @@ +--- +import { CATEGORIES } from "../../content/config"; + +export function getStaticPaths() { + return Object.keys(CATEGORIES).map((k) => { + return { + params: { category: k }, + }; + }); +} + +const { category } = Astro.params; +--- + +
Catakulli, {category}!
diff --git a/src/pages/index.astro b/src/pages/index.astro index f27e478..0f5e555 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -6,6 +6,7 @@ import "../styles/header.css"; import "../styles/home.css"; import { getCollection } from "astro:content"; +import Post from "../components/Post.astro"; const allTeknikPosts = await getCollection("blog"); --- @@ -17,22 +18,10 @@ const allTeknikPosts = await getCollection("blog"); { allTeknikPosts .sort((p1, p2) => p2.data.date.getTime() - p1.data.date.getTime()) - .map((p) => ( -
- -

{p.data.title}

- -

{p.data.summary}

-
- )) + .map((p) => ) } + Tüm Yayınlar