Skip to content

Commit

Permalink
🎨 Resolve tag PR comments (#1930)
Browse files Browse the repository at this point in the history
* πŸ› Fix tag API not passing limit & offset

* 🎨 Return object for tag name & description in API
  • Loading branch information
nwingt authored Nov 1, 2024
1 parent 14e9b44 commit 88294d2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/pages/store/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -953,11 +953,11 @@ export default {
},
localizedBookstoreCMSTags() {
const isChinese = this.$i18n.locale === 'zh-Hant';
const lang = this.$i18n.locale === 'zh-Hant' ? 'zh' : 'en';
return this.bookstoreCMSTags.map(tag => ({
...tag,
name: isChinese ? tag.nameZh : tag.nameEn,
description: isChinese ? tag.descriptionZh : tag.descriptionEn,
name: tag.name[lang],
description: tag.description[lang],
}));
},
bookstoreTagButtons() {
Expand Down
4 changes: 3 additions & 1 deletion src/server/api/routes/bookstore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ const router = Router();

router.get('/bookstore/tags', async (req, res, next) => {
try {
const { limit: pageSize, offset } = req.query;
const result = await fetchAirtableCMSTags({
pageSize: 100,
pageSize,
offset,
});

if (!IS_TESTNET) {
Expand Down
18 changes: 10 additions & 8 deletions src/server/api/util/airtable.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,21 @@ async function fetchAirtableCMSTags({ pageSize = 100, offset }) {

const normalizedRecords = results.data.records.map(({ fields }) => {
const id = fields.ID;
const name = fields.Name;
const nameZh = fields.Name;
const nameEn = fields['Name (Eng)'];
const description = fields.Description;
const descriptionZh = fields.Description;
const descriptionEn = fields['Description (Eng)'];
const isPublic = fields.Public;
return {
id,
name,
nameZh: name,
nameEn,
description,
descriptionZh: description,
descriptionEn,
name: {
zh: nameZh,
en: nameEn,
},
description: {
zh: descriptionZh,
en: descriptionEn,
},
isPublic,
};
});
Expand Down

0 comments on commit 88294d2

Please sign in to comment.