getPages
コードブロックを取る方法
code:log
async function getScrapboxContent(title, contentName, project="tsuzumik-online") {
return fetch(https://scrapbox.io/api/code/${project}/${title}/${contentName}).then(res=>{return res.text()});
}
ページ本文を取る方法
code:pages
async function getScrapboxPageBody(title, project="tsuzumik-online") {
let res = await fetch(https://scrapbox.io/api/pages/${project}/${title});
let pageData = await res.json();
lines = pageData.lines.map((item)=>{return item'text';}); return lines;
}
1hop linkリストを取る方法
code:log
async function getScrapboxRelatedPages(title, project="tsuzumik-online") {
let res = await fetch(https://scrapbox.io/api/pages/${project}/${title});
let pageData = await res.json();
let links = pageData.relatedPages.links1hop.map((item)=>{return item'title';}); return links;
}
新規ページを作る
code:log
function newPage(title, content, project="tsuzumik-online") {
let encoded = encodeURI(content.join('\n'));
window.open(https://scrapbox.io/${project}/${title}?body=${encoded}, "_blank");
}