使用 API Resource 来创建自己的 {JSON:API} 格式 API
在Laravel API中返回数据经常需要经过处理之后再返回,之前我们使用了第三方扩展 Fractal
实现数据格式转化,参照【扩展 API开发】DingoApi(二)
。
从Laravel 5.5开始,内置了 API Resource 功能帮助我们快速建立起模型和 JSON返回数据之间的桥梁。
无风仍脉脉,不雨亦潇潇
缺失模块。
1、请确保node版本大于6.2
2、在博客根目录(注意不是yilia根目录)执行以下命令:
npm i hexo-generator-json-content --save
3、在根目录_config.yml里添加配置:
jsonContent: meta: false pages: false posts: title: true date: true path: true text: false raw: false content: false slug: false updated: false comments: false link: false permalink: false excerpt: false categories: false tags: true