mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-26 23:04:57 +00:00
feat: add functions to retrieve unique snippet tags and category counts
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { LUA_SNIPPETS } from '../snippets/lua-snippets-data'
|
||||
|
||||
/**
|
||||
* Get all unique tags across snippets
|
||||
* @returns Sorted list of tags
|
||||
*/
|
||||
export const getAllSnippetTags = (): string[] => {
|
||||
const tagSet = new Set<string>()
|
||||
|
||||
for (const snippet of LUA_SNIPPETS) {
|
||||
for (const tag of snippet.tags) {
|
||||
tagSet.add(tag)
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(tagSet).sort()
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { LUA_SNIPPETS } from '../snippets/lua-snippets-data'
|
||||
|
||||
/**
|
||||
* Get count of snippets per category
|
||||
* @returns Category counts with "All" included
|
||||
*/
|
||||
export const getSnippetCategoryCounts = (): Record<string, number> => {
|
||||
const counts: Record<string, number> = { All: LUA_SNIPPETS.length }
|
||||
|
||||
for (const snippet of LUA_SNIPPETS) {
|
||||
counts[snippet.category] = (counts[snippet.category] || 0) + 1
|
||||
}
|
||||
|
||||
return counts
|
||||
}
|
||||
Reference in New Issue
Block a user