Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

Filter by Category results in "No blogposts found!" #196

@Laidlaw

Description

@Laidlaw

Seen here: https://swyxkit.netlify.app/blog?show=Essay

I think filtering by category worked before the fuzzySearch integration.
Could the culprit be here?
blog/+page.svelte 49-72

let loaded = false;
	const filterCategories = async (_items, _, s) => {
		if (!$selectedCategories?.length) return _items;
		return _items
			.filter((item) => {
				return $selectedCategories
					.map((element) => {
						return element.toLowerCase();
					})
					.includes(item.category.toLowerCase());
			})
			.filter((item) => item.toString().toLowerCase().includes(s));
	};
	$: searchFn = filterCategories;
	function loadsearchFn() {
		if (loaded) return;
		import('./fuzzySearch').then((fuzzy) => {
			searchFn = fuzzy.fuzzySearch;
			loaded = true;
		});
	}
	if ($search) loadsearchFn()
	/** @type import('$lib/types').ContentItem[]  */
	let list;
	$: searchFn(items, $selectedCategories, $search).then(_items => list = _items);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions