Merge pull request #126 from teaxyz/feature/add-sorting-data

* add sorting data to generated packages.json
* attach data to package thumbs
This commit is contained in:
Neil 2022-10-21 15:11:01 +08:00 committed by GitHub
commit cc91e49be2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 41 deletions

View file

@ -24,40 +24,13 @@ export const getAllAirtablePackages = async (): Promise<AirtablePackage[]> => {
'version',
'last_modified',
'full_name',
'dl_count',
]),
maintainer: record.fields?.maintainer || '',
desc: record.fields?.desc || '',
thumb_image_url: _.get(record.fields, 'thumb_image[0].url', '/Images/package-thumb-nolabel3.jpg')
} as AirtablePackage;
});
/**
* // SAMPLE RECORD SHAPE w/ thumb_image is uploaded
{
slug: 'unicode_org',
name: 'unicode.org',
full_name: 'unicode.org',
homepage: 'https://unicode.org',
version: '71.1.1',
last_modified: '2022-09-26T19:46:25.000Z',
thumb_image: [
{
id: 'attQVgaRUXOYinsWy',
width: 640,
height: 534,
url: 'https://dl.airtable.com/.attachments/f2465c36a0060919368e2f53305694f9/cfab76a8/gen-art-1.png',
filename: 'gen-art-1.png',
size: 184878,
type: 'image/png',
thumbnails: [Object]
}
]
}
TODO IMAGE UPLOAD to S3/CDN:
if thumb_image_url is empty
get thumb_image data
upload to s3
update thumb_image_url in airtable
*/
return packages;
}
@ -73,6 +46,7 @@ export const insertPackagesToAirtable = async (newPackages: Partial<AirtablePack
fields: {
...fields,
last_modified: fields.last_modified.toString(),
dl_count: 0,
}
}
});

View file

@ -13,6 +13,7 @@ export type AirtablePackage = S3Package & {
airtable_record_id: string,
thumb_image_url: string,
desc: string,
dl_count: number,
}
export type Package = Omit<AirtablePackage, 'airtable_record_id'> & {

View file

@ -7,7 +7,9 @@
"version": "2.5.1",
"installs": 3986221,
"maintainer": "",
"thumb_image_url": "/Images/package-thumb-nolabel.jpg"
"thumb_image_url": "/Images/package-thumb-nolabel.jpg",
"dl_count": 1,
"last_modified": "2022-09-26T19:46:25.000Z"
},
{
"name": "svg2png",
@ -17,7 +19,9 @@
"version": "0.1.3",
"installs": 1233,
"maintainer": "pascal",
"thumb_image_url": "/Images/package-thumb-nolabel4.jpg"
"thumb_image_url": "/Images/package-thumb-nolabel4.jpg",
"dl_count": 2,
"last_modified": "2022-09-30T15:39:15.000Z"
},
{
"name": "cmake",
@ -27,7 +31,9 @@
"version": "3.24.2",
"installs": 1729267,
"maintainer": "pascal",
"thumb_image_url": "/Images/package-thumb-nolabel3.jpg"
"thumb_image_url": "/Images/package-thumb-nolabel3.jpg",
"dl_count": 3,
"last_modified": "2022-09-27:39:15.000Z"
},
{
"name": "h2c",
@ -37,7 +43,9 @@
"version": "1.0",
"installs": 96,
"maintainer": "h2o",
"thumb_image_url": "/Images/package-thumb-nolabel.jpg"
"thumb_image_url": "/Images/package-thumb-nolabel.jpg",
"dl_count": 4,
"last_modified": "2022-09-25:39:15.000Z"
},
{
"name": "libmagic",
@ -47,7 +55,9 @@
"version": "5.43",
"installs": 162436,
"maintainer": "",
"thumb_image_url": "/Images/package-thumb-nolabel3.jpg"
"thumb_image_url": "/Images/package-thumb-nolabel3.jpg",
"dl_count": 5,
"last_modified": "2022-09-24:39:15.000Z"
},
{
"name": "deno",
@ -57,7 +67,9 @@
"version": "1.26.1",
"installs": 204033,
"maintainer": "Ryan Dahl",
"thumb_image_url": "/Images/package-thumb-nolabel2.jpg"
"thumb_image_url": "/Images/package-thumb-nolabel2.jpg",
"dl_count": 6,
"last_modified": "2022-09-23:39:15.000Z"
},
{
"name": "fontconfig",
@ -67,7 +79,9 @@
"version": "2.14.0",
"installs": 2485083,
"maintainer": "Max Miedinger",
"thumb_image_url": "/Images/package-thumb-nolabel.jpg"
"thumb_image_url": "/Images/package-thumb-nolabel.jpg",
"dl_count": 7,
"last_modified": "2022-09-22:39:15.000Z"
},
{
"name": "pkg-config",
@ -77,7 +91,9 @@
"version": "0.29.2",
"installs": 2634164,
"maintainer": "pascal",
"thumb_image_url": "/Images/package-thumb-nolabel4.jpg"
"thumb_image_url": "/Images/package-thumb-nolabel4.jpg",
"dl_count": 8,
"last_modified": "2022-09-21:39:15.000Z"
},
{
"name": "shared-mime-info",
@ -87,7 +103,9 @@
"version": "2.2",
"installs": 642619,
"maintainer": "Mr.Mime",
"thumb_image_url": "/Images/package-thumb-nolabel3.jpg"
"thumb_image_url": "/Images/package-thumb-nolabel3.jpg",
"dl_count": 9,
"last_modified": "2022-09-21:39:15.000Z"
},
{
"name": "ttfautohint",
@ -97,7 +115,9 @@
"version": "1.8.4",
"installs": 4696,
"maintainer": "pascal",
"thumb_image_url": "/Images/package-thumb-nolabel.jpg"
"thumb_image_url": "/Images/package-thumb-nolabel.jpg",
"dl_count": 10,
"last_modified": "2022-09-20:39:15.000Z"
},
{
"name": "numactl",
@ -107,7 +127,9 @@
"version": "2.0.16",
"installs": 1120,
"maintainer": "FSS",
"thumb_image_url": "/Images/package-thumb-nolabel2.jpg"
"thumb_image_url": "/Images/package-thumb-nolabel2.jpg",
"dl_count": 11,
"last_modified": "2022-09-19:39:15.000Z"
},
{
"name": "flex",
@ -117,6 +139,8 @@
"version": "2.6.4",
"installs": 35001,
"maintainer": "",
"thumb_image_url": "/Images/package-thumb-nolabel4.jpg"
"thumb_image_url": "/Images/package-thumb-nolabel4.jpg",
"dl_count": 12,
"last_modified": "2022-09-18:39:15.000Z"
}
]

View file

@ -1,4 +1,4 @@
<div class="card card-thumbnail" style="width: 100%">
<div class="card card-thumbnail" style="width: 100%" popularity="{{- .dl_count -}}" last_modified="{{- .last_modified -}}">
<figure class="card-img-top" >
<img class="package-image" src="{{- .thumb_image_url -}}" alt="{{- .name -}}" style="width:100%; height:100%;">
<article class="card-thumb-label">