NEARBuilders / near-bos-webcomponent

Embed NEAR BOS content as a web component
The Unlicense
13 stars 6 forks source link

Support SEO friendly URLs #10

Closed petersalomonsen closed 7 months ago

petersalomonsen commented 7 months ago

For the MVP for DevHub I did this (the commit from April 28th):

In addition, for ensuring this has the proper quality to be merged, I've added the following:

A test that demonstrates this, is implemented in router.spec.js:

test("for supporting SEO friendly URLs, it should be possible to set initialProps and src widget from any path", async ({ page }) => {
  await page.goto("/community/webassemblymusic");
  await page.evaluate(() => {
    const viewerElement = document.querySelector('near-social-viewer');
    viewerElement.setAttribute("src", "devhub.near/widget/app");
    const pathparts = location.pathname.split("/");
    viewerElement.setAttribute("initialProps", JSON.stringify({ page: pathparts[1], handle: pathparts[2] }));
  });
  await expect(await page.getByText('WebAssembly Music', { exact: true })).toBeVisible();
});

fixes #12

petersalomonsen commented 7 months ago

Thanks @elliotBraem . I'm not 100% finished with this. I need to create more tests, and documentation before I can merge it. Currently just tested the idea of being able to have the path controlling the props for the widget. As you say we also still want to be able to control which widget to display from the path, and we need a good way to support both behaviours or even combine them.

So I'm still trying to figure out how to introduce this in a good way, without breaking any existing use cases.