Processing a Wordpress page with a custom route

Hi All,

Old React developer but new to Frontity and quite impressed as I knocked out a large website over the weekend and am very impressed.

I have created a handler for a non-Wordpress page and that works well. My problem is that I have a few ‘static’ pages e.g. Privacy Policy, TOS etc I want to display these differently to posts as they’re all legalese and don’t have authors per se. How can I route these differently to posts so that I can display them differently?

Hi mike1,
probably what I get from this question is you need to route a different page that is not present in WordPress slug, so you need a custom route so here we can call a state
in the root component, where you can define all states.

<SignUp
when={ data.isSignUp}
/>

After that, you need a handler which will be called in index.js for handling your states.
libraries: {

source: {

  handlers: [

    {

      pattern: "/sign-up/:id",

      func: ({ state, link, params }) => {

        state.source.data[link] = {

          isSignUp: true,

          id: params.id

        }

      }

    },

then exactly you can route the custom route of the non-wordpress page

Thanks

1 Like

Hi saurabhjaydhar,

Sorry, yes. I know how to do this. But does that means I have to create a handler for every page e.g. /privacy-policy, /terms-of-service, /cookie-policy ?

Thanks

I could probably use a single handler with ‘multiple’ patterns.

Final solution (from elsewhere on here):

    const isPrivacyPolicy = state.router.link.startsWith("/privacy-policy");
    const isTermsOfService = state.router.link.startsWith("/terms-of-service");
   
   ...

    <LegalPage when={isPrivacyPolicy || isTermsOfService} />

Finally, you got the solution. It looks so good and yes we can use this .

My solution covers a similar type of slug pattern.

1 Like