From fd63c02e2a63739b70b6e5b01360e46054f3a6ed Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 28 Nov 2020 15:16:56 -0600 Subject: [PATCH] Rename sections to categories --- components/search.vue | 12 ++++----- helpers/build-app-list.js | 16 ++++++------ helpers/build-game-list.js | 2 +- helpers/build-homebrew-list.js | 2 +- helpers/categories.js | 5 +++- nuxt.config.js | 13 +++------ pages/categories.vue | 48 +++++++++++++++++----------------- pages/kind/_slug.vue | 16 ++++++------ 8 files changed, 56 insertions(+), 58 deletions(-) diff --git a/components/search.vue b/components/search.vue index 9178ae3..79470f9 100644 --- a/components/search.vue +++ b/components/search.vue @@ -240,7 +240,7 @@ export default { // results: [], titleStartsWithResults: [], titleContainsResults: [], - sectionContainsResults: [], + categoryContainsResults: [], statusResults: [], // store: overlayStore.state } @@ -254,7 +254,7 @@ export default { return [ ...this.titleStartsWithResults, ...this.titleContainsResults, - ...this.sectionContainsResults, + ...this.categoryContainsResults, ...this.statusResults ] }, @@ -326,10 +326,10 @@ export default { } return matches }, - sectionContains (query, app) { + categoryContains (query, app) { const matches = getAppCategory(app).label.toLowerCase().includes(query) if (matches) { - this.sectionContainsResults.push(app) + this.categoryContainsResults.push(app) } return matches }, @@ -384,7 +384,7 @@ export default { // Clear any results from before this.titleStartsWithResults = [] this.titleContainsResults = [] - this.sectionContainsResults = [] + this.categoryContainsResults = [] this.statusResults = [] @@ -407,7 +407,7 @@ export default { const matchers = [ this.titleStartsWith, this.titleContains, - this.sectionContains, + this.categoryContains, this.statusIs ] diff --git a/helpers/build-app-list.js b/helpers/build-app-list.js index 57858d7..ca4f001 100644 --- a/helpers/build-app-list.js +++ b/helpers/build-app-list.js @@ -128,8 +128,8 @@ export default async function () { const appList = [] - let sectionSlug = 'start' - let sectionTitle = 'Start' + let categorySlug = 'start' + let categoryTitle = 'Start' let isHeading = false let isParagraph = false @@ -143,13 +143,13 @@ export default async function () { if (isHeading && token.type === 'inline') { - sectionTitle = token.content - sectionSlug = slugify(token.content, { + categoryTitle = token.content + categorySlug = slugify(token.content, { lower: true, strict: true }) - // appList[sectionSlug] = [] + // appList[categorySlug] = [] } @@ -192,15 +192,15 @@ export default async function () { text, slug: appSlug, endpoint, - section: { - slug: sectionSlug + category: { + slug: categorySlug }, content: token.content, relatedLinks }) } - // appList[sectionSlug] + // appList[categorySlug] // console.log('token', token) diff --git a/helpers/build-game-list.js b/helpers/build-game-list.js index 0d41322..d1a0089 100644 --- a/helpers/build-game-list.js +++ b/helpers/build-game-list.js @@ -123,7 +123,7 @@ export default async function () { text: getStatusText(game), slug, endpoint: `/game/${slug}`, - section: { + category: { slug: 'games' }, content: '', diff --git a/helpers/build-homebrew-list.js b/helpers/build-homebrew-list.js index 116696d..02828e8 100644 --- a/helpers/build-homebrew-list.js +++ b/helpers/build-homebrew-list.js @@ -149,7 +149,7 @@ export default async function () { text: getStatusText(formulae), slug, endpoint: `/formula/${slug}`, - section: { + category: { slug: 'homebrew' }, content: formulae.comments, diff --git a/helpers/categories.js b/helpers/categories.js index 1f9e8cc..755c54d 100644 --- a/helpers/categories.js +++ b/helpers/categories.js @@ -86,5 +86,8 @@ export const categories = { export function getAppCategory (app) { - return categories[app.section.slug] + if (typeof app.category === 'undefined') { + console.log('app', app) + } + return categories[app.category.slug] } diff --git a/nuxt.config.js b/nuxt.config.js index a410fd8..3d7eb0f 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -6,6 +6,8 @@ import buildAppList from './helpers/build-app-list.js' import buildGamesList from './helpers/build-game-list.js' import buildHomebrewList from './helpers/build-homebrew-list.js' +import { categories } from './helpers/categories.js' + const listsOptions = [ { @@ -96,26 +98,19 @@ export default { .then(( lists ) => { // console.log('appList', appList) - const sectionList = [] - const [ appRoutes, gameRoutes, homebrewRoutes ] = lists.map((list, listI) => { return list.map( app => { - // Find and store all sections - if (sectionList.includes(app.section.slug) == false) { - sectionList.push(app.section.slug) - } - return app.endpoint }) }) // console.log('homebrewRoutes', homebrewRoutes) - const sectionRoutes = sectionList.map(slug => ({ + const categoryRoutes = Object.keys(categories).map( slug => ({ route: '/kind/' + slug, // payload: appList })) @@ -124,7 +119,7 @@ export default { ...appRoutes, ...gameRoutes, ...homebrewRoutes, - ...sectionRoutes + ...categoryRoutes ] }) } diff --git a/pages/categories.vue b/pages/categories.vue index 82eab30..3bd7091 100644 --- a/pages/categories.vue +++ b/pages/categories.vue @@ -7,24 +7,24 @@
- +