statamic / ssg

The official Statamic Static Site Generator
230 stars 23 forks source link

Video tag included on every page generated #15

Closed tao closed 3 years ago

tao commented 4 years ago

I have a very simple default page template which I use for many collections, and I check if a video exists with the video tag and display it at the top of the page. I generated the static site and one of the videos from a file appeared on every single page using this template. Which I don't quite understand how but it's an interesting problem. So even collections that don't have a video tag in the blueprint at all, now have the same video at the top of the page, so the data must not have been cleared from a previous page?

{{ if video }}
  <div class="featured flex mt-16">
    {{ if video | is_embeddable }}
      <!-- Youtube and Video -->
      <iframe src="{{ video | embed_url }}" width="100%" height="500px" allowfullscreen></iframe>
    {{ else }}
      <!-- Other HTML5 video types -->
      <video src="{{ video | embed_url }}" allowfullscreen></video>
    {{ /if }}
  </div>
{{ /if }}

<section class="featured flex">
  <div class="w-3/4">
    <article>
      <div class="header">
        <h1>{{ title }}</h1>
        <h4 class="subtitle">{{ date }}</h4>
      </div>
      {{ content }}
    </article>
  </div>
</section>
tao commented 4 years ago

I've actually come across this issue again so I'm going to re-open it and investigate it some more.

tao commented 4 years ago

The video is coming from a different collection too, so the {{ video }} tag must not be clearing properly between pages.

tao commented 4 years ago

I found the only way to overcome this issue for now is to give each collection it's own dedicated index/show pages instead of using a global template. I tried to figure out a way to solve the problem in the ssg codebase but nothing helped.

The {{ video }} was being show in another collection that didn't even have a video in the blueprint, and I also tried clearing the stache each time before testing. So it's really a difficult issue for me to understand what's going on.

tao commented 3 years ago

I believe I found another example where this might be causing an issue... I'm generating my static site and some pages have redirects with antlers:

{{ redirect to="/library/books" }}

This works fine until SSG renders a collection with redirect: 'entry::id' in the yaml header and I start getting a new problem:

[✘] /books/2019 (Modifier [to] not found)

I believe because it's not clearing data after each render, antlers tries to print the variable redirect from the previous collection... then tries to modify it with to - instead of generating a redirect as intended.

Eworm commented 3 years ago

I have a similar issue: comments from a blogpost are generated until a blogpost has new comments. Then those comments are generated on all blogposts until there's a post with new comments.