obsidian-bases

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Obsidian Bases Skill

Obsidian Bases 技能

This skill enables skills-compatible agents to create and edit valid Obsidian Bases (
.base
files) including views, filters, formulas, and all related configurations.
本技能支持兼容技能的Agent创建和编辑有效的Obsidian Bases(
.base
文件),包括视图、过滤器、公式及所有相关配置。

When to Use

适用场景

  • Designing or updating
    .base
    files to surface filtered views, tables, cards, or summaries inside Obsidian.
  • Configuring formulas, filters, or summaries that rely on file metadata, frontmatter, or computed values.
  • Converting scattered notes into cohesive database-like views for tracking projects, tasks, or research.
  • 设计或更新
    .base
    文件,在Obsidian中展示经过筛选的视图、表格、卡片或摘要。
  • 配置依赖文件元数据、前置属性或计算值的公式、过滤器或摘要。
  • 将分散的笔记转换为类似数据库的统一视图,用于跟踪项目、任务或研究内容。

When NOT to Use

不适用场景

  • You only need plain Markdown editing without Obsidian Base-specific features.
  • The task is outside Obsidian (other editors or platforms) with no
    .base
    files involved.
  • You are exploring general YAML editing unrelated to views/filters/summaries.
  • 仅需纯Markdown编辑,无需Obsidian Bases专属功能。
  • 任务在Obsidian之外(其他编辑器或平台),且不涉及
    .base
    文件。
  • 探索与视图/过滤器/摘要无关的通用YAML编辑。

Overview

概述

Obsidian Bases are YAML-based files that define dynamic views of notes in an Obsidian vault. A Base file can contain multiple views, global filters, formulas, property configurations, and custom summaries.
Obsidian Bases是基于YAML的文件,用于定义Obsidian库中笔记的动态视图。一个Base文件可包含多个视图、全局过滤器、公式、属性配置和自定义摘要。

File Format

文件格式

Base files use the
.base
extension and contain valid YAML. They can also be embedded in Markdown code blocks.
Base文件使用
.base
扩展名,内容为有效的YAML。也可嵌入到Markdown代码块中。

Complete Schema

完整Schema

yaml
undefined
yaml
undefined

Global filters apply to ALL views in the base

全局过滤器对Base中的所有视图生效

filters:

Can be a single filter string

OR a recursive filter object with and/or/not

and: [] or: [] not: []
filters:

可以是单个过滤器字符串

或是包含and/or/not的递归过滤器对象

and: [] or: [] not: []

Define formula properties that can be used across all views

定义可在所有视图中使用的公式属性

formulas: formula_name: 'expression'
formulas: formula_name: 'expression'

Configure display names and settings for properties

配置属性的显示名称和设置

properties: property_name: displayName: "Display Name" formula.formula_name: displayName: "Formula Display Name" file.ext: displayName: "Extension"
properties: property_name: displayName: "Display Name" formula.formula_name: displayName: "Formula Display Name" file.ext: displayName: "Extension"

Define custom summary formulas

定义自定义摘要公式

summaries: custom_summary_name: 'values.mean().round(3)'
summaries: custom_summary_name: 'values.mean().round(3)'

Define one or more views

定义一个或多个视图

views:
  • type: table | cards | list | map name: "View Name" limit: 10 # Optional: limit results groupBy: # Optional: group results property: property_name direction: ASC | DESC filters: # View-specific filters and: [] order: # Properties to display in order
    • file.name
    • property_name
    • formula.formula_name summaries: # Map properties to summary formulas property_name: Average
undefined
views:
  • type: table | cards | list | map name: "View Name" limit: 10 # 可选:限制结果数量 groupBy: # 可选:对结果分组 property: property_name direction: ASC | DESC filters: # 视图专属过滤器 and: [] order: # 要显示的属性顺序
    • file.name
    • property_name
    • formula.formula_name summaries: # 将属性映射到摘要公式 property_name: Average
undefined

Filter Syntax

过滤器语法

Filters narrow down results. They can be applied globally or per-view.
过滤器用于缩小结果范围,可全局应用或按视图应用。

Filter Structure

过滤器结构

yaml
undefined
yaml
undefined

Single filter

单个过滤器

filters: 'status == "done"'
filters: 'status == "done"'

AND - all conditions must be true

AND - 所有条件必须为真

filters: and: - 'status == "done"' - 'priority > 3'
filters: and: - 'status == "done"' - 'priority > 3'

OR - any condition can be true

OR - 任一条件为真即可

filters: or: - 'file.hasTag("book")' - 'file.hasTag("article")'
filters: or: - 'file.hasTag("book")' - 'file.hasTag("article")'

NOT - exclude matching items

NOT - 排除匹配项

filters: not: - 'file.hasTag("archived")'
filters: not: - 'file.hasTag("archived")'

Nested filters

嵌套过滤器

filters: or: - file.hasTag("tag") - and: - file.hasTag("book") - file.hasLink("Textbook") - not: - file.hasTag("book") - file.inFolder("Required Reading")
undefined
filters: or: - file.hasTag("tag") - and: - file.hasTag("book") - file.hasLink("Textbook") - not: - file.hasTag("book") - file.inFolder("Required Reading")
undefined

Filter Operators

过滤器运算符

OperatorDescription
==
equals
!=
not equal
>
greater than
<
less than
>=
greater than or equal
<=
less than or equal
&&
logical and
||
logical or
<code>!</code>logical not
运算符描述
==
等于
!=
不等于
>
大于
<
小于
>=
大于等于
<=
小于等于
&&
逻辑与
||
逻辑或
<code>!</code>逻辑非

Properties

属性

Three Types of Properties

三种属性类型

  1. Note properties - From frontmatter:
    note.author
    or just
    author
  2. File properties - File metadata:
    file.name
    ,
    file.mtime
    , etc.
  3. Formula properties - Computed values:
    formula.my_formula
  1. 笔记属性 - 来自前置属性:
    note.author
    或直接写
    author
  2. 文件属性 - 文件元数据:
    file.name
    ,
    file.mtime
  3. 公式属性 - 计算值:
    formula.my_formula

File Properties Reference

文件属性参考

PropertyTypeDescription
file.name
StringFile name
file.basename
StringFile name without extension
file.path
StringFull path to file
file.folder
StringParent folder path
file.ext
StringFile extension
file.size
NumberFile size in bytes
file.ctime
DateCreated time
file.mtime
DateModified time
file.tags
ListAll tags in file
file.links
ListInternal links in file
file.backlinks
ListFiles linking to this file
file.embeds
ListEmbeds in the note
file.properties
ObjectAll frontmatter properties
属性类型描述
file.name
字符串文件名
file.basename
字符串不含扩展名的文件名
file.path
字符串文件完整路径
file.folder
字符串父文件夹路径
file.ext
字符串文件扩展名
file.size
数字文件大小(字节)
file.ctime
日期创建时间
file.mtime
日期修改时间
file.tags
列表文件中的所有标签
file.links
列表文件中的内部链接
file.backlinks
列表链接到本文件的文件
file.embeds
列表笔记中的嵌入内容
file.properties
对象所有前置属性

The
this
Keyword

this
关键字

  • In main content area: refers to the base file itself
  • When embedded: refers to the embedding file
  • In sidebar: refers to the active file in main content
  • 在主内容区域:指代Base文件本身
  • 嵌入时:指代嵌入该Base的文件
  • 在侧边栏:指代主内容区域的活动文件

Formula Syntax

公式语法

Formulas compute values from properties. Defined in the
formulas
section.
yaml
formulas:
  # Simple arithmetic
  total: "price * quantity"

  # Conditional logic
  status_icon: 'if(done, "✅", "⏳")'

  # String formatting
  formatted_price: 'if(price, price.toFixed(2) + " dollars")'

  # Date formatting
  created: 'file.ctime.format("YYYY-MM-DD")'

  # Calculate days since created (use .days for Duration)
  days_old: '(now() - file.ctime).days'

  # Calculate days until due date
  days_until_due: 'if(due_date, (date(due_date) - today()).days, "")'
公式用于通过属性计算值,定义在
formulas
区域。
yaml
formulas:
  # 简单算术运算
  total: "price * quantity"

  # 条件逻辑
  status_icon: 'if(done, "✅", "⏳")'

  # 字符串格式化
  formatted_price: 'if(price, price.toFixed(2) + " dollars")'

  # 日期格式化
  created: 'file.ctime.format("YYYY-MM-DD")'

  # 计算创建后已过去的天数(使用.days获取时长)
  days_old: '(now() - file.ctime).days'

  # 计算距离截止日期的天数
  days_until_due: 'if(due_date, (date(due_date) - today()).days, "")'

Functions Reference

函数参考

Global Functions

全局函数

FunctionSignatureDescription
date()
date(string): date
Parse string to date. Format:
YYYY-MM-DD HH:mm:ss
duration()
duration(string): duration
Parse duration string
now()
now(): date
Current date and time
today()
today(): date
Current date (time = 00:00:00)
if()
if(condition, trueResult, falseResult?)
Conditional
min()
min(n1, n2, ...): number
Smallest number
max()
max(n1, n2, ...): number
Largest number
number()
number(any): number
Convert to number
link()
link(path, display?): Link
Create a link
list()
list(element): List
Wrap in list if not already
file()
file(path): file
Get file object
image()
image(path): image
Create image for rendering
icon()
icon(name): icon
Lucide icon by name
html()
html(string): html
Render as HTML
escapeHTML()
escapeHTML(string): string
Escape HTML characters
函数签名描述
date()
date(string): date
将字符串解析为日期,格式:
YYYY-MM-DD HH:mm:ss
duration()
duration(string): duration
解析时长字符串
now()
now(): date
当前日期和时间
today()
today(): date
当前日期(时间为00:00:00)
if()
if(condition, trueResult, falseResult?)
条件判断
min()
min(n1, n2, ...): number
最小值
max()
max(n1, n2, ...): number
最大值
number()
number(any): number
转换为数字
link()
link(path, display?): Link
创建链接
list()
list(element): List
若不是列表则包装为列表
file()
file(path): file
获取文件对象
image()
image(path): image
创建用于渲染的图片
icon()
icon(name): icon
通过名称获取Lucide图标
html()
html(string): html
以HTML形式渲染
escapeHTML()
escapeHTML(string): string
转义HTML字符

Any Type Functions

任意类型函数

FunctionSignatureDescription
isTruthy()
any.isTruthy(): boolean
Coerce to boolean
isType()
any.isType(type): boolean
Check type
toString()
any.toString(): string
Convert to string
函数签名描述
isTruthy()
any.isTruthy(): boolean
转换为布尔值
isType()
any.isType(type): boolean
检查类型
toString()
any.toString(): string
转换为字符串

Date Functions & Fields

日期函数与字段

Fields:
date.year
,
date.month
,
date.day
,
date.hour
,
date.minute
,
date.second
,
date.millisecond
FunctionSignatureDescription
date()
date.date(): date
Remove time portion
format()
date.format(string): string
Format with Moment.js pattern
time()
date.time(): string
Get time as string
relative()
date.relative(): string
Human-readable relative time
isEmpty()
date.isEmpty(): boolean
Always false for dates
字段:
date.year
,
date.month
,
date.day
,
date.hour
,
date.minute
,
date.second
,
date.millisecond
函数签名描述
date()
date.date(): date
移除时间部分
format()
date.format(string): string
使用Moment.js格式字符串格式化日期
time()
date.time(): string
获取时间字符串
relative()
date.relative(): string
人类可读的相对时间
isEmpty()
date.isEmpty(): boolean
对于日期始终返回false

Duration Type

时长类型

When subtracting two dates, the result is a Duration type (not a number). Duration has its own properties and methods.
Duration Fields:
FieldTypeDescription
duration.days
NumberTotal days in duration
duration.hours
NumberTotal hours in duration
duration.minutes
NumberTotal minutes in duration
duration.seconds
NumberTotal seconds in duration
duration.milliseconds
NumberTotal milliseconds in duration
IMPORTANT: Duration does NOT support
.round()
,
.floor()
,
.ceil()
directly. You must access a numeric field first (like
.days
), then apply number functions.
yaml
undefined
两个日期相减的结果是Duration类型(而非数字),时长有专属的属性和方法。
时长字段:
字段类型描述
duration.days
数字时长的总天数
duration.hours
数字时长的总小时数
duration.minutes
数字时长的总分钟数
duration.seconds
数字时长的总秒数
duration.milliseconds
数字时长的总毫秒数
重要提示: 时长类型不直接支持
.round()
.floor()
.ceil()
方法,必须先获取数值字段(如
.days
),再应用数字函数。
yaml
undefined

CORRECT: Calculate days between dates

正确写法:计算两个日期之间的天数

"(date(due_date) - today()).days" # Returns number of days "(now() - file.ctime).days" # Days since created
"(date(due_date) - today()).days" # 返回天数 "(now() - file.ctime).days" # 已创建天数

CORRECT: Round the numeric result if needed

正确写法:如需对结果取整

"(date(due_date) - today()).days.round(0)" # Rounded days "(now() - file.ctime).hours.round(0)" # Rounded hours
"(date(due_date) - today()).days.round(0)" # 取整后的天数 "(now() - file.ctime).hours.round(0)" # 取整后的小时数

WRONG - will cause error:

错误写法 - 会导致报错:

"((date(due) - today()) / 86400000).round(0)" # Duration doesn't support division then round

"((date(due) - today()) / 86400000).round(0)" # 时长类型不支持除法后取整

undefined
undefined

Date Arithmetic

日期运算

yaml
undefined
yaml
undefined

Duration units: y/year/years, M/month/months, d/day/days,

时长单位:y/year/years, M/month/months, d/day/days,

w/week/weeks, h/hour/hours, m/minute/minutes, s/second/seconds

w/week/weeks, h/hour/hours, m/minute/minutes, s/second/seconds

Add/subtract durations

增加/减少时长

"date + "1M"" # Add 1 month "date - "2h"" # Subtract 2 hours "now() + "1 day"" # Tomorrow "today() + "7d"" # A week from today
"date + "1M"" # 增加1个月 "date - "2h"" # 减少2小时 "now() + "1 day"" # 明天 "today() + "7d"" # 一周后

Subtract dates returns Duration type

日期相减返回时长类型

"now() - file.ctime" # Returns Duration "(now() - file.ctime).days" # Get days as number "(now() - file.ctime).hours" # Get hours as number
"now() - file.ctime" # 返回时长 "(now() - file.ctime).days" # 获取天数 "(now() - file.ctime).hours" # 获取小时数

Complex duration arithmetic

复杂时长运算

"now() + (duration('1d') * 2)"
undefined
"now() + (duration('1d') * 2)"
undefined

String Functions

字符串函数

Field:
string.length
FunctionSignatureDescription
contains()
string.contains(value): boolean
Check substring
containsAll()
string.containsAll(...values): boolean
All substrings present
containsAny()
string.containsAny(...values): boolean
Any substring present
startsWith()
string.startsWith(query): boolean
Starts with query
endsWith()
string.endsWith(query): boolean
Ends with query
isEmpty()
string.isEmpty(): boolean
Empty or not present
lower()
string.lower(): string
To lowercase
title()
string.title(): string
To Title Case
trim()
string.trim(): string
Remove whitespace
replace()
string.replace(pattern, replacement): string
Replace pattern
repeat()
string.repeat(count): string
Repeat string
reverse()
string.reverse(): string
Reverse string
slice()
string.slice(start, end?): string
Substring
split()
string.split(separator, n?): list
Split to list
字段:
string.length
函数签名描述
contains()
string.contains(value): boolean
检查是否包含子字符串
containsAll()
string.containsAll(...values): boolean
是否包含所有指定子字符串
containsAny()
string.containsAny(...values): boolean
是否包含任一指定子字符串
startsWith()
string.startsWith(query): boolean
是否以指定字符串开头
endsWith()
string.endsWith(query): boolean
是否以指定字符串结尾
isEmpty()
string.isEmpty(): boolean
是否为空或不存在
lower()
string.lower(): string
转换为小写
title()
string.title(): string
转换为标题格式
trim()
string.trim(): string
去除首尾空格
replace()
string.replace(pattern, replacement): string
替换指定模式内容
repeat()
string.repeat(count): string
重复字符串指定次数
reverse()
string.reverse(): string
反转字符串
slice()
string.slice(start, end?): string
截取子字符串
split()
string.split(separator, n?): list
按分隔符分割为列表

Number Functions

数字函数

FunctionSignatureDescription
abs()
number.abs(): number
Absolute value
ceil()
number.ceil(): number
Round up
floor()
number.floor(): number
Round down
round()
number.round(digits?): number
Round to digits
toFixed()
number.toFixed(precision): string
Fixed-point notation
isEmpty()
number.isEmpty(): boolean
Not present
函数签名描述
abs()
number.abs(): number
绝对值
ceil()
number.ceil(): number
向上取整
floor()
number.floor(): number
向下取整
round()
number.round(digits?): number
四舍五入到指定位数
toFixed()
number.toFixed(precision): string
转换为固定小数位数的字符串
isEmpty()
number.isEmpty(): boolean
是否不存在

List Functions

列表函数

Field:
list.length
FunctionSignatureDescription
contains()
list.contains(value): boolean
Element exists
containsAll()
list.containsAll(...values): boolean
All elements exist
containsAny()
list.containsAny(...values): boolean
Any element exists
filter()
list.filter(expression): list
Filter by condition (uses
value
,
index
)
map()
list.map(expression): list
Transform elements (uses
value
,
index
)
reduce()
list.reduce(expression, initial): any
Reduce to single value (uses
value
,
index
,
acc
)
flat()
list.flat(): list
Flatten nested lists
join()
list.join(separator): string
Join to string
reverse()
list.reverse(): list
Reverse order
slice()
list.slice(start, end?): list
Sublist
sort()
list.sort(): list
Sort ascending
unique()
list.unique(): list
Remove duplicates
isEmpty()
list.isEmpty(): boolean
No elements
字段:
list.length
函数签名描述
contains()
list.contains(value): boolean
列表中是否包含指定元素
containsAll()
list.containsAll(...values): boolean
列表中是否包含所有指定元素
containsAny()
list.containsAny(...values): boolean
列表中是否包含任一指定元素
filter()
list.filter(expression): list
按条件过滤列表(使用
value
index
map()
list.map(expression): list
转换列表元素(使用
value
index
reduce()
list.reduce(expression, initial): any
将列表归约为单个值(使用
value
index
acc
flat()
list.flat(): list
展平嵌套列表
join()
list.join(separator): string
将列表元素连接为字符串
reverse()
list.reverse(): list
反转列表顺序
slice()
list.slice(start, end?): list
截取子列表
sort()
list.sort(): list
升序排序
unique()
list.unique(): list
移除重复元素
isEmpty()
list.isEmpty(): boolean
列表是否为空

File Functions

文件函数

FunctionSignatureDescription
asLink()
file.asLink(display?): Link
Convert to link
hasLink()
file.hasLink(otherFile): boolean
Has link to file
hasTag()
file.hasTag(...tags): boolean
Has any of the tags
hasProperty()
file.hasProperty(name): boolean
Has property
inFolder()
file.inFolder(folder): boolean
In folder or subfolder
函数签名描述
asLink()
file.asLink(display?): Link
转换为链接
hasLink()
file.hasLink(otherFile): boolean
是否链接到指定文件
hasTag()
file.hasTag(...tags): boolean
是否包含任一指定标签
hasProperty()
file.hasProperty(name): boolean
是否包含指定属性
inFolder()
file.inFolder(folder): boolean
是否在指定文件夹或其子文件夹中

Link Functions

链接函数

FunctionSignatureDescription
asFile()
link.asFile(): file
Get file object
linksTo()
link.linksTo(file): boolean
Links to file
函数签名描述
asFile()
link.asFile(): file
获取对应的文件对象
linksTo()
link.linksTo(file): boolean
是否链接到指定文件

Object Functions

对象函数

FunctionSignatureDescription
isEmpty()
object.isEmpty(): boolean
No properties
keys()
object.keys(): list
List of keys
values()
object.values(): list
List of values
函数签名描述
isEmpty()
object.isEmpty(): boolean
对象是否无属性
keys()
object.keys(): list
获取对象的键列表
values()
object.values(): list
获取对象的值列表

Regular Expression Functions

正则表达式函数

FunctionSignatureDescription
matches()
regexp.matches(string): boolean
Test if matches
函数签名描述
matches()
regexp.matches(string): boolean
测试字符串是否匹配正则表达式

View Types

视图类型

Table View

表格视图

yaml
views:
  - type: table
    name: "My Table"
    order:
      - file.name
      - status
      - due_date
    summaries:
      price: Sum
      count: Average
yaml
views:
  - type: table
    name: "我的表格"
    order:
      - file.name
      - status
      - due_date
    summaries:
      price: Sum
      count: Average

Cards View

卡片视图

yaml
views:
  - type: cards
    name: "Gallery"
    order:
      - file.name
      - cover_image
      - description
yaml
views:
  - type: cards
    name: "图库"
    order:
      - file.name
      - cover_image
      - description

List View

列表视图

yaml
views:
  - type: list
    name: "Simple List"
    order:
      - file.name
      - status
yaml
views:
  - type: list
    name: "简单列表"
    order:
      - file.name
      - status

Map View

地图视图

Requires latitude/longitude properties and the Maps community plugin.
yaml
views:
  - type: map
    name: "Locations"
    # Map-specific settings for lat/lng properties
需要经纬度属性和Maps社区插件。
yaml
views:
  - type: map
    name: "位置"
    # 地图专属的经纬度属性设置

Default Summary Formulas

默认摘要公式

NameInput TypeDescription
Average
NumberMathematical mean
Min
NumberSmallest number
Max
NumberLargest number
Sum
NumberSum of all numbers
Range
NumberMax - Min
Median
NumberMathematical median
Stddev
NumberStandard deviation
Earliest
DateEarliest date
Latest
DateLatest date
Range
DateLatest - Earliest
Checked
BooleanCount of true values
Unchecked
BooleanCount of false values
Empty
AnyCount of empty values
Filled
AnyCount of non-empty values
Unique
AnyCount of unique values
名称输入类型描述
Average
数字算术平均值
Min
数字最小值
Max
数字最大值
Sum
数字求和
Range
数字最大值减最小值
Median
数字中位数
Stddev
数字标准差
Earliest
日期最早日期
Latest
日期最晚日期
Range
日期最晚日期减最早日期
Checked
布尔值真值数量
Unchecked
布尔值假值数量
Empty
任意类型空值数量
Filled
任意类型非空值数量
Unique
任意类型唯一值数量

Complete Examples

完整示例

Task Tracker Base

任务追踪Base

yaml
filters:
  and:
    - file.hasTag("task")
    - 'file.ext == "md"'

formulas:
  days_until_due: 'if(due, (date(due) - today()).days, "")'
  is_overdue: 'if(due, date(due) < today() && status != "done", false)'
  priority_label: 'if(priority == 1, "🔴 High", if(priority == 2, "🟡 Medium", "🟢 Low"))'

properties:
  status:
    displayName: Status
  formula.days_until_due:
    displayName: "Days Until Due"
  formula.priority_label:
    displayName: Priority

views:
  - type: table
    name: "Active Tasks"
    filters:
      and:
        - 'status != "done"'
    order:
      - file.name
      - status
      - formula.priority_label
      - due
      - formula.days_until_due
    groupBy:
      property: status
      direction: ASC
    summaries:
      formula.days_until_due: Average

  - type: table
    name: "Completed"
    filters:
      and:
        - 'status == "done"'
    order:
      - file.name
      - completed_date
yaml
filters:
  and:
    - file.hasTag("task")
    - 'file.ext == "md"'

formulas:
  days_until_due: 'if(due, (date(due) - today()).days, "")'
  is_overdue: 'if(due, date(due) < today() && status != "done", false)'
  priority_label: 'if(priority == 1, "🔴 高", if(priority == 2, "🟡 中", "🟢 低"))'

properties:
  status:
    displayName: 状态
  formula.days_until_due:
    displayName: "距离截止日期天数"
  formula.priority_label:
    displayName: 优先级

views:
  - type: table
    name: "活跃任务"
    filters:
      and:
        - 'status != "done"'
    order:
      - file.name
      - status
      - formula.priority_label
      - due
      - formula.days_until_due
    groupBy:
      property: status
      direction: ASC
    summaries:
      formula.days_until_due: Average

  - type: table
    name: "已完成"
    filters:
      and:
        - 'status == "done"'
    order:
      - file.name
      - completed_date

Reading List Base

阅读清单Base

yaml
filters:
  or:
    - file.hasTag("book")
    - file.hasTag("article")

formulas:
  reading_time: 'if(pages, (pages * 2).toString() + " min", "")'
  status_icon: 'if(status == "reading", "📖", if(status == "done", "✅", "📚"))'
  year_read: 'if(finished_date, date(finished_date).year, "")'

properties:
  author:
    displayName: Author
  formula.status_icon:
    displayName: ""
  formula.reading_time:
    displayName: "Est. Time"

views:
  - type: cards
    name: "Library"
    order:
      - cover
      - file.name
      - author
      - formula.status_icon
    filters:
      not:
        - 'status == "dropped"'

  - type: table
    name: "Reading List"
    filters:
      and:
        - 'status == "to-read"'
    order:
      - file.name
      - author
      - pages
      - formula.reading_time
yaml
filters:
  or:
    - file.hasTag("book")
    - file.hasTag("article")

formulas:
  reading_time: 'if(pages, (pages * 2).toString() + " 分钟", "")'
  status_icon: 'if(status == "reading", "📖", if(status == "done", "✅", "📚"))'
  year_read: 'if(finished_date, date(finished_date).year, "")'

properties:
  author:
    displayName: 作者
  formula.status_icon:
    displayName: ""
  formula.reading_time:
    displayName: "预计时长"

views:
  - type: cards
    name: "图书馆"
    order:
      - cover
      - file.name
      - author
      - formula.status_icon
    filters:
      not:
        - 'status == "dropped"'

  - type: table
    name: "阅读清单"
    filters:
      and:
        - 'status == "to-read"'
    order:
      - file.name
      - author
      - pages
      - formula.reading_time

Project Notes Base

项目笔记Base

yaml
filters:
  and:
    - file.inFolder("Projects")
    - 'file.ext == "md"'

formulas:
  last_updated: 'file.mtime.relative()'
  link_count: 'file.links.length'

summaries:
  avgLinks: 'values.filter(value.isType("number")).mean().round(1)'

properties:
  formula.last_updated:
    displayName: "Updated"
  formula.link_count:
    displayName: "Links"

views:
  - type: table
    name: "All Projects"
    order:
      - file.name
      - status
      - formula.last_updated
      - formula.link_count
    summaries:
      formula.link_count: avgLinks
    groupBy:
      property: status
      direction: ASC

  - type: list
    name: "Quick List"
    order:
      - file.name
      - status
yaml
filters:
  and:
    - file.inFolder("Projects")
    - 'file.ext == "md"'

formulas:
  last_updated: 'file.mtime.relative()'
  link_count: 'file.links.length'

summaries:
  avgLinks: 'values.filter(value.isType("number")).mean().round(1)'

properties:
  formula.last_updated:
    displayName: "更新时间"
  formula.link_count:
    displayName: "链接数量"

views:
  - type: table
    name: "所有项目"
    order:
      - file.name
      - status
      - formula.last_updated
      - formula.link_count
    summaries:
      formula.link_count: avgLinks
    groupBy:
      property: status
      direction: ASC

  - type: list
    name: "快速列表"
    order:
      - file.name
      - status

Daily Notes Index

每日笔记索引

yaml
filters:
  and:
    - file.inFolder("Daily Notes")
    - '/^\d{4}-\d{2}-\d{2}$/.matches(file.basename)'

formulas:
  word_estimate: '(file.size / 5).round(0)'
  day_of_week: 'date(file.basename).format("dddd")'

properties:
  formula.day_of_week:
    displayName: "Day"
  formula.word_estimate:
    displayName: "~Words"

views:
  - type: table
    name: "Recent Notes"
    limit: 30
    order:
      - file.name
      - formula.day_of_week
      - formula.word_estimate
      - file.mtime
yaml
filters:
  and:
    - file.inFolder("Daily Notes")
    - '/^\d{4}-\d{2}-\d{2}$/.matches(file.basename)'

formulas:
  word_estimate: '(file.size / 5).round(0)'
  day_of_week: 'date(file.basename).format("dddd")'

properties:
  formula.day_of_week:
    displayName: "星期"
  formula.word_estimate:
    displayName: "~字数"

views:
  - type: table
    name: "近期笔记"
    limit: 30
    order:
      - file.name
      - formula.day_of_week
      - formula.word_estimate
      - file.mtime

Embedding Bases

嵌入Base

Embed in Markdown files:
markdown
![[MyBase.base]]

<!-- Specific view -->
![[MyBase.base#View Name]]
在Markdown文件中嵌入:
markdown
![[MyBase.base]]

<!-- 指定视图 -->
![[MyBase.base#视图名称]]

YAML Quoting Rules

YAML引号规则

  • Use single quotes for formulas containing double quotes:
    'if(done, "Yes", "No")'
  • Use double quotes for simple strings:
    "My View Name"
  • Escape nested quotes properly in complex expressions
  • 若公式包含双引号,使用单引号包裹:
    'if(done, "Yes", "No")'
  • 简单字符串使用双引号:
    "我的视图名称"
  • 复杂表达式中需正确转义嵌套引号

Common Patterns

常见模式

Filter by Tag

按标签过滤

yaml
filters:
  and:
    - file.hasTag("project")
yaml
filters:
  and:
    - file.hasTag("project")

Filter by Folder

按文件夹过滤

yaml
filters:
  and:
    - file.inFolder("Notes")
yaml
filters:
  and:
    - file.inFolder("Notes")

Filter by Date Range

按日期范围过滤

yaml
filters:
  and:
    - 'file.mtime > now() - "7d"'
yaml
filters:
  and:
    - 'file.mtime > now() - "7d"'

Filter by Property Value

按属性值过滤

yaml
filters:
  and:
    - 'status == "active"'
    - 'priority >= 3'
yaml
filters:
  and:
    - 'status == "active"'
    - 'priority >= 3'

Combine Multiple Conditions

组合多个条件

yaml
filters:
  or:
    - and:
        - file.hasTag("important")
        - 'status != "done"'
    - and:
        - 'priority == 1'
        - 'due != ""'
yaml
filters:
  or:
    - and:
        - file.hasTag("important")
        - 'status != "done"'
    - and:
        - 'priority == 1'
        - 'due != ""'

References

参考资料