mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 15:45:13 +00:00
Roll out meta links resolution to all sites (#3872)
This commit is contained in:
@@ -297,7 +297,7 @@ async function getPageDataWithFallback(args: {
|
||||
}) {
|
||||
const { context: baseContext, pagePathParams } = args;
|
||||
const { context, pageTarget } = await fetchPageData(baseContext, pagePathParams);
|
||||
const pageMetaLinks = await (pageTarget?.page && shouldResolveMetaLinks(context.site.id)
|
||||
const pageMetaLinks = await (pageTarget?.page
|
||||
? resolvePageMetaLinks(context, pageTarget.page.id)
|
||||
: null);
|
||||
|
||||
@@ -359,29 +359,6 @@ async function resolvePageMetaLinks(
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether to resolve meta links for a site based on a percentage rollout.
|
||||
*/
|
||||
function shouldResolveMetaLinks(siteId: string): boolean {
|
||||
const META_LINKS_PERCENTAGE_ROLLOUT = 50;
|
||||
const ALLOWED_SITES: Record<string, boolean> = {
|
||||
site_CZrtk: true,
|
||||
};
|
||||
|
||||
if (ALLOWED_SITES[siteId] || process.env.NODE_ENV === 'development') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// compute a simple hash of the siteId
|
||||
let hash = 0;
|
||||
for (let i = 0; i < siteId.length; i++) {
|
||||
hash = (hash << 5) - hash + siteId.charCodeAt(i);
|
||||
hash = hash & hash; // Convert to 32-bit integer
|
||||
}
|
||||
|
||||
return Math.abs(hash % 100) < META_LINKS_PERCENTAGE_ROLLOUT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the <title> for a page.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user