This article has been imported from and is not necessarily up to date!

Cover showing GatsbyJS & Leasot Logos

Gatsby Transformer Leasot

Last updated: 

Table of contents

So what does it do?

It extracts all comments in provided source files like the following

// TODO: water the seedlings

and makes them available to you via GrapqhQL as accessible object containing the comment along useful information.

  "todo": {
    "ref": "",
    "line": 1,
    "value": "find a more concise way",
    "file": {
      "relativePath": "gatsby-config.js"

How to install it

yarn add -D gatsby-transformer-leasot
# or
npm i -D gatsby-transformer-leasot

It requires: gatsby-source-filesystem, this way you can use a separate instance to define which files to source only used by gatsby-transformer-leasot.
You can use gatsby-theme-leasot for convenience.
Alternatively, since v1.2.0, you can bring your own source plugin and set the internalType accordingly.

How to configure it

module.exports = {
  plugins: [
      resolve: `gatsby-source-filesystem`,
      options: {
        path: __dirname,
        name: `leasot`,
        ignore: [

That's the minimum required setup using the defaults.

How to query

  sort: { fields: [todo___modifiedTime], order: DESC }
) {
  group(field: todo___tag) {
    nodes {
      todo {
        modifiedTime(formatString: "YYYY-MM-DD H:mm") # More about modifiedTime below
        file {

Note: The name allLeasot depends on the provided sourceInstanceName in the configs. So when you change it you have to change the name option of gatsby-source-filesystem accordingly, lets say todo then you query for allTodo or todo if you just want a single one.

All config options

| name                              | type            | default                     | description                                                                                                                                                                                                                                          |
| --------------------------------- | --------------- | --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| sourceInstanceName                | `string`        | 'leasot'                    | Has to match the `name` prop of `gatsby-source-filesystem`.                                                                                                                                                                                          |
| customTags                        | `array`         | []                          | Other tags to look for (besides todos and fixmes). Tags are case-insensitive and are strict matching, i.e PROD tag will match PROD but not PRODUCTS. More in [Leasot's Docs]( |
| mode                              | `string`        | 'text'                      | Supports one of: `text`, `mdx`, `html`.                                                                                                                                                                                                              |
| truncateLinks                     | `int`\|`object` | {length: 32,style: 'smart'} | Provide `int` to change the length only. `style` can be one of: `smart`, `middle`, `end`.                                                                                                                                                            |
| associateParser                   | `object`        | {}                          | Associate the filetypes with parsers. This allows adding support for new filetypes. More in [Leasot's Docs](                                                             |
| customParsers                     | `object`        | {}                          | Extend the parsers by parserName, for example override the defaultParser or add a new parser. [Leasot's Docs](                                                             |
| internalType <br/> (since v1.2.0) | `string`        | "File"                      | Has to match `node.internal.type`                                                                                                                                                                                                                    |

All by default supported languages (file extensions) can be found in Leasot's Readme

More examples

// FIXME(Reference): improve example
// TODO: you can add a reference like this as well /Reference
// TODO: example without reference

See the full supported comment format by Leasot in their readme.


Even though the node in GraphQL also provides modifiedTime of the file it's currently only locally useful as file times will all be the same on CI. I don't have an easy fix for that so far.

Alternative todo lists

I've installed & tried VSCode extensions like TODO Highlight and some others yet never really remember to let them generate the list to see my notes. Global search could work, too. Yet I find this automatic integration much more pleasing. And making it public kinda helps at least trying to get back to those notes so they won't stick around forever 😅. Let's see how that goes 🤓.

The near future

This website is not only meant as my / GaiAma's dev knowledge base, but as a playground and place to try things out before implementing on 😉

My next plans are improving the donation experience on, then, or maybe along that, improving the various open source projects and probably releasing more stuff, not just to share them with others but with myself, too. 😁

Some time in the near future I think about merging this repository with GaiAma/, not exactly sure about that though. 🤔 One benefit would be that the roadmap could then easily show notes as well, without having to source it from GitHub. Just thinking out loud.

By the way

truncateLinks uses remark-truncate-links which I open sourced separately. I use it for all MDX content as well. It'll truncate all links not manually named. Go check it out 🤩

Find it on GitHub & NPM

Can Rau
Can Rau

Doing web-development since around 2000, building my digital garden with a mix of back-to-the-roots-use-the-platform and modern edge-rendered-client-side-magic tech 📻🚀

Living and working in Cusco, Perú 🦙