rockiger / reactpress

Plugin that lets you easily create, build and deploy React apps into your existing WordPress sites.
https://rockiger.com/en/reactpress/
GNU General Public License v2.0
50 stars 6 forks source link

Use a React app in more than one page #12

Closed rockiger closed 1 year ago

rockiger commented 2 years ago

As a website maintainer, I want the React app I created in several places in my WP site, that I don't repeat myself.

MauriceMorrey commented 2 years ago

Possible solution? See end of article.

https://javascript.plainenglish.io/how-to-add-a-react-app-to-wordpress-pages-61aee723d607

rockiger commented 2 years ago

I couldn't find anything that would help.

The approach in the article is to use WordPress's React installation, which it uses for Gutenberg and full-site editing. I can't think of a way I would hate more to develop React apps. Sorry, for being that harsh.

I think the implementation should be pretty straight forward, if I find the time or somebody else is pitching in.

We probably only need to make it possible to set more page slugs for a certain appname. The code at the moment does that:

add_option('repr_apps', [[
                'appname' => $appname,
                'pageslug' => $pageslug,
            ]]);

One solution would be to create 'more' apps or add a list of slugs. But the first approach seems more backwards compatible.