Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/components/CommandPalette.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -100,7 +107,17 @@ const searchData = JSON.stringify(searchIndex);
<path d="M12 2v6m0 0a4 4 0 100 8 4 4 0 000-8z"/>
<path d="M12 22v-6"/>
</svg>
<span class="text-primary-900 dark:text-primary-100">Browse all notes</span>
<span class="text-primary-900 dark:text-primary-100">Browse the garden</span>
</a>
<a
href="/notes/"
class="command-palette-item w-full flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-primary-100 dark:hover:bg-primary-800"
>
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4 text-primary-500" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/>
<path d="M14 3v5h5M8 13h8M8 17h5"/>
</svg>
<span class="text-primary-900 dark:text-primary-100">Public Notes</span>
</a>
</div>

Expand Down
4 changes: 3 additions & 1 deletion src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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}
</a>
Expand Down Expand Up @@ -82,12 +83,13 @@ function isActive(url: string): boolean {
{siteConfig.navigation.items.map((item) => (
<a
href={item.url}
class:list={[
class:list={[
'block py-2 px-3 rounded-lg text-sm font-medium transition-colors',
isActive(item.url)
? '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}
</a>
Expand Down
4 changes: 2 additions & 2 deletions src/components/PostCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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',
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ const featuredProjects = allProjects
</div>
</section>

<!-- Recent Posts -->
<!-- Mixed recent posts and notes. Public Notes is /notes/. -->
{recentPosts.length > 0 && (
<section>
<div class="flex items-center justify-between mb-6">
<h2 class="text-2xl text-primary-900 dark:text-primary-100">
Recent Notes
Recent
</h2>
<a
href="/posts/"
Expand Down
3 changes: 2 additions & 1 deletion src/pages/llms.txt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export const GET: APIRoute = async ({ site }) => {
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'),
Expand Down
68 changes: 68 additions & 0 deletions src/pages/notes/index.astro
Original file line number Diff line number Diff line change
@@ -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.';
---

<BaseLayout title="Public Notes" description={description}>
<Header slot="header" />

<div data-layout-container class:list={["mx-auto px-4 py-12 sm:py-16", layout === 'list' ? "max-w-3xl" : "max-w-5xl"]}>
<div class="flex items-start justify-between mb-8">
<div>
<h1 class="mb-2 text-4xl text-primary-900 dark:text-primary-100">
Public Notes
</h1>
<p class="text-primary-600 dark:text-primary-400">
{notes.length} {notes.length === 1 ? 'note' : 'notes'}, outside the growth stages
</p>
</div>
<LayoutToggle defaultLayout={layout} storageKey="posts-layout" />
</div>

{notes.length > 0 ? (
<>
<div id="posts-grid" data-view="grid" class:list={["mb-12 grid grid-cols-1 gap-8 md:grid-flow-dense md:grid-cols-2 lg:grid-cols-3", layout === 'list' && "hidden"]}>
{notes.map((post) => (
<div class:list={["flex min-w-0 flex-col", post.data.icon && "md:col-span-2"]}>
<PostCard headingLevel={2} post={post} />
</div>
))}
</div>
<div id="posts-list" data-view="list" class:list={["mb-12", layout === 'grid' && "hidden"]}>
{notes.map((post) => (
<PostListItem post={post} />
))}
</div>
</>
) : (
<div class="text-center py-12">
<p class="text-primary-600 dark:text-primary-400">
No notes yet.
</p>
</div>
)}
</div>

<Footer slot="footer" />
</BaseLayout>
6 changes: 6 additions & 0 deletions src/pages/posts/tag/[tag].astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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 { NOTES_TAG } from '../../../utils/growth';

export async function getStaticPaths() {
const posts = await getCollection('posts', ({ data }) => {
Expand Down Expand Up @@ -39,6 +40,11 @@ const { tag, posts } = Astro.props;
<p class="text-primary-600 dark:text-primary-400">
{posts.length} {posts.length === 1 ? 'post' : 'posts'} with this tag
</p>
{tag === NOTES_TAG && (
<p class="mt-3 text-primary-600 dark:text-primary-400">
Also listed on the <a href="/notes/" class="underline hover:text-primary-900 dark:hover:text-primary-100">Public Notes</a> page.
</p>
)}
</header>

<div class="space-y-8">
Expand Down
12 changes: 10 additions & 2 deletions src/utils/growth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading