Use this file's HTTP URL as the webhook for Contenda's API and paste this snippet to automatically save all your resulting jobs with the Contenda-generated blog. From there, you can call the API again to get the markdown file or access your content through the Contenda platform.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
if (context.http.method !== 'POST') return;
let job_id;
if (context.http.json.status == 'succeeded') {
job_id = context.http.json.job_id;
} else {
return;
}
let contenda = await lib.contenda.api['@0.0.8'].jobs.status.retrieve({
job_id: `${job_id}`,
});
const blog_id = contenda.result.result_document_id;
await lib.utils.kv.set({
key: `${job_id}`,
value: `${blog_id}`,
});
let result = await lib.utils.kv['@0.1.16'].entries();
console.log(result);
return result;