diff --git a/src/components/CommandPalette.astro b/src/components/CommandPalette.astro index 2beb5b9..74c6546 100644 --- a/src/components/CommandPalette.astro +++ b/src/components/CommandPalette.astro @@ -33,6 +33,13 @@ const searchIndex = [ type: 'page' as const, tags: [], })), + { + title: 'Public Notes', + description: 'Short notes, kept outside the garden\'s growth stages.', + url: '/notes/', + type: 'page' as const, + tags: [], + }, ]; const searchData = JSON.stringify(searchIndex); @@ -100,7 +107,17 @@ const searchData = JSON.stringify(searchIndex); - Browse all notes + Browse the garden + + + + + + + Public Notes diff --git a/src/components/Header.astro b/src/components/Header.astro index 0505e4b..d137c2a 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -47,6 +47,7 @@ function isActive(url: string): boolean { ? 'font-medium text-primary-900 dark:text-primary-100' : 'text-primary-600 hover:text-primary-900 dark:text-primary-400 dark:hover:text-primary-100', ]} + aria-current={isActive(item.url) ? 'page' : undefined} > {item.title} @@ -82,12 +83,13 @@ function isActive(url: string): boolean { {siteConfig.navigation.items.map((item) => ( {item.title} diff --git a/src/components/PostCard.astro b/src/components/PostCard.astro index 1814be3..a07b93f 100644 --- a/src/components/PostCard.astro +++ b/src/components/PostCard.astro @@ -9,7 +9,7 @@ import GrowthIndicator from './GrowthIndicator.astro'; import MemoryPoint from './MemoryPoint.astro'; import Tags from './Tags.astro'; import { siteConfig } from '../config'; -import { participatesInGrowth } from '../utils/growth'; +import { isNote, participatesInGrowth } from '../utils/growth'; export interface Props { post: Post; @@ -23,7 +23,7 @@ const { title, description, growth, planted, tags, icon } = post.data; // Use effective growth if provided, otherwise fall back to manual growth const displayGrowth = effectiveGrowth || growth; const showGrowth = siteConfig.garden.showGrowthStatus && participatesInGrowth(tags); -const kind = tags?.includes('notes') ? 'Note' : 'Post'; +const kind = isNote(tags) ? 'Note' : 'Post'; const plantedDate = planted.toLocaleDateString('en-US', { year: 'numeric', diff --git a/src/config.ts b/src/config.ts index 8c63bf5..c5e35fc 100644 --- a/src/config.ts +++ b/src/config.ts @@ -128,6 +128,7 @@ export const siteConfig: MyceliumConfig = { navigation: { items: [ { title: 'Garden', url: '/posts/' }, + { title: 'Public Notes', url: '/notes/' }, { title: 'About', url: '/about/' }, ], showSocialLinks: true, diff --git a/src/pages/index.astro b/src/pages/index.astro index bd34c63..5cebf9f 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -105,12 +105,12 @@ const featuredProjects = allProjects - + {recentPosts.length > 0 && (

- Recent Notes + Recent

{ pages.map((page) => line(page.data.title, url(`/${page.id}/`), page.data.description)).join('\n'), '## Optional', [ - line('All notes', url('/posts/'), 'the garden index, filterable by growth stage and tag'), + line('Garden', url('/posts/'), 'the garden index, filterable by growth stage and tag'), + line('Public Notes', url('/notes/'), 'notes only; posts tagged reading-notes stay in the garden'), line('RSS feed', url('/feed.xml')), line('Sitemap', url('/sitemap-index.xml')), ].join('\n'), diff --git a/src/pages/notes/index.astro b/src/pages/notes/index.astro new file mode 100644 index 0000000..d9ff289 --- /dev/null +++ b/src/pages/notes/index.astro @@ -0,0 +1,68 @@ +--- +/** + * Notes index. Lists posts the Note badge already marks (isNote). + * Growth filters stay on the garden. + */ + +import BaseLayout from '../../layouts/BaseLayout.astro'; +import Header from '../../components/Header.astro'; +import Footer from '../../components/Footer.astro'; +import PostCard from '../../components/PostCard.astro'; +import PostListItem from '../../components/PostListItem.astro'; +import LayoutToggle from '../../components/LayoutToggle.astro'; +import { getCollection } from 'astro:content'; +import { siteConfig } from '../../config'; +import { isNote } from '../../utils/growth'; + +const notes = (await getCollection('posts', ({ data }) => { + return import.meta.env.PROD ? !data.draft : true; +})) + .filter((post) => isNote(post.data.tags)) + .sort((a, b) => b.data.planted.valueOf() - a.data.planted.valueOf()); + +const { layout } = siteConfig.posts; +const description = 'Short notes, kept outside the garden\'s growth stages.'; +--- + + +
+ +
+
+
+

+ Public Notes +

+

+ {notes.length} {notes.length === 1 ? 'note' : 'notes'}, outside the growth stages +

+
+ +
+ + {notes.length > 0 ? ( + <> +
+ {notes.map((post) => ( +
+ +
+ ))} +
+
+ {notes.map((post) => ( + + ))} +
+ + ) : ( +
+

+ No notes yet. +

+
+ )} +
+ +
diff --git a/src/utils/growth.ts b/src/utils/growth.ts index 66c2676..641349b 100644 --- a/src/utils/growth.ts +++ b/src/utils/growth.ts @@ -28,11 +28,19 @@ export interface GrowthResult { reasons: string[]; } -const NOTES_TAG = 'notes'; +export const NOTES_TAG = 'notes'; + +/** + * The Note badge and the /notes/ index. + * A reading-notes tag is a normal post, not a note. + */ +export function isNote(tags?: readonly string[]): boolean { + return tags?.includes(NOTES_TAG) ?? false; +} /** Notes stay in the garden index but never receive a growth stage. */ export function participatesInGrowth(tags?: readonly string[]): boolean { - return !tags?.includes(NOTES_TAG); + return !isNote(tags); } // Thresholds for growth calculation