Working with page structured data

Hi all,

In my dashboard, each page and subpage has a Google Material Icon associated with it in the sidebar. We also reference that page’s icon in the topbar to show the folder the page is in (screenshot attached).

In an ideal world, I’d define the page’s icon at the page level and reference it dynamically in the sidebar and topbar (this also allows the topbar to be a linked section AKA WeWeb’s version of a reusable elements).

I could technically store these icon names in the database and fetch them on page load, but feels easier / less maintenance to do this entirely on the frontend. I’ve been trying to use the ‘Structured data’ at the page level (screenshot attached), which requires JSON, but when I try to reference it dynamically, the only key is ‘en’ and its difficult to reference to actual keys and values. I’m thinking that this is a bug since the actual structured data should be an object within ‘structuredData’.

Does anyone have experience working with the page structured data? Thanks!

Jack

CleanShot 2023-08-11 at 07.10.39@2x

Hi @Jack :wave:

Not sure I understand your use case. Do you want search engines to display an icon before the name of the page?

Could you share a screenshot of your dashboard page or record a short video walking us through your project, what you tried and what you’re trying to accomplish?

@Joyce apologies for the lack of clarity.

My question boils down to my last screenshot of the structuredData variable: why is the inputted JSON data a text field and not an object? It makes it impossible to reference the key values in formulas, to my understanding. Maybe I am missing something?

@Jack, in theory you can do a custom JavaScript trick with JSON.parse([en_variable]).tab_icon
What backend are you using? How are you storing your JSON?

See this reference - JSON.parse() - JavaScript | MDN

thanks @Broberto! Using Xano but trying to keep this entirely on the frontend and using WeWeb’s native ‘structured data’ section under the page metadata.

Will look into JSON.parse! This seems like a bug due to how WeWeb treats languages.

Update: It worked with JSON.parse. Good one to know for next time, thanks!