Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@radix-ui/react-toolbar": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.4",
"@radix-ui/themes": "^3.1.3",
"@sentry-internal/global-search": "^1.1.0",
"@sentry-internal/global-search": "1.2.0",
"@sentry/nextjs": "9.0.0-alpha.0",
"@types/mdx": "^2.0.9",
"algoliasearch": "^4.23.3",
Expand Down
34 changes: 34 additions & 0 deletions scripts/algolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,39 @@ async function generateAlogliaRecords(pageFrontMatters: FrontMatter[]) {
return records.flat();
}

/**
* Framework popularity ranking map - frameworks listed in order of priority
*/
const frameworkPopularity: Record<string, number> = {
nextjs: 1,
react: 2,
'react-native': 3,
python: 4,
laravel: 5,
node: 6,
vue: 7,
ios: 8,
angular: 9,
nestjs: 10,
django: 11,
spring: 12,
go: 13,
ruby: 14,
kotlin: 15,
dart: 16,
unity: 17,
};

const getPopularity = (sdk: string | undefined, framework: string | undefined) => {
if (sdk && frameworkPopularity[sdk]) {
return frameworkPopularity[sdk];
}
if (framework && frameworkPopularity[framework]) {
return frameworkPopularity[framework];
}
return Number.MAX_SAFE_INTEGER;
};

async function getRecords(pageFm: FrontMatter) {
console.log('processing:', pageFm.slug);

Expand All @@ -155,6 +188,7 @@ async function getRecords(pageFm: FrontMatter) {
keywords: pageFm.keywords,
sdk,
framework,
...(!isDeveloperDocs && {popularity: getPopularity(sdk, framework)}),
},
'#main'
);
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3049,10 +3049,10 @@
dependencies:
"@sentry/core" "9.0.0-alpha.0"

"@sentry-internal/global-search@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/global-search/-/global-search-1.1.0.tgz#108f11149a2516ea96b8a544fb4f8a0c046288e2"
integrity sha512-PL2oGOxr0vdnfPwVczs7VuV8bKhypbi1yN13gAT42AxgaSk3joBWzlEzLo7SXK53zBTWVyM2SAyBDzHWXEerJg==
"@sentry-internal/global-search@1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/global-search/-/global-search-1.2.0.tgz#43d68c9f277b51d9031ed16cb938731f9bf4782c"
integrity sha512-F1f2Q+kmoXlmUeyRVoKjpk4ZPOyRMnP4FdAIt8kp0zmNWPitQDVn3MzRIoFe70IB9PI3ygKTZHmuJDxHZ+kcHg==
dependencies:
"@types/react" ">=16"
"@types/react-dom" ">=16"
Expand Down
Loading