使用NUXT.js和KenticoCloud链接的内容项

时间:2019-05-07 12:50:05

标签: javascript sdk nuxt.js kentico-cloud

当前,我正在致电deliveryClient来收集我项目的所有内容项。

在我们的一种内容类型中,它具有链接的内容项。我想知道在NUXT中处理链接内容项的最佳方法是什么,以允许我从链接项中提取内容。

还值得注意的是,内容类型的内容比下面的代码建议的要多。为简单起见而减少。我也不想使用Model Generation等,因为它会耦合我的内容类型。我们要求允许不更改代码就连续更改内容类型。

任何帮助将不胜感激。干杯

export const actions = {
  getBlogPosts(context) {
  const cacheSeconds = 30;
  const query = this.$deliveryClient.items().depthParameter(6);

 return this.$deliveryClient.viaCache(query, cacheSeconds).then(response => {
  context.commit(
    "setBlogPosts",
    response.items.map(item => ({
      id: item.system.id,
      header: item.title.value,
      content: item.content.value
    }))
  );
})
;}

0 个答案:

没有答案