diff --git a/_includes/components/sections/recent-posts.njk b/_includes/components/sections/recent-posts.njk index 9f33f1d..602d89d 100644 --- a/_includes/components/sections/recent-posts.njk +++ b/_includes/components/sections/recent-posts.njk @@ -7,15 +7,16 @@ {% set sectionConfig = section.config or {} %} {% set maxItems = sectionConfig.maxItems or 5 %} {% set showSummary = sectionConfig.showSummary if sectionConfig.showSummary is defined else true %} +{% set listedPosts = collections.posts | excludeUnlistedPosts %} -{% if collections.posts and collections.posts.length %} +{% if listedPosts and listedPosts.length %}

{{ sectionConfig.title or "Recent Posts" }}

- {% for post in collections.posts | head(maxItems) %} + {% for post in listedPosts | head(maxItems) %} {# Detect post type from frontmatter properties #} {% set likedUrl = post.data.likeOf or post.data.like_of %} {% set bookmarkedUrl = post.data.bookmarkOf or post.data.bookmark_of %} diff --git a/_includes/components/widgets/recent-posts-blog.njk b/_includes/components/widgets/recent-posts-blog.njk index f6b77a6..eb04095 100644 --- a/_includes/components/widgets/recent-posts-blog.njk +++ b/_includes/components/widgets/recent-posts-blog.njk @@ -1,11 +1,12 @@ {# Recent Posts Widget — type-aware, for blog/post sidebars #} {# Uses collections.posts directly (all post types, not just recentPosts collection) #} -{% if collections.posts %} +{% set listedPosts = collections.posts | excludeUnlistedPosts %} +{% if listedPosts and listedPosts.length %}

Recent Posts

    - {% for post in collections.posts | head(5) %} + {% for post in listedPosts | head(5) %} {% if post.url != page.url %}
  • {% set _likedUrl = post.data.likeOf or post.data.like_of %} diff --git a/_includes/components/widgets/recent-posts.njk b/_includes/components/widgets/recent-posts.njk index c8bebcc..82e8b0d 100644 --- a/_includes/components/widgets/recent-posts.njk +++ b/_includes/components/widgets/recent-posts.njk @@ -1,11 +1,12 @@ {# Recent Posts Widget (sidebar) - compact type-aware list #} {% set recentPosts = recentPosts or collections.recentPosts %} -{% if recentPosts and recentPosts.length %} +{% set listedRecentPosts = recentPosts | excludeUnlistedPosts %} +{% if listedRecentPosts and listedRecentPosts.length %}

    Recent Posts

      - {% for post in recentPosts | head(5) %} + {% for post in listedRecentPosts | head(5) %}
    • {# Detect post type #} {% set likedUrl = post.data.likeOf or post.data.like_of %} diff --git a/eleventy.config.js b/eleventy.config.js index 18eb29e..1f28593 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -876,6 +876,17 @@ export default function (eleventyConfig) { }; }); + // Exclude unlisted posts from UI slices like homepage/sidebar recent-post lists. + eleventyConfig.addFilter("excludeUnlistedPosts", (posts) => { + if (!Array.isArray(posts)) return []; + return posts.filter((post) => { + const data = post?.data || {}; + const rawVisibility = data.visibility ?? data.properties?.visibility; + const visibility = Array.isArray(rawVisibility) ? rawVisibility[0] : rawVisibility; + return String(visibility ?? "").toLowerCase() !== "unlisted"; + }); + }); + // Helper: exclude drafts from collections const isPublished = (item) => !item.data.draft; diff --git a/theme/_includes/components/sections/recent-posts.njk b/theme/_includes/components/sections/recent-posts.njk index e7b459b..0c9f4e3 100644 --- a/theme/_includes/components/sections/recent-posts.njk +++ b/theme/_includes/components/sections/recent-posts.njk @@ -7,15 +7,16 @@ {% set sectionConfig = section.config or {} %} {% set maxItems = sectionConfig.maxItems or 5 %} {% set showSummary = sectionConfig.showSummary if sectionConfig.showSummary is defined else true %} +{% set listedPosts = collections.posts | excludeUnlistedPosts %} -{% if collections.posts and collections.posts.length %} +{% if listedPosts and listedPosts.length %}

      {{ sectionConfig.title or "Recent Posts" }}

      - {% for post in collections.posts | head(maxItems) %} + {% for post in listedPosts | head(maxItems) %} {# Detect post type from frontmatter properties #} {% set likedUrl = post.data.likeOf or post.data.like_of %} {% set bookmarkedUrl = post.data.bookmarkOf or post.data.bookmark_of %} diff --git a/theme/_includes/components/widgets/recent-posts-blog.njk b/theme/_includes/components/widgets/recent-posts-blog.njk index f6b77a6..eb04095 100644 --- a/theme/_includes/components/widgets/recent-posts-blog.njk +++ b/theme/_includes/components/widgets/recent-posts-blog.njk @@ -1,11 +1,12 @@ {# Recent Posts Widget — type-aware, for blog/post sidebars #} {# Uses collections.posts directly (all post types, not just recentPosts collection) #} -{% if collections.posts %} +{% set listedPosts = collections.posts | excludeUnlistedPosts %} +{% if listedPosts and listedPosts.length %}

      Recent Posts

        - {% for post in collections.posts | head(5) %} + {% for post in listedPosts | head(5) %} {% if post.url != page.url %}
      • {% set _likedUrl = post.data.likeOf or post.data.like_of %} diff --git a/theme/_includes/components/widgets/recent-posts.njk b/theme/_includes/components/widgets/recent-posts.njk index c8bebcc..82e8b0d 100644 --- a/theme/_includes/components/widgets/recent-posts.njk +++ b/theme/_includes/components/widgets/recent-posts.njk @@ -1,11 +1,12 @@ {# Recent Posts Widget (sidebar) - compact type-aware list #} {% set recentPosts = recentPosts or collections.recentPosts %} -{% if recentPosts and recentPosts.length %} +{% set listedRecentPosts = recentPosts | excludeUnlistedPosts %} +{% if listedRecentPosts and listedRecentPosts.length %}

        Recent Posts

          - {% for post in recentPosts | head(5) %} + {% for post in listedRecentPosts | head(5) %}
        • {# Detect post type #} {% set likedUrl = post.data.likeOf or post.data.like_of %} diff --git a/theme/eleventy.config.js b/theme/eleventy.config.js index 64954c6..3f67d1e 100644 --- a/theme/eleventy.config.js +++ b/theme/eleventy.config.js @@ -818,6 +818,17 @@ export default function (eleventyConfig) { }; }); + // Exclude unlisted posts from UI slices like homepage/sidebar recent-post lists. + eleventyConfig.addFilter("excludeUnlistedPosts", (posts) => { + if (!Array.isArray(posts)) return []; + return posts.filter((post) => { + const data = post?.data || {}; + const rawVisibility = data.visibility ?? data.properties?.visibility; + const visibility = Array.isArray(rawVisibility) ? rawVisibility[0] : rawVisibility; + return String(visibility ?? "").toLowerCase() !== "unlisted"; + }); + }); + // Helper: exclude drafts from collections const isPublished = (item) => !item.data.draft;