Live Vault Metrics
WIDGETDASHBOARD
maws7140

Live Vault Metrics

Total notes, notes edited this week and notes created this week, counted live from your vault.

What you need

  • The Datacore community plugin (Settings → Community plugins → Browse, search "Datacore").
  • The VaultHub widgets CSS snippet: download vaulthub-widgets.css, save it in your vault's .obsidian/snippets/ folder, then switch it on under Settings → Appearance → CSS snippets. One snippet styles every VaultHub widget.

Add it to a note

Paste the block below into any note. It renders in Live Preview and Reading view.

return function VaultMetrics() {
    const pages = dc.useQuery("@page") || [];
    const WEEK = 86400000 * 7;
    const now = new Date();
    const edited = pages.filter(p => (now - new Date(p.$mtime)) < WEEK).length;
    const created = pages.filter(p => (now - new Date(p.$ctime)) < WEEK).length;

    return (
        <div className="vh-widget vh-vault-stats">
            <div className="vh-vs-title vh-icon-label">
                VAULT METRICS
            </div>
            <div className="vh-vs-grid">
                <div className="vh-vs-item">
                    <div className="vh-vs-num">{pages.length}</div>
                    <div className="vh-vs-lbl">TOTAL NOTES</div>
                </div>
                <div className="vh-vs-item">
                    <div className="vh-vs-num">{edited}</div>
                    <div className="vh-vs-lbl">EDITED (7D)</div>
                </div>
                <div className="vh-vs-item">
                    <div className="vh-vs-num">{created}</div>
                    <div className="vh-vs-lbl">NEW (7D)</div>
                </div>
            </div>
        </div>
    );
}

Related

How to Install

  1. Install the Datacore community plugin
  2. Add the VaultHub widgets CSS snippet to .obsidian/snippets/ and enable it
  3. Copy the code block on this page into any note

Required Plugins

Datacore

Categories

Tags

vaulthubstatsvaulthomepage