Based on: WordPress + React Starter Kit from Postlight
This project relies on the connection between WordPress and Next.js based front-end.
I added few new REST API fields, which include:
I also changed the length and ending of excerpt generated by WordPress.
As for now, this project uses CSS Modules without scss support (built-in support for CSS modules was introduced to Next.js with version 9.3).
This project uses Next.js built-in scss support for global and module styles.
But except local styles I use global stylesheet in src/styles/style.scss
.
Most of the CSS is written using Tailwind CSS with the help of purgecss for production purposes (not yet implemented).
I use one of Next.js features, which are pages generated from pages
folder.
Those serve as templates for content received from node WPAPI.
Local styles for pages (modules) are stored in styles
subfolder.
The most important templates are:
On the back-end in server.js
there is specific path which accepts two regex parameters:
It then renders category
page with posts endpoint.
It provides queryParams:
On the front-end category uses node WPAPI for post API requests.
It uses function to get ID from slug provided in url query.
Then it returns multiple values:
This page uses react-paginating for pagination purposes, but it also introduces two methods to generate first, last page buttons and ellipsis (...) when needed.
I adhere mostly to the Airbnb code style with minor changes, which include:
This project is licensed under the GNU GPL v2.