การจัดการเนื้อหา
Headless CMS ที่มี collections, entries, locales และ releases ครบครัน จัดการเนื้อหาผ่าน Content panel หรือ SDK
Proyecta มีระบบ headless CMS แบบสมบูรณ์ โดยใช้แนวคิด schema-first: คุณกำหนด collections (ประเภทเนื้อหาแบบมีโครงสร้าง) ก่อน จากนั้นสร้าง entries ที่สอดคล้องกับ fields ของแต่ละ collection โดย entries สามารถแปลเป็นภาษาต่างๆ และจัดกลุ่มเป็น releases ได้
Content panel
หัวข้อที่มีชื่อว่า “Content panel”เนื้อหาสามารถจัดการได้ผ่าน SDK หรือโดยการถาม AI Content API มีประเภท resource ทั้งหมดหกแบบ:
| Tab / Resource | ใช้สำหรับ |
|---|---|
| Collections | กำหนดและจัดการ content schemas (เช่น “Blog Post”, “FAQ”, “Product Spec”) |
| Fields | ช่องที่มีการกำหนดประเภทภายใน collection (จัดการในฐานะ sub-resource ของ Collections) |
| Entries | ดู สร้าง แก้ไข publish และลบ entries ภายใน collection |
| Locales | เพิ่มและจัดการ locales ของภาษา/ภูมิภาคสำหรับเนื้อหาที่แปลแล้ว |
| Releases | จัดกลุ่ม entries เพื่อเผยแพร่พร้อมกัน (หรือยกเลิกการเผยแพร่พร้อมกัน) โดย publish ด้วยตนเองผ่าน releases.publish() |
| Assets | อัปโหลดและจัดการไฟล์มีเดีย (รูปภาพ วิดีโอ PDF) ที่สามารถอ้างอิงจาก entries ได้ |
คลิก collection ใน Collections tab เพื่อไปยัง entries ของ collection นั้น Entries tab ให้คุณสร้าง แก้ไข publish และลบรายการเนื้อหาแต่ละรายการได้
คุณยังสามารถจัดการทุกอย่างผ่าน SDK แบบ programmatic ได้ด้วย (proyecta.content)
แนวคิดพื้นฐาน
หัวข้อที่มีชื่อว่า “แนวคิดพื้นฐาน”| แนวคิด | ความหมาย |
|---|---|
| Collection | Schema — รูปแบบของเนื้อหาประเภทหนึ่ง (เช่น “Blog Post”, “FAQ”, “Product Spec”) |
| Field | ช่องที่มีการกำหนดประเภทใน collection (เช่น title: string, body: rich_text, coverImage: asset) |
| Entry | อินสแตนซ์เดียวของ collection (บล็อกโพสต์หนึ่งชิ้น หรือ FAQ หนึ่งรายการ) |
| Asset | ไฟล์มีเดียที่อัปโหลดแล้ว สามารถอ้างอิงจาก entries ได้ |
| Locale | ภาษา/ภูมิภาคที่แปลเนื้อหาไป |
| Release | กลุ่ม entries ที่กำหนดให้เผยแพร่ (หรือยกเลิกการเผยแพร่) พร้อมกัน |
เริ่มต้นใช้งาน
หัวข้อที่มีชื่อว่า “เริ่มต้นใช้งาน”import Proyecta from '@proyecta-ai/sdk';
const proyecta = new Proyecta({ apiKey: process.env.PROYECTA_API_KEY });
// 1. Define a collectionconst blog = await proyecta.content.collections.create({ api_id: 'blogPost', name: 'Blog Post', // fields are added via collections.fields.create()});
// 2. Create an entryconst post = await proyecta.content.entries.create({ collection_id: blog.id, data: { title: 'Hello, world', body: 'My very first post.', },});
// 3. Publish itawait proyecta.content.entries.publish({ entryId: post.id });Collections
หัวข้อที่มีชื่อว่า “Collections”// Browse collectionsfor await (const collection of proyecta.content.collections.list()) { console.log(collection.name);}
// Add or remove fields on a collectionawait proyecta.content.collections.fields.create(blog.id, { /* field definition */});await proyecta.content.collections.fields.delete(blog.id, fieldId);Entries
หัวข้อที่มีชื่อว่า “Entries”Entries คือแถวเนื้อหาจริงๆ แต่ละ entry เป็นของ collection หนึ่งและมีข้อมูลที่ตรงกับ fields ของ collection นั้น
// Browse entries (pass the collection's api_id, not its numeric id)for await (const entry of proyecta.content.entries.list({ collection: 'blogPost' })) { console.log(entry);}
// Update an entryawait proyecta.content.entries.update(post.id, { data: { title: 'Updated title' } });
// Publish an entryawait proyecta.content.entries.publish({ entryId: post.id });
// Delete an entryawait proyecta.content.entries.delete(post.id);การอัปโหลด asset เป็นฟีเจอร์หลัก — ใช้เพื่อแนบรูปภาพ วิดีโอ หรือ PDF เข้ากับ entries ของคุณ:
// Browse assetsfor await (const asset of proyecta.content.assets.list()) { console.log(asset);}
// Upload, update, or delete via assets.create / assets.update / assets.deleteสำหรับการอัปโหลดไฟล์ผ่าน chat (ลากเข้า builder) ดูได้ที่ Files & Media
การแปลภาษา
หัวข้อที่มีชื่อว่า “การแปลภาษา”เนื้อหาสามารถแปลเป็นหลาย locales ได้ แต่ละ locale คือ record ที่จัดการผ่าน proyecta.content.locales:
await proyecta.content.locales.create({ /* code, name, etc. */});
for await (const locale of proyecta.content.locales.list()) { console.log(locale);}เมื่อดึง entries คุณสามารถระบุ locale ที่ต้องการได้ ดูภาพรวมของ i18n เพิ่มเติมได้ที่ Internationalization
Releases
หัวข้อที่มีชื่อว่า “Releases”Release คือชุดรวมของ entries ที่จะเผยแพร่ (หรือยกเลิกการเผยแพร่) พร้อมกัน วิธีนี้ช่วยให้คุณเตรียมการเผยแพร่เนื้อหาแบบประสานงาน — ไม่ว่าจะเป็นการ launch แคมเปญการตลาด หน้าสินค้าใหม่ หรือการอัปเดต FAQ — และให้ทุกอย่างเปลี่ยนแปลงพร้อมกันแบบ atomic
หมายเหตุ: ยังไม่รองรับการเผยแพร่อัตโนมัติตามเวลา Releases ที่มีวันที่
scheduled_atจะเข้าสู่สถานะscheduledแต่ต้องทำการ publish ด้วยตนเองผ่านreleases.publish()ฟีเจอร์การ publish อัตโนมัติตามเวลาที่กำหนดกำลังจะมาเร็วๆ นี้
// Create a release (optionally with a target date)const release = await proyecta.content.releases.create({ name: 'Monday launch', scheduled_at: '2024-01-08T09:00:00Z',});
// Manually publish a release when readyawait proyecta.content.releases.publish({ releaseId: release.id });
// Browse releasesfor await (const r of proyecta.content.releases.list()) { console.log(r);}หากต้องการเปลี่ยนกำหนดการของ release ให้ลบแล้วสร้างใหม่ เนื่องจากยังไม่มี endpoint สำหรับการอัปเดต
รูปแบบการใช้งานทั่วไป (ให้ AI ช่วยเชื่อมต่อให้)
หัวข้อที่มีชื่อว่า “รูปแบบการใช้งานทั่วไป (ให้ AI ช่วยเชื่อมต่อให้)”"Build a blog using the Proyecta Content API. Collection 'Blog Post' with fields: title, slug, excerpt, body (rich text), coverImage (asset), author. Public route at /blog and /blog/[slug].""Create an FAQ collection in Proyecta Content. Build an admin page where I can add/edit FAQs and a public /faq page.""Set up a multi-language landing page using Proyecta Content with English and Spanish locales.""Create a release containing three blog posts and publish it manually when ready."
เมื่อไหรควรใช้ Content กับ Database
หัวข้อที่มีชื่อว่า “เมื่อไหรควรใช้ Content กับ Database”| กรณีการใช้งาน | ใช้สิ่งนี้ |
|---|---|
| เนื้อหาเชิงบรรณาธิการ (โพสต์ FAQ เนื้อหาการตลาด) — ต้องการสถานะ publish/draft การกำหนดเวลา และการแปลภาษา | Content API |
| ข้อมูลของแอป (ผู้ใช้ คำสั่งซื้อ รายการสินค้า) — ต้องการความเร็วในการ query, transactions และ real-time | Database |
| Static assets ในโค้ด | ไดเรกทอรี public/ ในโปรเจกต์ของคุณ |
| ไฟล์ที่ผู้ใช้อัปโหลด | Files & Media |
กำลังจะมาเร็วๆ นี้
หัวข้อที่มีชื่อว่า “กำลังจะมาเร็วๆ นี้”- Rich-text entry editor — การแก้ไขแบบ WYSIWYG เต็มรูปแบบสำหรับ fields ประเภท
rich_textใน Content panel - Live preview ของการเปลี่ยนแปลงเนื้อหาในแอปของคุณ
- Content roles — แยกสิทธิ์ของ editor ออกจากสิทธิ์ของ developer