diff --git a/src/components/PropertyCard.astro b/src/components/PropertyCard.astro index 3bb0182..e3d8b79 100644 --- a/src/components/PropertyCard.astro +++ b/src/components/PropertyCard.astro @@ -13,9 +13,9 @@ const { property, initial, change } = Astro.props; ---
-

+

{property} -

+ Copy link for {property} diff --git a/src/pages/index.astro b/src/pages/index.astro index 34a5b4d..2c12a9e 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -2,24 +2,44 @@ import PropertyCard from '@components/PropertyCard.astro'; import Layout from '@layouts/Layout.astro'; import json from '@data/data.json'; +import { getOrganizedProperties } from '@src/utils'; const { data } = json; const properties = Object.keys(data); const title = "CSS Triggers"; + +const organizedProperties = getOrganizedProperties(properties); +const firstLetters = Object.keys(organizedProperties); ---

{title}

diff --git a/src/utils.js b/src/utils.js new file mode 100644 index 0000000..1f7aa28 --- /dev/null +++ b/src/utils.js @@ -0,0 +1,15 @@ +export const getOrganizedProperties = (properties) => { + const organizedProperties = {}; + + properties.forEach((property) => { + const firstLetter = property.charAt(0); + + if (!organizedProperties[firstLetter]) { + organizedProperties[firstLetter] = []; + } + + organizedProperties[firstLetter].push(property); + }); + + return organizedProperties; +}; diff --git a/tsconfig.json b/tsconfig.json index ef4f318..9de0a78 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,8 @@ "@assets/*": ["src/assets/*"], "@components/*": ["src/components/*"], "@data/*": ["data/*"], - "@layouts/*": ["src/layouts/*"] + "@layouts/*": ["src/layouts/*"], + "@src/*": ["src/*"], } } - } \ No newline at end of file + }