aafeng avatar

好香的Headless CMS:Strapi

aafeng

Published: 22 Sept 2021 › Updated: 22 Sept 2021好香的Headless CMS:Strapi

好香的Headless CMS:Strapi

尝试了一下strapi,感觉真的很香,几分钟就能搭建起后台的REST API服务,同时还支持很多插件,比如graphql插件,这就大大加快了开发的速度。

strapi

其实,之所以喜欢它,最主要还是它的设计出发点:Headless CMS。也就是说,只提供操作数据的API,而不像Wordpress那样同时提供操作数据的UI。(严格的讲,strapi也提供一个非常简单的数据操作界面)

一旦安装配置好之后,最重要的一步就是设计各种Content Type了,这就有点像关系型数据库中的表结构。这里共有三种不同类型的Content type: Collection type(针对有多个数据的类型,比如blog, user等), Single type(针对只出现一次的类型,比如:homepage),以及Component(可反复使用的组件)。在设计时可选的字段类型很丰富:

image

等到这个Content type设计好了之后,strapi就会生成类似于:http://localhost:1337/reviews 这样的API地址,这样前段就可以非常方便的使用了。

当然,作为一个CMS,strapi自然支持Authn/Authz。可以将某项内容指定为public,也可以指定其访问权限,用户组等等。

image

添加了graphql插件的后台就更加好用了:
image

后台API都搞定了,前台就可以非常愉快的使用Vue/React等玩耍了。。。

Leave 好香的Headless CMS:Strapi to:

Written by

Experience is everything.

Read more #cn posts


Best Posts From aafeng

We have not curated any of aafeng's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From aafeng