Once enabled and authorized, Troglio will prompt for the destination of your pages.
Troglio creates pages data in JSON format, ready to be consumed by templates or any kind of framework (React.js, Vue.js, Angular.js, Hugo, Jekyll...). Troglio assumes you have an existing back-end supporting your app or website's assets, usually in some versioning system like Git
. Troglio conveniently allows you to connect with big Git players Github, Gitlab and Bitbucket. In case you don't use one of these, no worries: just provide Troglio with a valid endpoint accepting POST data in JSON format.
Panel asking where to send pages data to
This panel should be straightforward, just follow the steps until you connect either a Git provider hosting your app/websites assets, or a custom URL pointing to a back-end you own..
Considerations to keep in mind depending on where your back-end lives:
For Git endpoints: each time content is published, Troglio will send data as a classic commit
command upserting a file in the master
branch at /troglio/data.json
. UPSERTING means it will create or update the relevant file automatically. Also, data are always refreshed without any incremental steps whatsoever: new data replace old ones. Simple. Just to make it clear again: there will be a classic commit
each time a user presses the Publish !
button, so if you work with your repo from a remote source, do not forget to sync changes using git pull origin
before pushing changes yourself.
For custom endpoints: Troglio will issue a POST
request to the provided URL, with data included as JSON
. So prepare your back-end to receive these data and do something with it. We created an example project on Glitch for you to get started here.
Using git providers there is always a free Continuous Integration pipeline available to trigger a build when a new commit happens. This is how this very website works:
Publish !
buttonBut there is another way. This solution fits well for static websites like troglio.com, but not always for apps. In that case, or just because of personal taste, one can also leverage Git CI pipelines to create their own API. The workflow could be as follow:
Publish !
buttontroglio/data.json
, then parse its JSON contentpath
property, we can then create a new page for each object in the pages
arrayapplication/json
MIME typeWith this workflow, one will be able to query pages data like a classic API.
For other more complex projects needing filters, databases etc... we recommend switching to a more flexible custom back-end like node.js
or any other language, and create a web server accepting POST requests with JSON data as input. Then the world is yours: Troglio will send data to your endpoint and you can do virtually anything with it to process, store, and retrieve data as you please.