megazear7 / orison

A server and static site generator built on top of lit-html
http://orison.alexlockhart.me
18 stars 2 forks source link

Fine Tune Web Hooks #11

Closed megazear7 closed 5 years ago

megazear7 commented 5 years ago

The ./build.js file should use the information passed by the Github and Contentful build hooks in order to only build the files necessary.

Github Web Hook

Currently it looks like the Github passes no information in the web hook, so that might need updated or might not be possible. For example if no changes under /src are changed in a commit, then no build is necessary.

Contentful Web Hook

The Contentful web hook passes along information such as the JSON listed below. Blog posts tagged with the orisonjs-blog tag should produce a build with a generate path of /blog. Other types of Contentful updates can produce builds with vary generate paths in order to only rebuild what is necessary.

{
   "sys":{
      "type":"Entry",
      "id":"5yI7Sof8GKPflIWeG2O9RE",
      "space":{
         "sys":{
            "type":"Link",
            "linkType":"Space",
            "id":"8blvhwbk2pug"
         }
      },
      "environment":{
         "sys":{
            "id":"master",
            "type":"Link",
            "linkType":"Environment"
         }
      },
      "contentType":{
         "sys":{
            "type":"Link",
            "linkType":"ContentType",
            "id":"blogPost"
         }
      },
      "revision":7,
      "createdAt":"2019-04-23T09:47:54.520Z",
      "updatedAt":"2019-05-07T12:26:53.466Z"
   },
   "fields":{
      "title":{
         "en-US":"About OrisonJS"
      },
      "slug":{
         "en-US":"about-orisonjs"
      },
      "heroImage":{
         "en-US":{
            "sys":{
               "type":"Link",
               "linkType":"Asset",
               "id":"4zxnW6kn21u3ya4zBKf8Ib"
            }
         }
      },
      "description":{
         "en-US":"OrisonJS is a static site generator built on top of lit-html with performance, SPA, PWA, and static site generation out of the box with no frontend dependencies."
      },
      "body":{
         "en-US":"OrisonJS is a static site generator built on top of lit-html. It comes with initialization commands for getting a project up and running quick. It is built with native web in mind, allowing you to easily get started with all of the following web platform techniques:\n\n1. Performance First\n2. Progressive Web App\n3. Single Page Application\n4. Search Engine Optimization\n5. Static Site Generation"
      },
      "publishDate":{
         "en-US":"2019-04-23T00:00-04:00"
      }
   }
}
megazear7 commented 5 years ago

I have added in a more fine tuned build process which looks for changes to blog content. If the content of a blog article is changed only that blog page and the blog listing pages are changed. Otherwise the entire build is performed. I opted against doing a fine tuned Github based build process because the OOTB github netlify integration does not provide that information and I would rather rely on the OOTB integration than have a github build hook that has to reimplement already provided features.

This is good enough for now. More could be done though.