MoOx / phenomic

DEPRECATED. Please use Next.js instead.
https://nextjs.org
MIT License
3.21k stars 249 forks source link

CMS with Contentful #917

Closed cedricdelpoux closed 7 years ago

cedricdelpoux commented 7 years ago

I just discovered Contentful. Contrary to Netlify-cms or Siteleaf this service does not push to github repo.

Do you think it could be possible, during the build process, to get content from Contentful to generate static website ?

I could be awesome. Because for now, I use Siteleaf and I let someone write content for me. But for each updated file, the is a commit. I would like to keep my git history clean and maybe Contentful could be a solution. What do you think ?

thangngoc89 commented 7 years ago

There is also Prismic.io which offers the same service. Basically with this kind of service, you pull the content from the service and create markdown files before building. You can use this solution for a Wordpress based CMS too.

cedricdelpoux commented 7 years ago

Looks amazing. I will take a look. Thanks

MoOx commented 7 years ago

As a workaround for the content/ commit thing: you might be able to use 2 repos (one for content as a submodule).

For contentful you might want to check this https://gist.github.com/ivanoats/e79ebbd711831be2536d1650890055c4.

Closing as it's a duplicate of #886

cedricdelpoux commented 7 years ago

Thank you. Sorry for the duplicate

Khaledgarbaya commented 7 years ago

Hi there, I know this issue is closed but I wanted to let you know that we support webhooks if you want to trigger ci builds to re-build you website everytime you publish something on Contentful.

cedricdelpoux commented 7 years ago

@Khaledgarbaya do you have any tips to generate markdown files after requesting data from Contenful ?

thangngoc89 commented 7 years ago

@xuopled just download the data and generating a markdown file with frontmatter and a body.

cedricdelpoux commented 7 years ago

I'm looking for a library which can help to create markdown file with frontmatter and body. Do you know one ?

thangngoc89 commented 7 years ago

@xuopled just write one yourself. Here is mine, only 30 LOCs https://github.com/thangngoc89/dnh-cpp/blob/6299e1d9b8d38e59568c1d5c2ee7b4a201ecec50/scripts/content/download-post.js

Khaledgarbaya commented 7 years ago

@xuopled Unfortunately there is no tool to do that, but as @thangngoc89 said should be straight forward to achieve that, Using the SDK client.getEntries({'content_type': 'post'}) and then run your files through a templating engine and save them. ps: the content_type:post is just an example could be any contenttype you defined in the webapp. Also using the SDK you will get link resolution between reference entries included.

cedricdelpoux commented 7 years ago

@thangngoc89, thank you, I did. @Khaledgarbaya I tried to create one markdown file per Contentful data :

client.getEntries()
  .then(function(posts) {
    posts.items.map(post => {
      var mdContent = objectToYaml(post.fields)
      fs.outputFile(`content/${post.fields.slug}.md`, mdContent)
    })
  })

but some of my fields are reference to other data :

---
title: Down the Rabbit Hole
slug: down-the-rabbit-hole
author:
  - &ref_0
    sys:
      space:
        sys:
          type: Link
          linkType: Space
          id: wdrlqiaj0bs4
    fields:
      name: Lewis Carroll
---

Is there a way to configure the way some ref will be resolve ? For example I would like the author field will resolve to author.fields.name to get :

---
title: Down the Rabbit Hole
slug: down-the-rabbit-hole
author: Lewis Carroll
--- 
thangngoc89 commented 7 years ago

@xuopled write you own resolver here

var mdContent = objectToYaml(post.fields)
cedricdelpoux commented 7 years ago

I would like to create a generic plugin. If each people has to resolve everything by hand, it would be never easy for Phenomic users to use it

thangngoc89 commented 7 years ago

@xuopled that's the goal for 1.0 . With the current architecture, it's hard to do that.

cedricdelpoux commented 7 years ago

Ok So I stop wasting my time :D

Khaledgarbaya commented 7 years ago

@xuopled the SDK should do the resolution for you, how deep the links are? and to not spam this issue can you create an issue here

cedricdelpoux commented 7 years ago

I don't know if my explanation is good but I opened an issue : https://github.com/contentful/contentful.js/issues/119