writing it in html and sending it over curl to integromat(make) it uses the json from the webhook to send over to blogger
" Define the Vim function
function! Blogpost()
" Get the current buffer content
let l:buf_content = join(getline(1, '$'), "\n")
" Find the first heading
let l:title = matchstr(l:buf_content, '\(.*\)
')
if l:title == ''
echo "No heading found."
return
endif
" Extract the title text (remove the and
tags)
let l:title = substitute(l:title, '\(.*\)
', '\1', '')
" Extract content after the first heading
let l:content_start = matchend(l:buf_content, '\(.*\)
')
let l:content = strpart(l:buf_content, l:content_start)
" Create a dictionary for the JSON payload
let l:json_dict = {
\ 'title': l:title,
\ 'content': l:content
\ }
" Convert the dictionary to JSON
let l:json_payload = json_encode(l:json_dict)
" Create a temporary file to hold the JSON payload
let l:tmpfile = tempname()
call writefile([l:json_payload], l:tmpfile)
" Prepare the curl command
let l:cmd = 'curl -X POST https://hook.us1.make.com/WEBHOOKURLGOESHERE -H "Content-Type: application/json" -d @' . shellescape(l:tmpfile)
" Run the curl command
let l:output = system(l:cmd)
" Clean up the temporary file
call delete(l:tmpfile)
" Show the output or errors
echo l:output
endfunction
" Create a command to run the function
command! Blogpost call Blogpost()
No comments:
Post a Comment