feat(guides) : add safer publishing and discovery
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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) {
|
||||
return guide.sections.filter((section) => hasPublicSectionContent(guide, section.slug));
|
||||
}
|
||||
Reference in New Issue
Block a user