diff --git a/components/search.vue b/components/search.vue index a4d96a5..17fb439 100644 --- a/components/search.vue +++ b/components/search.vue @@ -75,7 +75,7 @@ > @@ -168,6 +168,7 @@ import scrollIntoView from 'scroll-into-view-if-needed' import { getAppCategory } from '~/helpers/categories.js' +import { getAppEndpoint } from '~/helpers/app-derived.js' // import appList from '~/static/app-list.json' // import EmailSubscribe from '~/components/email-subscribe.vue' @@ -320,6 +321,7 @@ export default { }, methods: { getAppCategory, + getAppEndpoint, // Search priorities titleStartsWith (query, app) { const matches = app.name.toLowerCase().startsWith(query) diff --git a/helpers/app-derived.js b/helpers/app-derived.js new file mode 100644 index 0000000..8ca339f --- /dev/null +++ b/helpers/app-derived.js @@ -0,0 +1,11 @@ +// App Data that is derived from other app data + +export function getAppEndpoint ( app ) { + // console.log('app', app) + + if (app.category.slug === 'homebrew') return `/formula/${app.slug}` + + if (app.category.slug === 'games') return `/game/${app.slug}` + + return `/app/${app.slug}` +} diff --git a/helpers/build-app-list.js b/helpers/build-app-list.js index a4f3292..99eb656 100644 --- a/helpers/build-app-list.js +++ b/helpers/build-app-list.js @@ -6,6 +6,7 @@ import axios from 'axios' import statuses from './statuses' import parseGithubDate from './parse-github-date' +import { getAppEndpoint } from './app-derived' const md = new MarkdownIt() @@ -58,8 +59,10 @@ const lookForLastUpdated = function (app, commits) { // console.log('commit', commit) + const appEndpoint = getAppEndpoint(app) + // $$ If message body contains endpoint - if (commit.messageBody.includes(app.endpoint)) { + if (commit.messageBody.includes(appEndpoint)) { // console.log('Found', app.name ,commit.committedDate) return commit.committedDate } @@ -78,7 +81,7 @@ const lookForLastUpdated = function (app, commits) { // $$$ If commits comments contains endpoint for (const { node: comment } of commit.comments.edges) { - if (comment.body.includes(app.endpoint)) { + if (comment.body.includes(appEndpoint)) { // console.log('Found', app.name ,commit.committedDate) return commit.committedDate } @@ -165,7 +168,12 @@ export default async function () { strict: true }) - const endpoint = `/app/${appSlug}` + const endpoint = getAppEndpoint({ + category: { + slug: null + }, + slug: appSlug + })// `/app/${appSlug}` let status = 'unknown' @@ -176,7 +184,11 @@ export default async function () { } } - const lastUpdatedRaw = lookForLastUpdated({ name, endpoint }, commits) + const category = { + slug: categorySlug + } + + const lastUpdatedRaw = lookForLastUpdated({ name, slug: appSlug, endpoint, category }, commits) const lastUpdated = (lastUpdatedRaw) ? { raw: lastUpdatedRaw, @@ -191,10 +203,8 @@ export default async function () { // url, text, slug: appSlug, - endpoint, - category: { - slug: categorySlug - }, + // endpoint, + category, // content: token.content, relatedLinks }) diff --git a/helpers/build-game-list.js b/helpers/build-game-list.js index 1c22435..64e84c9 100644 --- a/helpers/build-game-list.js +++ b/helpers/build-game-list.js @@ -4,6 +4,7 @@ import slugify from 'slugify' import axios from 'axios' // import { statuses } from './build-app-list' +// import { getAppEndpoint } from './app-derived' // console.log('process.env.GAMES_SOURCE', process.env.GAMES_SOURCE) @@ -129,16 +130,21 @@ export default async function () { continue } + const category = { + slug: 'games' + } + gameList.push({ name: game.Games, status, // url: `https://rawg.io/search?query=${encodeURIComponent(game.Games)}`, text: getStatusText(game), slug, - endpoint: `/game/${slug}`, - category: { - slug: 'games' - }, + // endpoint: getAppEndpoint({ + // slug, + // category + // }),//`/game/${slug}`, + category, content: '', // relatedLinks: [], reports: [ diff --git a/helpers/build-homebrew-list.js b/helpers/build-homebrew-list.js index 958bd15..8ef92ae 100644 --- a/helpers/build-homebrew-list.js +++ b/helpers/build-homebrew-list.js @@ -1,7 +1,7 @@ // import { promises as fs } from 'fs' // import MarkdownIt from 'markdown-it' -import slugify from 'slugify' +// import slugify from 'slugify' import axios from 'axios' // import statuses from './statuses' @@ -10,6 +10,7 @@ import axios from 'axios' const marked = require('marked') const HTMLParser = require(`node-html-parser`) +// import { getAppEndpoint } from './app-derived' const statusesTranslations = { @@ -144,16 +145,21 @@ export default async function () { // strict: true // }) + const category = { + slug: 'homebrew' + } + formulaeList.push({ name: formulae.name, status: parseStatus(formulae), // url: `https://formulae.brew.sh/formula/${formulae.name}`, text: getStatusText(formulae), slug, - endpoint: `/formula/${slug}`, - category: { - slug: 'homebrew' - }, + // endpoint: getAppEndpoint({ + // slug, + // category + // }),//`/formula/${slug}`, + category, content: formulae.comments, relatedLinks: [ { diff --git a/nuxt.config.js b/nuxt.config.js index 86ed5f1..bf27b80 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -7,6 +7,7 @@ import buildGamesList from './helpers/build-game-list.js' import buildHomebrewList from './helpers/build-homebrew-list.js' import { categories } from './helpers/categories.js' +import { getAppEndpoint } from './helpers/app-derived.js' const listsOptions = [ @@ -119,7 +120,7 @@ export default { homebrewRoutes ] = lists.map((list, listI) => { return list.map( app => { - return app.endpoint + return getAppEndpoint(app) }) }) diff --git a/pages/index.vue b/pages/index.vue index 9a51d1a..bbe19cb 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -64,7 +64,7 @@ export default { name: app.name, status: app.status, slug: app.slug, - endpoint: app.endpoint, + // endpoint: app.endpoint, text: app.text, lastUpdated: app.lastUpdated, category: app.category,