Skip to content

Commit c272fbe

Browse files
cookesanaklinker1
andauthored
docs: show Edge Add-ons in showcase (#2452)
Co-authored-by: Aaron <aaronklinker1@gmail.com>
1 parent f40005d commit c272fbe

3 files changed

Lines changed: 46 additions & 12 deletions

File tree

docs/.vitepress/components/UsingWxtSection.vue

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ interface ListedExtension {
2121
const extensionEntries = _extensionEntries as Array<{
2222
chromeId?: string;
2323
firefoxSlug?: string;
24+
edgeId?: string;
2425
}>;
2526
2627
const chromeIds = extensionEntries.flatMap((e) =>
@@ -31,8 +32,13 @@ const firefoxSlugs = [
3132
extensionEntries.flatMap((e) => (e.firefoxSlug ? [e.firefoxSlug] : [])),
3233
),
3334
];
35+
const edgeIds = extensionEntries.flatMap((e) => (e.edgeId ? [e.edgeId] : []));
3436
35-
const { data, isLoading } = useListExtensionDetails(chromeIds, firefoxSlugs);
37+
const { data, isLoading } = useListExtensionDetails(
38+
chromeIds,
39+
firefoxSlugs,
40+
edgeIds,
41+
);
3642
3743
function addUtmSource(storeUrl: string): string {
3844
const url = new URL(storeUrl);
@@ -49,6 +55,9 @@ const sortedExtensions = computed((): ListedExtension[] => {
4955
const firefoxBySlug = new Map(
5056
(data.value.firefox ?? []).filter(Boolean).map((e) => [e.id, e]),
5157
);
58+
const edgeById = new Map(
59+
(data.value.edge ?? []).filter(Boolean).map((e) => [e.id, e]),
60+
);
5261
5362
const results: ListedExtension[] = [];
5463
@@ -57,12 +66,14 @@ const sortedExtensions = computed((): ListedExtension[] => {
5766
const firefox = entry.firefoxSlug
5867
? firefoxBySlug.get(entry.firefoxSlug)
5968
: undefined;
69+
const edge = entry.edgeId ? edgeById.get(entry.edgeId) : undefined;
6070
61-
if (!chrome && !firefox) continue;
71+
if (!chrome && !firefox && !edge) continue;
6272
63-
const primary = chrome ?? firefox!;
64-
const users = (chrome?.users ?? 0) + (firefox?.users ?? 0);
65-
const rating = chrome?.rating ?? firefox?.rating;
73+
const primary = chrome ?? firefox ?? edge!;
74+
const users =
75+
(chrome?.users ?? 0) + (firefox?.users ?? 0) + (edge?.users ?? 0);
76+
const rating = chrome?.rating ?? firefox?.rating ?? edge?.rating;
6677
6778
const stores: StoreLink[] = [];
6879
if (chrome) {
@@ -71,9 +82,16 @@ const sortedExtensions = computed((): ListedExtension[] => {
7182
if (firefox) {
7283
stores.push({ label: 'Firefox', url: addUtmSource(firefox.storeUrl) });
7384
}
85+
if (edge) {
86+
stores.push({ label: 'Edge', url: addUtmSource(edge.storeUrl) });
87+
}
7488
7589
results.push({
76-
id: entry.chromeId ?? `firefox:${entry.firefoxSlug}`,
90+
id:
91+
entry.chromeId ??
92+
(entry.firefoxSlug
93+
? `firefox:${entry.firefoxSlug}`
94+
: `edge:${entry.edgeId}`),
7795
name: primary.name,
7896
iconUrl: primary.iconUrl,
7997
shortDescription: primary.shortDescription,

docs/.vitepress/composables/useListExtensionDetails.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ export interface Extension {
1313
export interface ExtensionResults {
1414
chrome: Extension[];
1515
firefox: Extension[];
16+
edge: Extension[];
1617
}
1718

1819
const operationName = 'WxtDocsUsedBy';
19-
const query = `query ${operationName}($chromeIds: [String!]!, $firefoxIds: [String!]!) {
20+
const query = `query ${operationName}($chromeIds: [String!]!, $firefoxIds: [String!]!, $edgeIds: [String!]!) {
2021
chromeExtensions(ids: $chromeIds) {
2122
id
2223
...ExtensionData
@@ -25,6 +26,10 @@ const query = `query ${operationName}($chromeIds: [String!]!, $firefoxIds: [Stri
2526
id: slug
2627
...ExtensionData
2728
}
29+
edgeAddons(ids: $edgeIds) {
30+
id
31+
...ExtensionData
32+
}
2833
}
2934
3035
fragment ExtensionData on Extension {
@@ -36,13 +41,21 @@ fragment ExtensionData on Extension {
3641
users
3742
}`;
3843

39-
export default function (chromeIds: string[], firefoxSlugs: string[]) {
44+
export default function (
45+
chromeIds: string[],
46+
firefoxSlugs: string[],
47+
edgeIds: string[],
48+
) {
4049
const data = ref<ExtensionResults>();
4150
const err = ref<unknown>();
4251
const isLoading = ref(true);
4352

44-
if (chromeIds.length === 0 && firefoxSlugs.length === 0) {
45-
data.value = { chrome: [], firefox: [] };
53+
if (
54+
chromeIds.length === 0 &&
55+
firefoxSlugs.length === 0 &&
56+
edgeIds.length === 0
57+
) {
58+
data.value = { chrome: [], firefox: [], edge: [] };
4659
isLoading.value = false;
4760
return { data, err, isLoading };
4861
}
@@ -52,7 +65,7 @@ export default function (chromeIds: string[], firefoxSlugs: string[]) {
5265
body: JSON.stringify({
5366
operationName,
5467
query,
55-
variables: { chromeIds, firefoxIds: firefoxSlugs },
68+
variables: { chromeIds, firefoxIds: firefoxSlugs, edgeIds },
5669
}),
5770
headers: {
5871
'Content-Type': 'application/json',
@@ -64,6 +77,7 @@ export default function (chromeIds: string[], firefoxSlugs: string[]) {
6477
data.value = {
6578
chrome: responseData.chromeExtensions ?? [],
6679
firefox: responseData.firefoxAddons ?? [],
80+
edge: responseData.edgeAddons ?? [],
6781
};
6882
err.value = undefined;
6983
})

docs/assets/extension-showcase.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
# Use:
88
#
99
# - `chromeId` for the Chrome Web Store listing,
10-
# - `firefoxSlug` for Firefox Add-ons (slug from https://addons.mozilla.org/firefox/addon/{slug}/)
10+
# - `firefoxSlug` for Firefox Add-ons (slug from https://addons.mozilla.org/firefox/addon/{slug}/),
11+
# - `edgeId` for the Edge Add-ons listing (ID from https://microsoftedge.microsoft.com/addons/detail/{slug}/{id})
1112
#
1213
# You may include one or more of these fields for your extension.
1314

@@ -30,6 +31,7 @@
3031
- # StayFree - Website Blocker & Web Analytics
3132
chromeId: elfaihghhjjoknimpccccmkioofjjfkf
3233
firefoxSlug: stayfree
34+
edgeId: aghmglalnfmjbipodadgbgpakneabgnp
3335

3436
- # Doozy: Ai Made Easy
3537
chromeId: okifoaikfmpfcamplcfjkpdnhfodpkil

0 commit comments

Comments
 (0)