Frontity release: Dynamic Public Path

This release adds support for Dynamic public paths. They can be configured using the frontity.settings.js file like this:

export default [
  {
    name: "site",
    match: ["/site/"],
    state: {
      frontity: {
        options: {
          publicPath: "/site/custom-static-path",
        },
      },
    },
    packages: ["..."],
  },
  {
    name: "site-2",
    match: ["/site-2/"],
    state: {
      frontity: {
        options: {
          publicPath: "/site-2/other-static-path",
        },
      },
    },
    packages: ["..."],
  },
];

Or passed as a Frontity Query Option: https://site.com/some-post/?frontity_public_path=https://other-domain.com/custom-static-path

Features

@frontity/[email protected]

  • #890 Thanks @orballo! - Add support for dynamic publicPath configuration via state.frontity.options.publicPath (in frontity.settings.js) or the ?frontity_public_path=/your-path query option.

Fixes

[email protected]

2 Likes

Since I updated, frontity does not find my assets (some fonts and images). My code can be found here: https://github.com/Koli14/szinhaz.live/tree/update-22.03.02
And here one can see the errors: https://szinhaz-online-9g3umg6kx-berta.vercel.app/
Some error message from the console:

downloadable font: download failed (font-family: "Open Sans" style:normal weight:400 stretch:100 src index:0): status=2147746065 source: http://localhost:3000/fonts/open-sans-v18-latin-ext-regular.woff2

Or:

Warning: Prop `src` did not match. Server: "images/NKA_logo.png" Client: "/static/images/NKA_logo.png"
img
[email protected]:///./node_modules/@frontity/connect ...

Or:

GET https://szinhaz-online-9g3umg6kx-berta.vercel.app/images/NKA_logo-889d41c423a9dea4422bce6399e02a55.png
[HTTP/2 400 Bad Request 1215ms]
1 Like

I just update and like @koli14, I notice that the assets import doesn’t work anymore.

I created a public repository only with a fresh install of the “mars theme” and one asset import:

I notice that the problem is on the SSR. On the server side rendering the path of the images is the relative path of the current url, so for example:

  • with the image /resources/imgs/logo.png
  • on a page that have this slug /about-page/

The link to the image on SSR is

  • /about-page/images/logo.png instead of being /static/images/logo.png
2 Likes

I updated frontity in one of my projects last week and was wondering why all the local assets stopped working. I will also look into it today and inform what I found.

EDIT: I can confirm I have the same issue. I was trying to look for a solution but I couldn’t find anything that works for me right now so I had do downgrade the version back to 1.14.3

1 Like

Is this issue resolved?

I’ve opened a pull request with a possible fix.

Sorry, but that is too advanced for me, I have no idea where to put the fix, could you perhaps just update Frontity package with the fix?

Thanks.

We’ll release a new version, don’t worry.

1 Like

Version @frontity/[email protected] was released with the patch.

Please try it out and let me know if it solves the issue.

@frontity/[email protected]

Patch Changes

3 Likes

Thank you! It seem to have solved the issue!

1 Like