食べたもの記録用template
函数をファイルに分割できないかな
code:breakfast.js
export default function() {
const zero = n => String(n).padStart(2, '0');
const today = (d => ${d.getFullYear()}-${zero(d.getMonth() + 1)}-${zero(d.getDate())})(new Date());
const title=${today} あさごはん;
// pageを生成
const project_name = scrapbox.Project.name;
const body = encodeURIComponent(\n\n#log-breakfast #log-eatenfood\n#${today});
window.open(https://scrapbox.io/${project_name}/${title}?body=${body});
}
code:lunch.js
export default function() {
const zero = n => String(n).padStart(2, '0');
const today = (d => ${d.getFullYear()}-${zero(d.getMonth() + 1)}-${zero(d.getDate())})(new Date());
const title=${today} ひるごはん;
// pageを生成
const project_name = scrapbox.Project.name;
const body = encodeURIComponent(\n\n#log-lunch #log-eatenfood\n#${today});
window.open(https://scrapbox.io/${project_name}/${title}?body=${body});
}
code:dinner.js
export default function() {
const zero = n => String(n).padStart(2, '0');
const today = (d => ${d.getFullYear()}-${zero(d.getMonth() + 1)}-${zero(d.getDate())})(new Date());
const title=${today} よるごはん;
// pageを生成
const project_name = scrapbox.Project.name;
const body = encodeURIComponent(\n\n#log-dinner #log-eatenfood\n#${today});
window.open(https://scrapbox.io/${project_name}/${title}?body=${body});
}
code:snack.js
export default function() {
const zero = n => String(n).padStart(2, '0');
const today = (d => ${d.getFullYear()}-${zero(d.getMonth() + 1)}-${zero(d.getDate())})(new Date());
const title=${today} 食べたもの;
// pageを生成
const project_name = scrapbox.Project.name;
const body = encodeURIComponent(\n\n#log-eatenfood\n#${today});
window.open(https://scrapbox.io/${project_name}/${title}?body=${body});
}
project nameを現在のprojectになるようにした
変数名を修正
functionを全てlambda式に変更