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
7 changes: 5 additions & 2 deletions site/scripts/generate-pack-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ interface RegistryEntry {
source_path: string;
trust_tier?: string;
tags?: string[];
added?: string;
}

interface PackData {
Expand All @@ -155,6 +156,7 @@ interface PackData {
previewSounds: { file: string; label: string; audioUrl: string }[];
sourceRepo?: string;
sourcePath?: string;
dateAdded?: string;
}

// ── Config ──────────────────────────────────────────────────────────────────
Expand All @@ -175,7 +177,7 @@ const REGISTRY_INDEX_URL =
// ── Helpers ─────────────────────────────────────────────────────────────────
// audioBase should be the URL of the directory containing sounds/
// e.g. "https://raw.../og-packs/v1.0.0/peon" or "https://raw.../mypack/v1.0.0"
function processManifest(manifest: Manifest, packName: string, audioBase: string, trustTier: string = "community", registryTags?: string[], sourceRepo?: string, sourcePath?: string): PackData {
function processManifest(manifest: Manifest, packName: string, audioBase: string, trustTier: string = "community", registryTags?: string[], sourceRepo?: string, sourcePath?: string, dateAdded?: string): PackData {
const categories: PackData["categories"] = [];
const previewSounds: PackData["previewSounds"] = [];
let soundCount = 0;
Expand Down Expand Up @@ -218,6 +220,7 @@ function processManifest(manifest: Manifest, packName: string, audioBase: string
previewSounds,
sourceRepo,
sourcePath,
dateAdded,
};
}

Expand Down Expand Up @@ -298,7 +301,7 @@ async function generateFromRemote(): Promise<PackData[]> {
? `${rawBase}/${entry.source_path}`
: rawBase;

return processManifest(manifest, packName, audioBase, entry.trust_tier || "community", entry.tags, entry.source_repo, entry.source_path || undefined);
return processManifest(manifest, packName, audioBase, entry.trust_tier || "community", entry.tags, entry.source_repo, entry.source_path || undefined, entry.added);
})
);

Expand Down
18 changes: 17 additions & 1 deletion site/src/app/packs/PacksClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ const LANGUAGE_LABELS: Record<string, string> = {

const PACKS_PER_PAGE = 24;

type SortKey = "name-asc" | "name-desc" | "sounds-desc" | "sounds-asc";
type SortKey = "name-asc" | "name-desc" | "sounds-desc" | "sounds-asc" | "date-desc" | "date-asc";

const SORT_OPTIONS: { value: SortKey; label: string }[] = [
{ value: "name-asc", label: "A → Z" },
{ value: "name-desc", label: "Z → A" },
{ value: "sounds-desc", label: "Most sounds" },
{ value: "sounds-asc", label: "Fewest sounds" },
{ value: "date-desc", label: "Newest" },
{ value: "date-asc", label: "Oldest" },
];

// ── Helpers ──────────────────────────────────────────────────────────────────
Expand All @@ -56,6 +58,20 @@ function sortPacks(packs: ReturnType<typeof getAllPacks>, key: SortKey) {
return sorted.sort((a, b) => b.totalSoundCount - a.totalSoundCount);
case "sounds-asc":
return sorted.sort((a, b) => a.totalSoundCount - b.totalSoundCount);
case "date-desc":
return sorted.sort((a, b) => {
if (!a.dateAdded && !b.dateAdded) return 0;
if (!a.dateAdded) return 1;
if (!b.dateAdded) return -1;
return b.dateAdded.localeCompare(a.dateAdded);
});
case "date-asc":
return sorted.sort((a, b) => {
if (!a.dateAdded && !b.dateAdded) return 0;
if (!a.dateAdded) return 1;
if (!b.dateAdded) return -1;
return a.dateAdded.localeCompare(b.dateAdded);
});
default:
return sorted;
}
Expand Down
1 change: 1 addition & 0 deletions site/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface PackMeta {
previewSounds: SoundEntry[];
sourceRepo?: string;
sourcePath?: string;
dateAdded?: string;
}

export interface PacksData {
Expand Down
Loading