[father::元笔记汇总]

官方文档

官方完整文档

Dataview (blacksmithgu.github.io)

梗概

  • dataview插件:一个高级的内嵌笔记自动搜索器

适用范围

作用

可以自定义笔记显示样式

  • 甚至能以树状图进行显示

场景

  • 做笔记的自动索引
  • 做笔记的自5动汇总

详解

dataview的作用

  1. 按照制定规则归类显示一堆文件

支持的语言:

截至2022-02-24

  1. dataview共提供了两种语言
    1. DQL(Dataview Query Language)
      1. 官方自创的语言
      2. 简单易用,功能够用
    2. DataviewJS
      1. 一个高性能的JavaScript API,可以完全访问Dataview索引和一些方便的渲染实用程序。
  2. 以上两种语言都有两种用法
    1. 写在多行代码块中
      1. 在代码块头加上dataviewdataviewjs
    2. 写在单行代码块中
      1. 加上前缀=(该前缀可以在设置中自定义)

DQL(Dataview Query Language)的语法

  1. 先选择要怎么展示文件(有list或table或task)
    1. 直接在第一行写list或table或task即可
  2. 选择展示的文件范围(可以选择文件夹或标签)
    1. 在新的一行写上from "文件夹名"from #标签
    2. 如果不写,就默认是所有文件
  3. 填写以文件为单位的过滤条件
    1. 在新的一行写where 针对每个文件元数据的条件表达式
      1. 元数据的来源
        1. 官方自动为每个文件索引的元数据
          • file.name: The file title (a string).
          • file.folder: The path of the folder this file belongs to.
          • file.path: The full file path (a string).
          • file.link: A link to the file (a link).
          • file.size: The size (in bytes) of the file (a number).
          • file.ctime: The date that the file was created (a date + time).
          • file.cday: The date that the file was created (just a date).
          • file.mtime: The date that the file was last modified (a date + time).
          • file.mday: The date that the file was last modified (just a date).
          • file.tags: An array of all unique tags in the note. Subtags are broken down by each level, so will be stored in the array as #Tag/1/A``[#Tag, #Tag/1, #Tag/1/A]
          • file.etags: An array of all explicit tags in the note; unlikefile.tags , does not include subtags.
          • file.inlinks: An array of all incoming links to this file.
          • file.outlinks: An array of all outgoing links from this file.
          • file.aliases: An array of all aliases for the note.
          • file.tasks: An array of all tasks (I.e.- [ ] blah blah blah, ) in this file.
        2. 自定义添加的元数据
          1. YAML格式在文件头创建键值对
      2. 对元数据的处理
        1. 官方内置封装了非常多的处理函数,直接调用即可
          1. 详见该官方文档功能 - 数据视图 (blacksmithgu.github.io)
      3. 条件判断函数
        1. 官方内置封装了很多条件判断函数
          1. 详见该官方文档功能 - 数据视图 (blacksmithgu.github.io)
        2. 一些常用的判断函数总结
          1. regexmatch(".*测试类1-1.*", join(file.etags))
            1. ragexmatch用第一个参数的正则表达式(用""括起来,默认有/^ $/把第一个参数包围起来)来匹配第二个参数的字符串
            2. join把数组按第二个参数指定的分割符连成一个字符串,默认分隔符为逗号.
    2. 当一个文件的元数据导致条件表达式最终为ture时,该文件就会被展示出来