In the last posthttps://publishing-project.rivendellweb.net/docs-as-code-the-technical-side/ we discussed the basic setup of a barebones Vuepress site. This post will cover some basic details of the theme: the navigation menu and the sidebar. To create the configuration you need to create the directory where Vuepress stores its data. From the root of the site create a .vuepress directory. bash mkdir -p /docs/.vuepress/ Inside the .vuepress directory, create a config.js file. The rest of the work will be done in this file. The first part of the module export declaration defines some basic metadata for the site. The head array will contain a list...
Docs as code is an interesting way to create documentation for software and technical projects. The idea is that we use the same tools to create our documentation that engineers or technical authors use to create their projects. According to Write the Docshttps://www.writethedocs.org/guide/docs-as-code/: Documentation as Code Docs as Code refers to a philosophy that you should be writing documentation with the same tools as code: - Issue Trackers - Version Control Git - Plain Text Markup Markdown, reStructuredText, Asciidoc - Code Reviews - Automated Tests This means the technical writing process follows the same workflows as the rest of the...
The last two articles on using Axios with the WordPress REST API has worked with standard items in the WordPress world like post and pages. WordPress also gives you the option of creating your own content types with Custom Post Typeshttps://wordpress.org/support/article/post-types/ CPTs We create custom post types in PHP, either in a theme's functions.php or in a plugin. When working with the REST API, the important configuration is showinrest. Specifying this attribute with a value of true will make the custom post type available in the WordPress API. The CPT definition for an essay CPT looks like this: php array...
As I'm learning the deep workings of the WordPress REST APIhttps://developer.wordpress.org/rest-api/ I'm also learning how to use Axioshttps://github.com/axios/axios as a replacement for Fetch. While I discovered that this will not work with Nuxt and the WordPress REST API, it's still a good starting point if you want to work with vanilla JS and templating engines. I am still researching how to make it work in Nuxt.js. Another thing that's important to note. Other than getJWT all other functions require authentication and I've chosen to use JSON Web Tokens JWThttps://jwt.io/introduction to authenticate the requests. The WordPress site uses the JWT Authentication...
While researching block-based themes I found more information about blocks themselves and how to write them in a way you can submit them for inclusion in the WordPress directory. Most, if not all our blocks, will not be dynamic so we won't cover them in this post, just mention them in case that's what you're looking for. See creating dynamic blockshttps://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/creating-dynamic-blocks/ for more information Creating blocks with external metadata The block type metadatahttps://developer.wordpress.org/block-editor/developers/block-api/block-metadata/ provides an external means to declare our block API that will also be necessary if you decide to submit it to the block directoryhttps://wordpress.org/support/article/block-directory/. The metadata is...
Note Right now block-based themes and full site editing are still work in progress. I write about it because, sooner rather than later, themes will take advantage of full site editing and they will become a new tool in the arsenal for WordPress developers. These features are not part of Core WordPress, they require the latest Gutenberg plugin not the version that is bundled with WordPress, and the APIs discussed in this post may change before they are merged into core and become official parts of WordPress. An experimental feature available in recent versions of Gutenberg is the ability to...
There are times when we want the same element across the page to do the same. The following block styles the h2 elements inside the header, footer and main elements. css header h2, main h2, footer h2 { color: red; } It works but it's error-prone, repetitive and may cause all rules to be ignored if there is a mistake. Published in Selectors Level 4https://drafts.csswg.org/selectors-4/matches-pseudo, the :is pseudo-classhttps://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classestakes a selector list and selects any element that matches any of the selectors in that list. Using :is e can write the previous example like this css :isheader, main, footer h2 {...
This post about Gutenberg is a mix of different thoughts, ideas and code snippets I've worked on while researching how to build blocks for a project I'm working on. Making Custom Post Types work in Gutenberg I've created several custom post types that worked in the classic editor. When I brought them to my Gutenberg playground they would not work or they would not work as I expected them to. It took me a while to realize that you must be really picky on how you configure the Custom Post Type CPT to work as Gutenberg is far less forgiving...
The previous post Revisiting Gutenberg blocks part 1: Building and Styling the blockshttps://publishing-project.rivendellweb.net/revisiting-gutenberg-blocks-part-1-building-and-styling-the-blocks/ discussed how to build a block and reviewed both old and new techniques for creating Gutenberg blocks. This post will revisit related areas of block development in more detail. Block variations Some times it may be easier to create additional styles for an existing core element than create your own. Gutenberg calls this block variations. Authors can also choose whether they want to incorporate core blocks. It is highly likely that you will need to customize the block styles to match the core blocks with the theme...
My dislike of Gutenberg has softened since it was first introduced, mostly because they provided ways to keep the classic editor and they've guaranteed support for it through 2022. I've written about building Gutenberg blocks: Building Gutenberg Blocks Part 1https://publishing-project.rivendellweb.net/building-gutenberg-blocks-part-1/, part 2https://publishing-project.rivendellweb.net/building-gutenberg-blocks-part-2/, part 3https://publishing-project.rivendellweb.net/building-gutenberg-blocks-part-3/ and part4https://publishing-project.rivendellweb.net/building-gutenberg-blocks-part-4/, and another series on using Gutenberg as a design system: Gutenberg as a design system part 1https://publishing-project.rivendellweb.net/gutenberg-as-a-design-system-part-1/, part 2https://publishing-project.rivendellweb.net/gutenberg-as-a-design-system-part-2/, and part 3https://publishing-project.rivendellweb.net/gutenberg-as-design-systems-part-3/ but I want to revisit block design both in light of new developments in Gutenberg and as a way to build more complex blocks using block patterns and, possibly, full-page designs. Build...