diff --git a/src/pages/plugins/index.astro b/src/pages/plugins/index.astro index 405843b..6b8a442 100644 --- a/src/pages/plugins/index.astro +++ b/src/pages/plugins/index.astro @@ -8,6 +8,10 @@ import SectionSubheader from "@/components/SectionSubheader.astro"; import LabelValue from "@/components/plugins/LabelValue.astro"; import {TAGS} from "@/constants"; import featuredPluginIds from "@/data/featured-plugins.yml"; +import { + DEFAULT_PLUGIN_SORT, + PLUGIN_SORT_LIST, +} from "@/pages/plugins/pluginSortOptions"; import Swiper from "@/components/Swiper.astro"; const plugins = await getPluginsJson(); @@ -45,9 +49,23 @@ const hasFeaturedPlugins = featured.length > 0; {TAGS.map(v => )} + + + +
- {plugins.map(v => )} + {plugins.map(v => )}
@@ -60,8 +78,9 @@ const hasFeaturedPlugins = featured.length > 0; .controls { display: grid; - grid-template-columns: repeat(2, 1fr); - gap: 24px; + grid-template-columns: repeat(3, 1fr); + column-gap: 20px; + row-gap: 12px; margin-top: 24px; position: sticky; top: 68px; @@ -99,39 +118,64 @@ const hasFeaturedPlugins = featured.length > 0; diff --git a/src/pages/plugins/pluginSortOptions.ts b/src/pages/plugins/pluginSortOptions.ts new file mode 100644 index 0000000..c95a8da --- /dev/null +++ b/src/pages/plugins/pluginSortOptions.ts @@ -0,0 +1,28 @@ +export const PLUGIN_SORTS = { + NAME_ASC: { + value: "name-asc", + label: "Name", + }, + FIRST_RELEASE_DESC: { + value: "first-release-desc", + label: "Release Date", + }, + LATEST_RELEASE_DESC: { + value: "latest-release-desc", + label: "Updated Date", + }, +} as const; + +export const PLUGIN_SORT_LIST = Object.values(PLUGIN_SORTS); + +export type PluginSortValue = typeof PLUGIN_SORTS[keyof typeof PLUGIN_SORTS]["value"]; + +export const DEFAULT_PLUGIN_SORT: PluginSortValue = PLUGIN_SORTS.NAME_ASC.value; + +const PLUGIN_SORT_VALUE_SET = new Set( + PLUGIN_SORT_LIST.map(option => option.value), +); + +export function isPluginSortValue(value: string): value is PluginSortValue { + return PLUGIN_SORT_VALUE_SET.has(value); +} \ No newline at end of file