Routing

In Gustwind, routes are defined using configuration. The model favors explicity over implicity and it supports nesting. Thanks to nesting, you can implement features like i18n and generate a blog or pages to the site root as in the example below.

Routes define how project layouts are combined with data sources and what kind of metadata is injected to them. In short, they are glue of each site.

The example below shows how the structure of this site has been defined:

routes.json

{
  "/": {
    "layout": "siteIndex",
    "meta": {
      "title": "Gustwind",
      "description": "Deno powered JSON oriented site generator"
    },
    "dataSources": [{ "operation": "readme", "name": "readme" }],
    "expand": {
      "matchBy": {
        "dataSource": { "operation": "documentation", "name": "document" },
        "slug": "data.slug"
      },
      "layout": "documentationPage",
      "meta": {
        "title": {
          "utility": "get",
          "parameters": ["context", "document.data.title"]
        },
        "description": {
          "utility": "get",
          "parameters": ["context", "document.data.description"]
        }
      }
    }
  },
  "breezewind": {
    "layout": "documentationPage",
    "meta": {
      "title": "Breezewind",
      "description": "Breezing fast templating"
    },
    "dataSources": [{ "operation": "parseHeadmatter", "name": "document" }],
    "scripts": ["playground"]
  },
  "blog": {
    "layout": "blogIndex",
    "meta": {
      "title": "Blog",
      "description": "A blog about Gustwind"
    },
    "dataSources": [{ "operation": "blogPosts", "name": "blogPosts" }],
    "expand": {
      "matchBy": {
        "dataSource": { "operation": "blogPosts", "name": "document" },
        "slug": "data.slug"
      },
      "layout": "blogPage",
      "meta": {
        "title": {
          "utility": "get",
          "parameters": ["context", "document.data.title"]
        },
        "description": {
          "utility": "get",
          "parameters": ["context", "document.data.description"]
        }
      }
    }
  },
  "buttons": {
    "layout": "buttonsPage",
    "meta": {
      "title": "Gustwind buttons",
      "description": "Secret buttons page"
    },
    "scripts": ["hello"],
    "routes": {
      "more": {
        "layout": "buttonsPage",
        "meta": {
          "title": "More Gustwind buttons",
          "description": "Another secret buttons page"
        },
        "scripts": ["hello"]
      }
    }
  },
  "atom.xml": {
    "layout": "rssPage",
    "meta": {
      "title": "Gustwind",
      "description": "Gustwind blog"
    },
    "dataSources": [{ "operation": "blogPosts", "name": "blogPosts" }],
    "type": "xml"
  }
}