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 showSummary = sectionConfig.showSummary if sectionConfig.showSummary is defined else true %}
|
||||||
{% set primaryPosts = collections.posts if (collections and collections.posts) else [] %}
|
{% set primaryPosts = collections.posts if (collections and collections.posts) else [] %}
|
||||||
{% set fallbackRecentPosts = collections.recentPosts if (collections and collections.recentPosts) 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) %}
|
{% if not (listedPosts and listedPosts.length) %}
|
||||||
{% set listedPosts = fallbackRecentPosts | excludeUnlistedPosts %}
|
{% set listedPosts = fallbackRecentPosts | excludeUnlistedPosts | excludeWhereNotes %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if listedPosts and listedPosts.length %}
|
{% if listedPosts and listedPosts.length %}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{# Recent Posts Widget (sidebar) - compact type-aware list #}
|
{# Recent Posts Widget (sidebar) - compact type-aware list #}
|
||||||
{% set recentPosts = recentPosts or collections.recentPosts %}
|
{% set recentPosts = recentPosts or collections.recentPosts %}
|
||||||
{% set listedRecentPosts = recentPosts | excludeUnlistedPosts %}
|
{% set listedRecentPosts = recentPosts | excludeUnlistedPosts | excludeWhereNotes %}
|
||||||
{% if listedRecentPosts and listedRecentPosts.length %}
|
{% if listedRecentPosts and listedRecentPosts.length %}
|
||||||
<is-land on:visible>
|
<is-land on:visible>
|
||||||
<div class="widget">
|
<div class="widget">
|
||||||
|
|||||||
+16
-2
@@ -913,14 +913,28 @@ export default function (eleventyConfig) {
|
|||||||
// Helper: exclude drafts from collections
|
// Helper: exclude drafts from collections
|
||||||
const isPublished = (item) => !item.data.draft;
|
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 isListed = (item) => {
|
||||||
const data = item?.data || {};
|
const data = item?.data || {};
|
||||||
const rawVisibility = data.visibility ?? data.properties?.visibility;
|
const rawVisibility = data.visibility ?? data.properties?.visibility;
|
||||||
const visibility = Array.isArray(rawVisibility) ? rawVisibility[0] : rawVisibility;
|
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.
|
// Exclude unlisted posts from UI slices like homepage/sidebar recent-post lists.
|
||||||
eleventyConfig.addFilter("excludeUnlistedPosts", (posts) => {
|
eleventyConfig.addFilter("excludeUnlistedPosts", (posts) => {
|
||||||
if (!Array.isArray(posts)) return [];
|
if (!Array.isArray(posts)) return [];
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ layout: layouts/base.njk
|
|||||||
title: Notes
|
title: Notes
|
||||||
withSidebar: true
|
withSidebar: true
|
||||||
pagination:
|
pagination:
|
||||||
data: collections.listedNotes
|
data: collections.listedNotes | excludeWhereNotes
|
||||||
size: 20
|
size: 20
|
||||||
alias: paginatedNotes
|
alias: paginatedNotes
|
||||||
generatePageOnEmptyData: true
|
generatePageOnEmptyData: true
|
||||||
|
|||||||
Reference in New Issue
Block a user