From fbedd56e9325dd810177e8c500b971ec45ffb7da Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Mon, 24 Apr 2023 12:54:05 +0530 Subject: [PATCH] added featuredAuthors component --- app/src/plugins/data.ts | 40 +++++++++++++++----- app/src/views/Authors.vue | 79 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 109 insertions(+), 10 deletions(-) diff --git a/app/src/plugins/data.ts b/app/src/plugins/data.ts index afad0181d..80ce81cb7 100644 --- a/app/src/plugins/data.ts +++ b/app/src/plugins/data.ts @@ -197,6 +197,37 @@ export async function fetchRepo( } } +export async function queryAuthors( + q: FirestoreQuery +): Promise> { + const collectionPath = `/authors`; + const json = await fetchQuery(collectionPath, q); + allAuthors = json as QueryResult; + return json as QueryResult; +} + + +export async function fetchFeaturedAuthors( +): Promise> { + const collectionPath = `/featuredAuthors`; + const json = await fetchQuery(collectionPath, {}); + const featuredAuthorData = []; + for(const ele of json.docs) { + featuredAuthorData.push(ele.data.id) + } + const q: FirestoreQuery = {where: [ + { + fieldPath: "id", + operator: "in", + value: featuredAuthorData, + }, + ],} + const featuredAuthors = await queryAuthors(q) + + return featuredAuthors as QueryResult; +} + + export async function fetchBlog( product: string, id: string @@ -221,15 +252,6 @@ export async function fetchRepoPage( } } -export async function queryAuthors( - q: FirestoreQuery -): Promise> { - const collectionPath = `/authors`; - const json = await fetchQuery(collectionPath, q); - allAuthors = json as QueryResult; - return json as QueryResult; -} - export async function queryBlogs( product: string, q: FirestoreQuery diff --git a/app/src/views/Authors.vue b/app/src/views/Authors.vue index f93adbf85..48350c427 100644 --- a/app/src/views/Authors.vue +++ b/app/src/views/Authors.vue @@ -34,6 +34,73 @@ +
+

+ Featured Authors +

+

+ View a selection of our featured authors. Click “View profile” to view their featured author page and preferred way to connect. +

+
+
+ + +
+
+
+ {{ author.metadata.name }} +
+ + + + + + View profile + +
+ +
+
+ +

+ All Authors +

+

+ View all of our authors. Click “View profile” to view their author page and preferred way to connect. +

+
+
@@ -252,7 +319,8 @@ import { nextPage, PagedResponse, queryAuthors, - queryUsingAuthorData + queryUsingAuthorData, + fetchFeaturedAuthors } from "@/plugins/data"; @Component({ @@ -285,6 +353,7 @@ export default class Authors extends Vue { private pagesToShow = 1; public allAuthors: AuthorData[] = []; + public featuredAuthors: AuthorData[] = []; public allAuthorDetailedData = new Map(); public authorData: PagedResponse = emptyPageResponse( `/authors`, @@ -307,6 +376,14 @@ export default class Authors extends Vue { }, 60 ); + const featuredRes = await fetchFeaturedAuthors() + this.featuredAuthors = featuredRes.docs.map((d) => d.data) + .sort((a, b) => { + return a.metadata.name + .toLowerCase() + .localeCompare(b.metadata.name.toLowerCase()); + }); + console.log(this.featuredAuthors) const authorsPromise = nextPage(authorData); const reloadPromise = Promise.all([authorsPromise]).then(async () => { this.pagesToShow = 1;