Quickstart

Setup

To create a hook, run Hook Create. You can set the hookName to hello and change the hookFilter to hello.*.

When you run this command, Dendron will do two things:

  1. Create an entry in dendron.yml about the hook
  2. Create {workspace}/hooks/{hookName}.js

This should lead to a page like the following:

/**
 @params wsRoot: string, root of your current workspace
 @params note: Object with following properties https://github.com/dendronhq/dendron/blob/master/packages/common-all/src/types/typesv2.ts
 @params NoteUtils: utilities for working with notes. [code](https://github.com/dendronhq/dendron/blob/master/packages/common-all/src/dnode.ts#L307:L307)
 @params execa: instance of [execa](https://github.com/sindresorhus/execa#execacommandcommand-options)
 @params _: instance of [lodash](https://lodash.com/docs)
 @params axios: instance of [axios](https://axios-http.com/docs/example)
 */
module.exports = async function({wsRoot, note, NoteUtils, execa, axios, _}) {
    // do some changes
    return {note};
};

  • add the following line to the change
module.exports = async function({wsRoot, note, NoteUtils, execa, _}) {
    note.body = note.body + "hello"
    return {note};
};

After you are done, run Reload Index. Now use lookup to create hello.one

You should get something like the following:

hooks image

Cleaning Up

To delete your hook, run Hook Delete. This will remove the hook entry in dendron.yml and also delete the hook script (script deletion is optional).


Backlinks