Post view count

Hi,

This forum managed to count the post view, how does this work ? Is there a repo or something ? Does this ofurm uses wordpress also ? Thanks :slight_smile:

Here it is: frontity/response-utils.ts at dev · frontity/frontity · GitHub

Its not documented but its there.

Awesome, thanks :+1:

I will take a look, but in the meantime I’ve tried this Find popular posts with the WordPress REST API | by Ben Zumdahl | Fiat Insight | Medium

It almost work, with a bit of modifications on wp side, I’m able to retrieve the post meta in the state, and add +1 to it when I use the url provided with Postman (/wp-json/base/views/postid) but it does not work when I use this link in Frontity, any idea ? thanks again

useEffect(() => {
  actions.source.fetch(`/base/views/${postId}`);
}, [])

Find a solution, might not be the best but it works

const viewHandler = {
    name: "viewHandler",
    priority: 1,
    pattern: "/base/views/:id/",
    func: async ({ state, link, params, libraries,type }) => {
      // first need convert object to int
      let id = parseInt(params.id);
      const post = await libraries.source.api.get({
        endpoint: `/base/views/${id}`,
        params: {
          page: id,
        },
      });

    },
  
};

export default viewHandler;

in my post.js

    actions.source.fetch(`/base/views`);