This theme is demo for WordCamp Kathmandu 2019, which implements React in archive page to add infinite scroll.
Not for production use. This is a child theme for default WP
twentynineteentheme.
- Rakesh Lawaju (WP Theme part)
- Rabin Gaire (React Part)
- Latest WordPress setup with
twentynineteentheme installed. - Add some dummy post in backend or import Theme test file as instructed here.
Nodeinstalled.
- Install postman to check API data.
A) WordPress Part
- Go to
wp-content/themes/folder. - Create new folder called
twentynineteen-child. - Copy
index.phpfile fromtwentynineteentheme and paste it totwentynineteen-childfolder. - Inside
twentynineteen-childfolder create two files- style.css
- functions.php
- On
style.csswe will define theme info and add little css as shown here. - On
index.phpremove all the code inside<main id="main" class="site-main"></main> - On
functions.phplets enqueue style and scripts as shown here.
Note that we have not created js files yet so it will give error on console.
- Go to backend and activate
twentynineteen-childtheme. On front end there should be blank. - Go to
http://yoursite.local/wp-json/wp/v2/postsit should show json with posts of your site. - Next step is to add more code in
functions.phpas shown here. This would add some more data in API.
B) React Part
- Go to
assets/js/srcfolder this is the location where we have kept the react code. index.jsis the entry point of the application whereasApp.jsandPost.jsare the two react components.- Inside
assets/js/distwe have the production build generated using webpack, webpack bundles all the necessary files and dependency needed to run react application into a single file calledbundle.js. - Configuration for webpack
webpack.config.jsis at root of the application. - You can also see folder called
node_modules,node_modulescontains all the dependency for the application managed bynpm. npmis a tool that is used to maintain and download dependency required for the aplication.npmlooks at file calledpackage.jsonwhich is located at the root of the application to maintain and download the dependency.