Featured post on the tag page

Hi. Is it possible to show 1 featured post on the tag page at the top of the posts feed? I have the code of the tag.hbs page (below), a selection of the first post is implemented there, but in this case #get simply pulls out any featured post, and I need exactly the post that meets two requirements - it is marked as featured and refers to the tag on which page it is displayed. Maybe I need to rewrite the code, or is there no solution at all?

{{!< default}}

<div class="gh-page tag-page">
    <div class="gh-container">

        {{#tag}}
        <header class="gh-page-head">

            <h1>{{name}}</h1>

            <p>
                {{#if description}}
                    {{description}}
                {{else}}
                    A collection of {{plural ../pagination.total empty='posts' singular='% post' plural='% posts'}}
                {{/if}}
            </p>

            {{!-- {{#if feature_image}}
                <img class="gh-page-image" src="{{feature_image}}" alt="{{name}}" />
            {{/if}} --}}

            <span class="icon-tag-left">{{> "icons/tag-left"}}</span>
            <span class="icon-tag-right">{{> "icons/tag-right"}}</span>

        </header>

        {{/tag}}

        <div class="posts-feed tag-post-feed">
            {{#get "posts" include="tags,authors" filter="featured:true" limit="1" as |featured|}}
                {{#foreach featured}}
                    {{> "featured-card"}}
                {{/foreach}}
            {{/get}}
            {{#foreach posts}}
                {{#unless featured}}
                    {{> "card"}}
                {{/unless}}
            {{/foreach}}
        </div>



    </div>
</div>

It is probably possible to do this using css, assuming that the container with articles is either flex or grid:

<style>
.featured:first-child {
    order: 1;
}
</style>

But maybe there is a more ideal solution

Use filter="featured:true+tags:{{slug}}" in your get helper, but inside {{#tag}}

Like this:

{{#tag}}
    {{#get "posts" include="tags,authors" filter="featured:true+tags:{{slug}}" limit="1" as |featured|}}
        {{#foreach featured}}
            {{> "featured-card"}}
        {{/foreach}}
    {{/get}}
{{/tag}}
2 Likes