fix: hide private and where/Loc notes from public overviews and collections
This commit is contained in:
@@ -9,9 +9,9 @@
|
||||
{% set showSummary = sectionConfig.showSummary if sectionConfig.showSummary is defined else true %}
|
||||
{% set primaryPosts = collections.posts if (collections and collections.posts) else [] %}
|
||||
{% set fallbackRecentPosts = collections.recentPosts if (collections and collections.recentPosts) else [] %}
|
||||
{% set listedPosts = primaryPosts | excludeUnlistedPosts %}
|
||||
{% set listedPosts = primaryPosts | excludeUnlistedPosts | excludeWhereNotes %}
|
||||
{% if not (listedPosts and listedPosts.length) %}
|
||||
{% set listedPosts = fallbackRecentPosts | excludeUnlistedPosts %}
|
||||
{% set listedPosts = fallbackRecentPosts | excludeUnlistedPosts | excludeWhereNotes %}
|
||||
{% endif %}
|
||||
|
||||
{% if listedPosts and listedPosts.length %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{# Recent Posts Widget (sidebar) - compact type-aware list #}
|
||||
{% set recentPosts = recentPosts or collections.recentPosts %}
|
||||
{% set listedRecentPosts = recentPosts | excludeUnlistedPosts %}
|
||||
{% set listedRecentPosts = recentPosts | excludeUnlistedPosts | excludeWhereNotes %}
|
||||
{% if listedRecentPosts and listedRecentPosts.length %}
|
||||
<is-land on:visible>
|
||||
<div class="widget">
|
||||
|
||||
@@ -913,14 +913,28 @@ export default function (eleventyConfig) {
|
||||
// Helper: exclude drafts from collections
|
||||
const isPublished = (item) => !item.data.draft;
|
||||
|
||||
// Helper: exclude unlisted visibility from public listing surfaces
|
||||
// Helper: exclude unlisted/private/where/Loc notes from public listing surfaces
|
||||
const isListed = (item) => {
|
||||
const data = item?.data || {};
|
||||
const rawVisibility = data.visibility ?? data.properties?.visibility;
|
||||
const visibility = Array.isArray(rawVisibility) ? rawVisibility[0] : rawVisibility;
|
||||
return String(visibility ?? "").toLowerCase() !== "unlisted";
|
||||
const tags = (data.category || data.tags || []).map(t => typeof t === 'string' ? t.toLowerCase() : '');
|
||||
// Exclude unlisted, private, and where/Loc notes
|
||||
if (["unlisted", "private"].includes(String(visibility ?? "").toLowerCase())) return false;
|
||||
if (tags.includes("where") || tags.includes("loc")) return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
// Filter: exclude where/Loc notes from collections
|
||||
eleventyConfig.addFilter("excludeWhereNotes", (posts) => {
|
||||
if (!Array.isArray(posts)) return [];
|
||||
return posts.filter(item => {
|
||||
const data = item?.data || {};
|
||||
const tags = (data.category || data.tags || []).map(t => typeof t === 'string' ? t.toLowerCase() : '');
|
||||
return !tags.includes("where") && !tags.includes("loc");
|
||||
});
|
||||
});
|
||||
|
||||
// Exclude unlisted posts from UI slices like homepage/sidebar recent-post lists.
|
||||
eleventyConfig.addFilter("excludeUnlistedPosts", (posts) => {
|
||||
if (!Array.isArray(posts)) return [];
|
||||
|
||||
Reference in New Issue
Block a user