Panel plugin: display content from selected page in a block preview

i’m creating a panel plugin that should display content from a selected page inside a custom block preview.

this.content.selectedPage inside the vue component gets me an object with minimal info like title, id and image, but i nee another field’s value – what’s the panel plugin equivalent to the toPage method?

Don’t think that exists. I would watch this.content.selectedPage and fetch the content manually.

{
  // ...
  watch: {
    "content.selectedPage": function([page]) {
      if(page) {
        this.fetch(page.id);
      }
    }
  },
  methods: {
    async fetch(id) {
      const page = await this.$api.pages.get(id);
      this.foo = page.content.bar;
    }
  }
  // ...
}

untested and written from the top of my head, but something like this should work.

Or, shameless plug, Kirby implements custom api models. This way you could add your field to the properties that kirby sends by default for pages and you wouldn’t need another request.

@texnixe @rasteiner this helps a lot! thanks both!