Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(strapi): add strapi #27

Merged
merged 3 commits into from
Mar 12, 2022
Merged

feat(strapi): add strapi #27

merged 3 commits into from
Mar 12, 2022

Conversation

colmugx
Copy link
Contributor

@colmugx colmugx commented Mar 6, 2022

add strapi support (not sure whether you need it)

it's a really simple version, maybe should take more support when blogkit updated. (configuring with plugin)

and this version must use fields in strapi: title, content, excerpt

thx.

@2nthony
Copy link
Owner

2nthony commented Mar 6, 2022

I'm gonna take some updates first.

@2nthony 2nthony mentioned this pull request Mar 6, 2022
@2nthony
Copy link
Owner

2nthony commented Mar 7, 2022

support request(config: BlogkitConfig): Request in [email protected]

@colmugx
Copy link
Contributor Author

colmugx commented Mar 8, 2022

你可以 review 一遍代码,由于 strapi 是一个非常自由的 cms,其字段都可以自由配置

blogkit 现在默认的主题可以说只需要 slug、标题、时间、摘要、正文。strapi会提供时间,但剩下的字段都是自由的,目前 type 如下

attributes?: {
  title: string
  content: string
  excerpt: string
}

这其实导致的问题是:字段不可控。那么就需要可配置

当前事实上的问题并不是让 request 接受一个内部配置,而是让 request 能获取配置

现在一个比较尴尬的问题是,blogkit-strapi需要在 defineConfig 里执行参数,就像这样

request: request({
  // key 为 blogkit 标记点,value 为 strapi 配置的变量
  attributes: {
    title: "title",
    content: "content",
    excerpt: "excerpt",
  },
}),

这样属实难看,而且有点背离设计了。如果强制使用类似title, content, excerpt 就没问题

所以是否在 request 或者别的东西需要重新设计,当然这是后话,并不需要因为这个需求而修改 blogkit 的设计

(大不了也直接用环境变量做这个事情)

而且,或者说,现在仅是因为 theme-minimal 只需要这些参数(变量),那么未来呢(例如增加 tag)?
想错了,blogkit 里的 Attributes 的设计没问题

@2nthony
Copy link
Owner

2nthony commented Mar 9, 2022

好像理解当初为什么提了一下插件机制,是不是为了能够通过插件去修改一些内部的定义。

像 vite 那样,可以在插件中去修改

definePlugin({
  config(config) {
    config[prop] = myValue
  }
})

但好像不太应该🤔


tag(s)? 这个字段在 #2 中有提及,这个字段应该是存在的,所以要加。


reqeust 的出发点就是一层转换,将数据转换为符合 core 里的 Attributes 的格式。

@colmugx
Copy link
Contributor Author

colmugx commented Mar 9, 2022

reqeust 的出发点就是一层转换,将数据转换为符合 core 里的 Attributes 的格式。

没有问题,这是个 Adapter Pattern。现在的问题是“request 可能可以支持一部分自定义能力”

直接写也能达到目的,只要让 reuqest 永远返回的是 Request 就行。但一是看起来不好看了跟设计不太像,二是我怎么看都像有学习成本了..

@2nthony
Copy link
Owner

2nthony commented Mar 10, 2022

由于 strapi 是一个非常自由的 cms,其字段都可以自由配置

其实 notion database 也是字段随意定,因此我的解决方式是给一个 database 模板 让用户去复制这个模板,来帮助用户做这个事情,不过确实这个方式也只能解决一部分问题。

可能在 request 层需要做更多的探讨。

周末我尝试一下 strapi 就合了😂 。

@2nthony
Copy link
Owner

2nthony commented Mar 12, 2022

I am merging this, and I will add a basic strapi tutorial to the starter template.

@2nthony 2nthony merged commit fdaea37 into 2nthony:main Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants