bashlk / staticman-netlify-function

Simple wrapper around Staticman that allows it to be hosted as a netlify function.
MIT License
32 stars 4 forks source link

instruction for Jekyll #7

Open evodify opened 3 years ago

evodify commented 3 years ago

I tried to use staticman-netlify-function with Jekyll on Netlify. The function fails to build. I tried to replace yarn --production with npm install in the post install command. The build process starts but gets stack at:

yarn build
2:22:11 PM: [DEPRECATION] The trollop gem has been renamed to optimist and will no longer be supported. Please switch to optimist as soon as possible.

Then Netlify kills it because of the build time limit. Please, try to build from this test repo on Netlify to reproduce the problem: https://github.com/avglinux/avgt

bashlk commented 3 years ago

Hi @evodify!

I primarily built statesman-netlify-function to work with Gatsby or other node based static site generators. So following the instructions might actually break your project's build process. I believe netlify automatically figures out the project type based on the files in the repo and placing the config files I have provided might interfere with that.

That said in your case, you can get rid of the root package.json and instead modify the build section of netlify.toml to be

[build]
  publish = "_site"
  command = "jekyll build && cd functions/staticman && npm install"
  functions = "functions"

I adapted this config from a jekyll config I found online (https://github.com/algolia/jekyll-algolia-example/blob/master/netlify.toml) you might need to set publish to the folder where the final files are generated and adjust the Jekyll build command to what you use.

Let me know if that helps. (also post the entire log output from netlify, the sample you provided doesn't show anything out of the ordinary)

evodify commented 3 years ago

Thanks for your help!

It did not work with your functions/staticman files, but I was able to build it with the official code and the build command you provided.

However, it doesn't work. I assume it requires some code modification to run on Netlify. I see the error staticman.handler is undefined or not exported when I submit a comment.

I also added GITHUB_TOKEN and RSA_PRIVATE_KEY in Settings > Build & deploy > Environment > Environment variables on Netlify.

I will stick with Heroku deployment for now and may get back to Netlify functions later.

Thanks again for your time.