diff --git a/.gitignore b/.gitignore index ce47e26..0dd2359 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ node_modules dist .env -*.log \ No newline at end of file +*.log +.astro +package-lock.json +.omc diff --git a/package.json b/package.json index 6025204..06ec428 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,19 @@ { - "name": "astro6-simple", + "name": "astro-tina", "type": "module", "scripts": { "dev": "astro dev --host 0.0.0.0", "build": "astro build", - "preview": "astro preview" + "preview": "astro preview", + "dev:tina": "tinacms dev -c \"node ./tina/config.server.ts\"" }, "dependencies": { - "astro": "^6.1.7" + "astro": "^5.6.1", + "@astrojs/mdx": "^4.0.8", + "@tinacms/cli": "^2.2.3", + "react": "^18.3.1", + "react-dom": "^18.3.1", + "tinacms": "^2.2.3", + "astro-tina": "^0.1.4" } -} \ No newline at end of file +} diff --git a/src/content.config.ts b/src/content.config.ts new file mode 100644 index 0000000..d41da57 --- /dev/null +++ b/src/content.config.ts @@ -0,0 +1,22 @@ +import { defineCollection, z } from "astro:content" + +const postCollection = defineCollection({ + type: "content", + schema: z.object({ + title: z.string(), + description: z.string().optional(), + }), +}) + +const pageCollection = defineCollection({ + type: "content", + schema: z.object({ + title: z.string(), + description: z.string().optional(), + }), +}) + +export const collections = { + posts: postCollection, + pages: pageCollection, +} diff --git a/src/content/pages/about.md b/src/content/pages/about.md new file mode 100644 index 0000000..3d96497 --- /dev/null +++ b/src/content/pages/about.md @@ -0,0 +1,8 @@ +--- +title: About +description: About our site +--- + +# About Us + +We are building modern websites with Astro and Tina CMS. diff --git a/src/content/posts/welcome.md b/src/content/posts/welcome.md new file mode 100644 index 0000000..73ece7a --- /dev/null +++ b/src/content/posts/welcome.md @@ -0,0 +1,17 @@ +--- +title: Welcome to Astro + Tina +description: A modern starter with Astro 6 and Tina CMS +--- + +# Welcome to Astro + Tina + +This is a sample page managed by Tina CMS. + +## Features + +- Visual content editing with Tina CMS +- Git-based content management +- Static site generation with Astro +- Easy deployment on Easypanel + +Stay tuned for more updates! diff --git a/src/content/settings/site.json b/src/content/settings/site.json new file mode 100644 index 0000000..ec916d3 --- /dev/null +++ b/src/content/settings/site.json @@ -0,0 +1,5 @@ +{ + "siteName": "Astro Tina Starter", + "siteDescription": "A modern starter template with Astro 6, Tina CMS, and Thai language support.", + "language": "th" +} diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro new file mode 100644 index 0000000..2e4aeed --- /dev/null +++ b/src/layouts/Layout.astro @@ -0,0 +1,71 @@ +--- +const { title, description } = Astro.props +--- + + + + + + + + {title || "Astro Tina Starter"} + + + +
+ +
+ + + diff --git a/src/pages/blog.astro b/src/pages/blog.astro new file mode 100644 index 0000000..6450635 --- /dev/null +++ b/src/pages/blog.astro @@ -0,0 +1,57 @@ +--- +import { getCollection } from 'astro:content' +import Layout from "../layouts/Layout.astro" +const posts = await getCollection('posts') +--- + + +
+

Blog Posts

+
+ {posts.map(post => ( + + ))} +
+
+
+ + diff --git a/src/pages/posts/[slug].astro b/src/pages/posts/[slug].astro new file mode 100644 index 0000000..e381d7b --- /dev/null +++ b/src/pages/posts/[slug].astro @@ -0,0 +1,62 @@ +--- +import { getCollection } from 'astro:content' +import Layout from "../../layouts/Layout.astro" + +export async function getStaticPaths() { + const posts = await getCollection('posts') + return posts.map(post => ({ + params: { slug: post.slug }, + props: { post }, + })) +} + +const { post } = Astro.props +const { Content } = await post.render() +--- + + +
+ ← Back to Blog +
+

{post.data.title}

+ +
+
+
+ +