garchi-render-content
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUsage of Skill: garchi-render-content
Skill使用说明:garchi-render-content
Use this skill to render the created content. Follow the the steps below for smooth workflow:
使用此Skill来渲染已创建的内容。遵循以下步骤以确保流程顺畅:
Initial Checks
初始检查
- Read the documentation of Garchi CMS to understand the concepts. (Mandatory)
- Read the OpenAPI specifications to understand Garchi CMS APIs and their usage. (Mandatory)
- Understand if the project is created from scratch or Garchi CMS is being integrated into an existing project.
- If creating from scratch recommend to use Garchi CMS starter kits which comes in next, nuxt and laravel.
- If integrating into an existing project, recommend to use SDKs for easier integration otherwise use APIs with DRY and SOLID code.
- Check if user has provided API tokens and Space UID in .env file or some configuration file.
Content rendering refers to creating code that can be used to fetch and display the content from Garchi CMS.
Content can be rendered using APIs, Node SDK or PHP SDK. The SDKs are wrappers around the APIs and follows the same request and response schemas as APIs but provides a more user friendly way to fetch content from Garchi CMS.
- 阅读Garchi CMS文档以理解相关概念。(必填项)
- 阅读OpenAPI规范以了解Garchi CMS API及其使用方法。(必填项)
- 明确项目是从零开始创建,还是要将Garchi CMS集成到现有项目中。
- 如果是从零开始创建,建议使用Garchi CMS入门套件,目前支持Next、Nuxt和Laravel框架。
- 如果是集成到现有项目中,建议使用SDK以简化集成流程;若不使用SDK,则需遵循DRY和SOLID原则编写API调用代码。
- 检查用户是否已在.env文件或其他配置文件中提供API令牌和Space UID。
内容渲染指的是编写代码以从Garchi CMS获取并展示内容。
内容可通过API、Node SDK或PHP SDK进行渲染。SDK是API的封装,与API使用相同的请求和响应 schema,但提供了更便捷的方式从Garchi CMS获取内容。
Using SDKs
使用SDK
- Read the SDK documentation to understand it's usage and definitions of the functions. Documentation for the Node SDK can be found here and for the PHP SDK, it can be found here.
- Check if the SDK is installed in the project, if not, prompt to install it.
- If using starter kits, follow the coding pattern of starter kit.
- Keep the code DRY and SOLID, create reusable functions to fetch content from Garchi CMS and use it across the project.
- Some of the SDKs utilities have multiple ways to fetch data. For instance, data items can be fetched using ids, slugs, filters etc. Understand the user context and use the most suitable function to fetch the data.
- 阅读SDK文档以了解其使用方法及函数定义。Node SDK文档可在此处查看,PHP SDK文档可在此处查看。
- 检查项目中是否已安装SDK,若未安装,提示用户进行安装。
- 若使用入门套件,需遵循套件的编码规范。
- 代码需遵循DRY和SOLID原则,创建可复用的函数从Garchi CMS获取内容,并在整个项目中复用。
- 部分SDK工具提供多种数据获取方式。例如,可通过ID、别名、过滤器等方式获取数据项。需结合用户场景选择最合适的函数来获取数据。
Using APIs
使用API
- Familiarise yourself with APIs schema and usage by reading this OpenAPI specification
- Create reusable content management functions to fetch content from Garchi CMS using APIs. These functions should be flexible enough to be used across the project and should follow DRY and SOLID principles.
- Use appropriate HTTP methods (GET, POST, PUT, DELETE) for different operations.
- Handle errors gracefully and provide meaningful error messages to the user. The API provides validation errors with status of 422 if the request body is not valid.
- APIs have to be called from server or native environment as they don't support client side calls.
- Base URL of the API is https://garchi.co.uk
- 通过阅读OpenAPI规范熟悉API的schema及使用方法。
- 创建可复用的内容管理函数,通过API从Garchi CMS获取内容。这些函数需具备足够的灵活性,可在整个项目中复用,并遵循DRY和SOLID原则。
- 针对不同操作使用合适的HTTP方法(GET、POST、PUT、DELETE)。
- 优雅地处理错误,并向用户提供有意义的错误信息。若请求体无效,API会返回状态码为422的验证错误。
- API仅支持从服务器或原生环境调用,不支持客户端调用。
- API的基础URL为https://garchi.co.uk