链滴分享1
效果展示
使用方法
下载集市中插件 Query & View
新建一个文档
命名就看你自己
打开模板文件
按照下图路径找到模板文件夹,并找到命名的日记模板文件
插入模板代码
在文档首行放入如下代码:
.action{$week := add (mod (div ((toDate "2006-01-02" "2050-03-13").Sub now).Hours 24) 7) 1}
.action{$today := last (slice (list "星期六" "星期五" "星期四" "星期三" "星期二" "星期一" "星期天") 0 $week )}
.action{$datestr := now | date "2006-01-02"}
.action{$datestr_sy := now | date "20060102"}
在文件末尾放入如下代码
{{//!js_esc_newline_const today = '.action{$datestr_sy}';_esc_newline_const query = async () => {_esc_newline_ let dv = Query.DataView(protyle, item, top);_esc_newline_ const docid = Query.docid(protyle);_esc_newline_ console.log(docid);_esc_newline_ const createdToday = await Query.sql(`_esc_newline_ select * from blocks where type='d' and created like '${today}%'_esc_newline_ `);_esc_newline_ dv.addmd(`#### 今天创建了 ${createdToday.length} 篇文档:`);_esc_newline_ dv.addtable(createdToday, { cols: ['type', 'hpath', 'box'], fullwidth: true });_esc_newline__esc_newline_ dv.addmd('#### daily notes')_esc_newline_ const sqlDN = `_esc_newline_ select B.* from blocks as B join attributes as A_esc_newline_ on B.id = A.block_id_esc_newline_ where (_esc_newline_ B.type = 'd'_esc_newline_ and A.name='custom-dailynote-${today}'_esc_newline_ and B.root_id != '${docid}'_esc_newline_ )_esc_newline_ `;_esc_newline_ const sqlh2 = `_esc_newline_ select * from blocks where (_esc_newline_ subtype='h2' and root_id != '${docid}'_esc_newline_ and root_id in (_esc_newline_ select distinct B.id from blocks as B join attributes as A_esc_newline_ on B.id = A.block_id_esc_newline_ where A.name = 'custom-dailynote-${today}'_esc_newline_ )_esc_newline_ )_esc_newline_ `_esc_newline__esc_newline_ const dailynotes = await Query.sql(sqlDN);_esc_newline_ const h2s = await Query.sql(sqlh2);_esc_newline_ const groupedh2 = h2s.groupby('root_id');_esc_newline_ dailynotes.map(note => {_esc_newline_ const h2s = groupedh2[note.root_id];_esc_newline_ const name = note.attr('box');_esc_newline_ const content = document.createElement('div');_esc_newline_ content.style.display = 'content';_esc_newline_ if (h2s) {_esc_newline_ const l = dv.list(h2s, { columns: 2 });_esc_newline_ content.appendChild(l);_esc_newline_ }_esc_newline_ const embed = dv.embed(note, { zoom: 0.7, limit: 2 });_esc_newline_ content.appendChild(embed);_esc_newline_ const detail = dv.adddetail(name, content);_esc_newline_ detail.style.overflowX = 'unset';_esc_newline_ });_esc_newline__esc_newline_ const now = Query.Utils.today(false);_esc_newline__esc_newline_ let updatedState = dv.useState('updated-docs', []);_esc_newline_ if (now === today) {_esc_newline_ dv.addmd('#### 今天的更新')_esc_newline_ let updatedDoc = await Query.sql(`_esc_newline_ select * from blocks where type='d' and updated like '${today}%'_esc_newline_ order by updated desc_esc_newline_ `);_esc_newline_ dv.addtable(updatedDoc, {_esc_newline_ fullwidth: true,_esc_newline_ cols: ['box', 'hpath', 'updated'],_esc_newline_ });_esc_newline_ let state = updatedDoc.pick('id', 'root_id', 'box', 'hpath', 'updated', 'content');_esc_newline_ updatedState(state);_esc_newline_ } else {_esc_newline_ //不是今天,就从缓存中读取_esc_newline_ dv.addmd(`#### ${today} 当天的更新`)_esc_newline_ dv.addtable(updatedState(), {_esc_newline_ fullwidth: true,_esc_newline_ cols: ['box', 'hpath', 'updated'],_esc_newline_ });_esc_newline_ }_esc_newline__esc_newline_ dv._element.style = 'max-height: 700px; overflow-y: auto;';_esc_newline_ dv.render();_esc_newline_}_esc_newline__esc_newline_return query();}}
调用
用/之后找到模板,然后找到你的命名模板,就可以将模板插入文件中
同时设置笔记本的日记模板位置
我的日记模板文件名称为:/2025-日记-每日新建文档和修改文档.md
找到你要创建日记的笔记本
填入模板路径
照上图方式填入模板即可
链滴分享
↩
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于