diff --git a/helpers/build-app-list.js b/helpers/build-app-list.js index bf8e421..42eafa1 100644 --- a/helpers/build-app-list.js +++ b/helpers/build-app-list.js @@ -270,6 +270,7 @@ export default async function () { } const category = { + label: categoryTitle, slug: categorySlug } diff --git a/helpers/categories.js b/helpers/categories.js index 2f4e36e..f072489 100644 --- a/helpers/categories.js +++ b/helpers/categories.js @@ -1,4 +1,13 @@ // Universal JS imports only +import slugify from 'slugify' + + +export function makeCategorySlug ( categoryName ) { + return slugify(categoryName, { + lower: true, + strict: true + }) +} // Contains all types of properies to keep data consistent @@ -139,5 +148,21 @@ export function getAppCategory (app) { if (typeof app.category === 'undefined') { console.log('app', app) } + + // If this category is not defined yet + // then add it + if ( !categories.hasOwnProperty( app.category.slug ) ) { + // console.log('app', app) + + const customCategory = { + id: null, + ...app.category, + } + + categories[app.category.slug] = customCategory + + console.log('Added new category', app.category.slug) + } + return categories[app.category.slug] } diff --git a/pages/categories.vue b/pages/categories.vue index 65425b9..0dcbee5 100644 --- a/pages/categories.vue +++ b/pages/categories.vue @@ -73,6 +73,9 @@ export default { } categoryList[app.category.slug] = { + // Merg in category data from app + ...app.category, + // Merge in category data from category file ...categories[app.category.slug], appNamesList: [ app.name ] } @@ -81,11 +84,14 @@ export default { // Add App Names Text into categoryList Object.keys(categoryList).map(function(key, index) { const category = categoryList[key] + categoryList[key] = { ...category, appNames: category.appNamesList.slice(0, 25).join(', ') + ', etc...' } - }); + }) + + // console.log('categoryList', categoryList) return { categoryList diff --git a/pages/kind/_slug.vue b/pages/kind/_slug.vue index 887693e..5a8fc38 100644 --- a/pages/kind/_slug.vue +++ b/pages/kind/_slug.vue @@ -2,7 +2,7 @@

- {{ category.pluralLabel || category.label }} that are reported to support Apple Silicon + {{ pluralLabel }} that are reported to support Apple Silicon

{ + return app.category.slug === this.slug + }) + + // console.log('appWithCategory', appWithCategory) + + return appWithCategory.category + }, + pluralLabel () { + if ( this.category.hasOwnProperty('pluralLabel') ) { + return this.category.pluralLabel + } + + return this.category.label }, supportedAppList () { return this.categoryAppList.filter(app => { @@ -123,10 +141,10 @@ export default { }).map(app => app.name) }, title () { - return `List of ${this.category.pluralLabel || this.category.label} that work on Apple Silicon?` + return `List of ${this.pluralLabel || this.category.label} that work on Apple Silicon?` }, description () { - return `Check the the latest reported support status of ${this.category.pluralLabel || this.category.label} on Apple Silicon and Apple M1 Processors. ` + return `Check the the latest reported support status of ${this.pluralLabel || this.category.label} on Apple Silicon and Apple M1 Processors. ` }, }, head() {