#Matching a path

3 messages · Page 1 of 1 (latest)

chilly valve
#

I'm a bit confused. In development, this works as expected. However, when building and running the preview, it does not.

{
    pathname === "/blog" && (
      <>
        <p set:html={post.data.description} />
        <a href={"/blog/" + post.slug}>Read More &rarr;</a>
      </>
    )
  }

BTW, pathname = Astro.url.pathname
When running console.log(pathname), I get a matching /blog, so why is this failing on the preview?

zinc sparrow
#

A solution for SSG is to just create a little JavaScript snippet instead of relying on the Astro API.