Open hojjatnikan opened 3 years ago
A Wordpress site is literally its own app, and they are usually hosted separately.
The solution, if you want to map the URL, is to configure the server to map /blog
to the Wordpress app that is running separately. For that you would usually use a reverse proxy.
So there is no way to actually integrate it into and existing Blazor project/app. And why would you?
Actually, WpDotNet is a part of your Asp.Net Core application request pipeline. So you can combine it with your other razor views and request delegates.
At this point - https://docs.peachpie.io/scenarios/wordpress/overview/#quick-start - in Startup
class, you are free to prepend app.UseWordPress();
with other request delegates.
In the case of Blazor - feel free to experiment, but it can't run on the client-side for sure (it needs to communicate with MySql and to access the server's file system).
@hojjatnikan Just to elaborate my answer:
It did not occur to me that you could map different endpoints in the same app, as it is not a case that I have found desirable.
So @jakubmisek is right there.
I would personally keep the apps separate since mixing them makes it harder to maintain. And… If your main site is down then the blog is down too.
Anyway, you could use YARP (Reverse Proxy for .NET) in your main site to proxy /blog to the Wordpress site.
Unless you want tight integration between main site and blog then I would recommend this approach.
In my projects I’m hosting Blazor components in Wordpress pages via Razor views.
Would be great to see more write tuts on doing this stuff.. would like to move away from using wordpress php and using c# for this stuff as finding a good cms for c# is well.. not really found anything decent yet
Would be great to see more write tuts on doing this stuff.. would like to move away from using wordpress php and using c# for this stuff as finding a good cms for c# is well.. not really found anything decent yet
I enjoy the backend parts of Wordpress, but I would like the ability to write my frontend/theme entirely in Razor syntax, perhaps even a Blazor app.
I wonder how hard it would be to plug into that part of Wordpress.
@robertsundstrom creating a theme in razor shouldn't be that difficult; I'd create a dummy theme in PHP which would include your razor component. (there is a short demo at https://www.peachpie.io/2018/08/razor-partial-view-on-php-page.html and https://github.com/iolevel/peachpie-samples/tree/master/mvc)
@jakubmisek Sure, I have been doing that for individual pages. What I'm not sure about is how to build a theme that is fully Blazor. Where you, at least, can access the most common functions to render content.
@robertsundstrom hmm combining it with blazor and application state might be a challenge. I'm not sure what's needed to achieve that.
I don't know how Wordpress works, when it loads the data of a page. Is it just routing to page based on a convention? Couldn't you just map that route to a ASP.NET Route? And then just inject the WP_Post into a Razor Page or a Blazor component? And write some interop code where it is needed.
yes, it routes the page request and ends up by including various template-part PHP files (i.e. calling the main method of the file). We can put a breakpoint into a template file to see what's on the call stack.
@hojjatnikan @jakubmisek
You can build a frontend using the technology of your choice, be it Blazor or React, with Wordpress just for content management - using Wordpress as a "Headless CMS". The Wordpress API: https://developer.wordpress.org/rest-api/
Here is my headless Wordpress with a Blazor frontend: https://github.com/robertsundstrom/headless-wordpress-blazor
maybe there is integration with blazor-oqtane multisite multi tenant architecture
How can I use this 'wpdotnet' project as a component in the blazor project and have a page called blog that displays the 'wpdotnet' project? For example www.example.com/blog Someone can guide me