Files
buzz-sheet/lib/guides/public-sections.ts
T
gunshiz 87e6bcd96f
CI / Verify and audit (push) Successful in 2m33s
CI / Build, scan and deploy immutable images (push) Failing after 1m29s
feat : 6 astra improve it
2026-09-22 18:28:18 +07:00

33 lines
1.4 KiB
TypeScript

import type { PublicGuide } from "@/lib/guides/queries";
function hasPublicSectionContent(guide: PublicGuide, slug: string): boolean {
if (slug === "weapon") return guide.weapons.length > 0;
if (slug === "artifact") {
return guide.artifactGroups.some((condition) =>
condition.tiers.some((group) => group.rows.length > 0),
) || Boolean(
guide.artifactProfile && (
guide.artifactProfile.recommendedConditions.some((condition) =>
condition.sands.length || condition.goblet.length || condition.circlet.length || condition.substats.length,
) ||
guide.artifactProfile.sands.length ||
guide.artifactProfile.goblet.length ||
guide.artifactProfile.circlet.length ||
guide.artifactProfile.substats.length ||
guide.artifactProfile.targetConditions.some((group) => group.rows.length) ||
guide.artifactProfile.talents.length
),
);
}
if (slug === "constellations") {
return guide.constellationGroups.some((group) => group.rows.length > 0);
}
if (slug === "team") return guide.teams.length > 0;
return guide.extras.some((extra) => extra.slug === slug && extra.rows.length > 0);
}
export function publicGuideSections(guide: PublicGuide) {
if (guide.availableSections) return guide.availableSections;
return guide.sections.filter((section) => hasPublicSectionContent(guide, section.slug));
}