Frontity update: 10 October 2019 - Support for Custom Post Types & Custom Taxonomies

We have added support for Custom Post Types and Custom Taxonomies!

You just need to configure them in your frontity.settings.js – inside the wp-source package – adding the following options:

  • postTypes: array of post type definitions with the properties type, endpoint and archive (more info here).
  • taxonomies: array of taxonomy definitions with the properties taxonomy, endpoint, postTypeEndpoint and params (more info here).

An example using both options would be:

{
  name: "@frontity/wp-source",
  state: {
    source: {
      api: "https://test.frontity.io/wp-json",
      postTypes: [
        {
          type: "movies", // type slug
          endpoint: "movies", // REST API endpoint
          archive: "/movies-archive" // link where this custom posts are listed
        }
      ],
      taxonomies: [
        {
          taxonomy: "actors", // taxonomy slug
          endpoint: "actor", // REST API endpoint
          postTypeEndpoint: "movies", // endpoint from which posts from this taxonomy are fetched
        }
      ]
    }
  }
}

After that, you can cosume and use these Custom Post Types and Taxonomies the same way you were doing with posts and categories or tags before.


Another important updates:

  • We have added the create-package command to our CLI. With this command, you can add empty packages to your project and start developing themes and other type of packages from scratch.

    It has the following syntax:

    npx frontity create-package [name] [--namespace <value>]
    

    NOTE: If you don’t specify name or namespace you will be prompted to do so, as these values are mandatory.

    The newly created package is ready-to-use – just add it to your frontity.settings.js as the rest of packages.

  • We have added the --dont-open-browser option to the dev command (the name is self-explanatory).

  • We have fixed a problem in the <Image> component when using native lazy-loading in Chrome if the height prop was not present.

  • We also made some improvements to mars-theme (#203) and created the package type-declarations (#211).

Features

  • cli: add --dont-open-browser option to dev (6ae037c)
  • frontity: add create-package command (#218) (eac88fd)
  • wp-source: add postTypes and taxonomies arrays to state (8f8fce3)

Bug Fixes

  • image: add height prop and set loading=auto if no height is present (9870414)
  • core: delete package name from merged store (7428a90)
  • typescript: update to latest version (a89b11c)

Versions

 - @frontity/[email protected]
 - @frontity/[email protected]
 - @frontity/[email protected]
 - @frontity/[email protected]
 - [email protected]
 - @frontity/[email protected]
 - @frontity/[email protected]
 - @frontity/[email protected]
 - @frontity/[email protected]
 - @frontity/[email protected]
 - @frontity/[email protected]
 - @frontity/[email protected]
 - @frontity/[email protected]
 - @frontity/[email protected]
 - @frontity/[email protected]
7 Likes

What’s the command to update frontity? Do we just run npm update in the root of our webserver or is there an npx command we should use?

Updating npm packages is not very straightforward so we made a small guide in our docs: https://docs.frontity.org/guides/keep-frontity-updated

Let me know if that helps :slight_smile:

1 Like

Yes it does. Works great! Thanks!

2 Likes