@terrafirmagreg-team/recipe 1.2.20 → 1.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrafirmagreg-team/recipe",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Recipe viewer and calculator",
|
|
6
6
|
"license": "LGPL-3.0-only",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@terrafirmagreg-team/data": "^1.2.10",
|
|
27
|
-
"@terrafirmagreg-team/dump": "^1.2.
|
|
28
|
-
"@terrafirmagreg-team/game": "^1.2.
|
|
29
|
-
"@terrafirmagreg-team/kit": "^1.2.
|
|
30
|
-
"@terrafirmagreg-team/mdx": "^1.2.
|
|
31
|
-
"@terrafirmagreg-team/preview": "^1.2.
|
|
27
|
+
"@terrafirmagreg-team/dump": "^1.2.16",
|
|
28
|
+
"@terrafirmagreg-team/game": "^1.2.9",
|
|
29
|
+
"@terrafirmagreg-team/kit": "^1.2.23",
|
|
30
|
+
"@terrafirmagreg-team/mdx": "^1.2.12",
|
|
31
|
+
"@terrafirmagreg-team/preview": "^1.2.7",
|
|
32
32
|
"@terrafirmagreg-team/sites": "^1.2.3",
|
|
33
33
|
"@terrafirmagreg-team/translate": "^1.2.11",
|
|
34
34
|
"@terrafirmagreg-team/ui": "^1.2.16",
|
|
@@ -4,8 +4,10 @@ import { useMemo, useRef, useState, type ComponentProps } from 'react';
|
|
|
4
4
|
import { RecipeCard } from './card';
|
|
5
5
|
import { SlotHitbox } from './slot-hitbox';
|
|
6
6
|
import { StripCard } from './strip-card';
|
|
7
|
+
import { ScrollCard } from './scroll-card';
|
|
7
8
|
import { recipeGlareFilter } from './glare-filter';
|
|
8
9
|
import { recipeGrid } from '@terrafirmagreg-team/recipe/lib/data/grid';
|
|
10
|
+
import { recipeScroll } from '@terrafirmagreg-team/recipe/lib/data/scroll';
|
|
9
11
|
import { recipeSlots } from '@terrafirmagreg-team/recipe/lib/browser/recipe-slots';
|
|
10
12
|
import { PagerArrow } from '@terrafirmagreg-team/ui/components/blocks/page/pager';
|
|
11
13
|
import { useInView } from '@terrafirmagreg-team/ui/hooks/use-in-view';
|
|
@@ -93,6 +95,9 @@ export function PagedCard({
|
|
|
93
95
|
setPage((p) => Math.max(0, Math.min(pages - 1, p + dir))),
|
|
94
96
|
);
|
|
95
97
|
|
|
98
|
+
if (recipeScroll(recipe.properties)) {
|
|
99
|
+
return <ScrollCard {...props} />;
|
|
100
|
+
}
|
|
96
101
|
if (recipeGrid(recipe.properties)) {
|
|
97
102
|
return <StripCard {...props} />;
|
|
98
103
|
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useMemo, useRef, useState, type ComponentProps } from 'react';
|
|
4
|
+
import { recipeGlareFilter } from '@terrafirmagreg-team/recipe/components/cards/glare-filter';
|
|
5
|
+
import { StripCardMember } from '@terrafirmagreg-team/recipe/components/cards/strip-card/member-cell';
|
|
6
|
+
import { StripCardTagPager } from '@terrafirmagreg-team/recipe/components/cards/strip-card/buttons';
|
|
7
|
+
import { recipeScroll } from '@terrafirmagreg-team/recipe/lib/data/scroll';
|
|
8
|
+
import { useInView } from '@terrafirmagreg-team/ui/hooks/use-in-view';
|
|
9
|
+
import { useSwipe } from '@terrafirmagreg-team/ui/hooks/use-swipe';
|
|
10
|
+
import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
|
|
11
|
+
import type { RecipeCard } from '@terrafirmagreg-team/recipe/components/cards/card';
|
|
12
|
+
|
|
13
|
+
const FALLBACK_PITCH = 18;
|
|
14
|
+
|
|
15
|
+
type Props = ComponentProps<typeof RecipeCard>;
|
|
16
|
+
|
|
17
|
+
export function ScrollCard(props: Props) {
|
|
18
|
+
const {
|
|
19
|
+
recipe,
|
|
20
|
+
dataset,
|
|
21
|
+
lang,
|
|
22
|
+
langMap,
|
|
23
|
+
nav,
|
|
24
|
+
title,
|
|
25
|
+
src,
|
|
26
|
+
onFail,
|
|
27
|
+
naturalW,
|
|
28
|
+
naturalH,
|
|
29
|
+
interactive = true,
|
|
30
|
+
slotTooltip,
|
|
31
|
+
eager,
|
|
32
|
+
frameOnly,
|
|
33
|
+
} = props;
|
|
34
|
+
const scale = recipe.scale ?? 2;
|
|
35
|
+
const margin = recipe.margin ?? 0;
|
|
36
|
+
const scroll = recipeScroll(recipe.properties);
|
|
37
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
38
|
+
const observedInView = useInView(rootRef);
|
|
39
|
+
const inView = eager || observedInView;
|
|
40
|
+
const [page, setPage] = useState(0);
|
|
41
|
+
|
|
42
|
+
const members = useMemo(() => {
|
|
43
|
+
if (!scroll) return [];
|
|
44
|
+
const horizontal = scroll.axis === 'horizontal';
|
|
45
|
+
const paneStart = horizontal ? scroll.y : scroll.x;
|
|
46
|
+
const paneEnd = paneStart + (horizontal ? scroll.h : scroll.w);
|
|
47
|
+
return Object.values(recipe.slots ?? {}).filter((slot) => {
|
|
48
|
+
if (slot.x === undefined || slot.y === undefined) return false;
|
|
49
|
+
const mid = horizontal ? slot.y + 9 : slot.x + 9;
|
|
50
|
+
return mid >= paneStart && mid < paneEnd;
|
|
51
|
+
});
|
|
52
|
+
}, [recipe.slots, scroll]);
|
|
53
|
+
|
|
54
|
+
const pitch = useMemo(() => {
|
|
55
|
+
if (!scroll) return FALLBACK_PITCH;
|
|
56
|
+
const horizontal = scroll.axis === 'horizontal';
|
|
57
|
+
const coords = Array.from(
|
|
58
|
+
new Set(members.map((slot) => (horizontal ? slot.x : slot.y) ?? 0)),
|
|
59
|
+
).sort((a, b) => a - b);
|
|
60
|
+
let min = 0;
|
|
61
|
+
for (let i = 1; i < coords.length; i++) {
|
|
62
|
+
const delta = coords[i] - coords[i - 1];
|
|
63
|
+
if (delta > 0 && (min === 0 || delta < min)) min = delta;
|
|
64
|
+
}
|
|
65
|
+
return min || FALLBACK_PITCH;
|
|
66
|
+
}, [members, scroll]);
|
|
67
|
+
|
|
68
|
+
const horizontal = scroll?.axis === 'horizontal';
|
|
69
|
+
const paneSpan = scroll ? (horizontal ? scroll.w : scroll.h) : 0;
|
|
70
|
+
const perPage = Math.max(1, Math.floor(paneSpan / pitch));
|
|
71
|
+
const contentSpan = useMemo(() => {
|
|
72
|
+
if (!scroll) return 0;
|
|
73
|
+
let extent = horizontal ? scroll.x : scroll.y;
|
|
74
|
+
for (const slot of members) {
|
|
75
|
+
extent = Math.max(
|
|
76
|
+
extent,
|
|
77
|
+
(horizontal ? slot.x : slot.y)! + FALLBACK_PITCH,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return extent - (horizontal ? scroll.x : scroll.y);
|
|
81
|
+
}, [members, scroll, horizontal]);
|
|
82
|
+
const pages = Math.max(1, Math.ceil(contentSpan / (perPage * pitch)));
|
|
83
|
+
const clamped = Math.min(page, pages - 1);
|
|
84
|
+
const offset = clamped * perPage * pitch * scale;
|
|
85
|
+
const swipe = useSwipe((dir) =>
|
|
86
|
+
setPage((p) => Math.max(0, Math.min(pages - 1, p + dir))),
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
if (!scroll) return null;
|
|
90
|
+
const pane = {
|
|
91
|
+
left: (scroll.x + margin) * scale,
|
|
92
|
+
top: (scroll.y + margin) * scale,
|
|
93
|
+
width: scroll.w * scale,
|
|
94
|
+
height: scroll.h * scale,
|
|
95
|
+
};
|
|
96
|
+
const memberOf = (slot: (typeof members)[number]) => ({
|
|
97
|
+
id: slot.ref?.id ?? slot.id,
|
|
98
|
+
kind: slot.ref?.kind ?? slot.kind,
|
|
99
|
+
amount: slot.count ?? slot.amount,
|
|
100
|
+
chance: slot.chance,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<div
|
|
105
|
+
ref={rootRef}
|
|
106
|
+
className={cn('relative w-fit overflow-hidden rounded-sm bg-mc-panel')}
|
|
107
|
+
{...swipe}
|
|
108
|
+
onWheel={(event) => {
|
|
109
|
+
if (event.deltaY === 0) return;
|
|
110
|
+
const next = clamped + (event.deltaY > 0 ? 1 : -1);
|
|
111
|
+
if (next < 0 || next >= pages) return;
|
|
112
|
+
event.stopPropagation();
|
|
113
|
+
setPage(next);
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
{/* eslint-disable-next-line @next/next/no-img-element -- dump asset */}
|
|
117
|
+
<img
|
|
118
|
+
src={src}
|
|
119
|
+
alt={title}
|
|
120
|
+
className="block"
|
|
121
|
+
width={naturalW}
|
|
122
|
+
height={naturalH}
|
|
123
|
+
loading="lazy"
|
|
124
|
+
decoding="async"
|
|
125
|
+
onError={onFail}
|
|
126
|
+
style={recipeGlareFilter}
|
|
127
|
+
/>
|
|
128
|
+
<div
|
|
129
|
+
className="absolute overflow-hidden"
|
|
130
|
+
style={{ left: pane.left, top: pane.top, width: pane.width, height: pane.height }}
|
|
131
|
+
>
|
|
132
|
+
{inView && !frameOnly
|
|
133
|
+
? members.map((slot, index) => {
|
|
134
|
+
const x = (slot.x! - scroll.x) * scale;
|
|
135
|
+
const y = (slot.y! - scroll.y) * scale;
|
|
136
|
+
const member = memberOf(slot);
|
|
137
|
+
if (!member.id) return null;
|
|
138
|
+
const shifted = horizontal ? x - offset : y - offset;
|
|
139
|
+
if (shifted < -pitch * scale || shifted > paneSpan * scale)
|
|
140
|
+
return null;
|
|
141
|
+
return (
|
|
142
|
+
<span
|
|
143
|
+
key={`${member.id}:${index}`}
|
|
144
|
+
className="absolute"
|
|
145
|
+
style={{
|
|
146
|
+
left: horizontal ? shifted : x,
|
|
147
|
+
top: horizontal ? y : shifted,
|
|
148
|
+
width: pitch * scale,
|
|
149
|
+
height: pitch * scale,
|
|
150
|
+
}}
|
|
151
|
+
>
|
|
152
|
+
<span className="absolute inset-0 rounded-[2px] border border-black/25 bg-black/10" />
|
|
153
|
+
<span className="absolute inset-0">
|
|
154
|
+
<StripCardMember
|
|
155
|
+
member={member}
|
|
156
|
+
dataset={dataset}
|
|
157
|
+
lang={lang}
|
|
158
|
+
langMap={langMap}
|
|
159
|
+
nav={nav}
|
|
160
|
+
x={0}
|
|
161
|
+
y={0}
|
|
162
|
+
pitch={pitch * scale}
|
|
163
|
+
interactive={interactive}
|
|
164
|
+
tooltipLevel={slotTooltip}
|
|
165
|
+
/>
|
|
166
|
+
</span>
|
|
167
|
+
</span>
|
|
168
|
+
);
|
|
169
|
+
})
|
|
170
|
+
: null}
|
|
171
|
+
</div>
|
|
172
|
+
{pages > 1 && (
|
|
173
|
+
<>
|
|
174
|
+
<StripCardTagPager
|
|
175
|
+
left={(margin + 2) * scale}
|
|
176
|
+
top={margin * scale}
|
|
177
|
+
dir={-1}
|
|
178
|
+
scale={scale}
|
|
179
|
+
disabled={clamped <= 0}
|
|
180
|
+
onClick={() => setPage(clamped - 1)}
|
|
181
|
+
/>
|
|
182
|
+
<StripCardTagPager
|
|
183
|
+
left={(margin + ((naturalW ?? 0) / scale - margin - 14)) * scale}
|
|
184
|
+
top={margin * scale}
|
|
185
|
+
dir={1}
|
|
186
|
+
scale={scale}
|
|
187
|
+
disabled={clamped + 1 >= pages}
|
|
188
|
+
onClick={() => setPage(clamped + 1)}
|
|
189
|
+
/>
|
|
190
|
+
</>
|
|
191
|
+
)}
|
|
192
|
+
</div>
|
|
193
|
+
);
|
|
194
|
+
}
|
package/src/components/tree.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import { encodeQueryValue } from '@terrafirmagreg-team/translate/lib/url';
|
|
|
13
13
|
import { recipeBasePath } from '@terrafirmagreg-team/recipe/lib/links';
|
|
14
14
|
import { sectionDatasets } from '@terrafirmagreg-team/kit/lib/datasets';
|
|
15
15
|
import type { DumpRecipeCategory } from '@terrafirmagreg-team/recipe/lib/data/category/dto';
|
|
16
|
+
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
16
17
|
import type { SectionTrees } from '@terrafirmagreg-team/kit/types';
|
|
17
18
|
|
|
18
19
|
function categoryIcon(
|
|
@@ -53,48 +54,45 @@ function categoryLeaf(
|
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
const recipeTreesCache = createAsyncCache(
|
|
56
|
-
|
|
57
|
-
() =>
|
|
57
|
+
(lang: Lang): Promise<SectionTrees> => buildRecipeTrees(lang),
|
|
58
|
+
(lang) => `recipe-trees/${lang}`,
|
|
58
59
|
DUMP_POINTER_TTL,
|
|
59
60
|
);
|
|
60
61
|
|
|
61
|
-
export function recipeTrees(): Promise<SectionTrees> {
|
|
62
|
-
return recipeTreesCache();
|
|
62
|
+
export function recipeTrees(lang: Lang): Promise<SectionTrees> {
|
|
63
|
+
return recipeTreesCache(lang);
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
async function buildRecipeTrees(): Promise<SectionTrees> {
|
|
66
|
+
async function buildRecipeTrees(lang: Lang): Promise<SectionTrees> {
|
|
66
67
|
const { defaultLanguage } = loadLocaleRegistry();
|
|
67
68
|
const datasets = await sectionDatasets('recipe');
|
|
68
69
|
const trees: SectionTrees = {};
|
|
69
70
|
for (const { id, title: datasetTitle, languages } of datasets) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
.filter((row) => (row.count ?? 0) > 0)
|
|
80
|
-
.map((row) => row.id),
|
|
81
|
-
)
|
|
82
|
-
: undefined;
|
|
83
|
-
const leaves = [...categories]
|
|
84
|
-
.filter((category) => !nonEmpty || nonEmpty.has(category.id))
|
|
85
|
-
.sort(
|
|
86
|
-
(a, b) =>
|
|
87
|
-
creativeTabName(map, a.display?.name).localeCompare(
|
|
88
|
-
creativeTabName(map, b.display?.name),
|
|
89
|
-
) || a.id.localeCompare(b.id),
|
|
71
|
+
if (!(languages ?? [defaultLanguage]).includes(lang)) continue;
|
|
72
|
+
const ref = { id };
|
|
73
|
+
const map = await loadMergedLangMap(ref, lang);
|
|
74
|
+
const source = getRecipeSource();
|
|
75
|
+
const categories = await source.categories(ref);
|
|
76
|
+
const types = (await source.manifest(ref))?.indexes.recipes.types;
|
|
77
|
+
const nonEmpty = types
|
|
78
|
+
? new Set(
|
|
79
|
+
types.filter((row) => (row.count ?? 0) > 0).map((row) => row.id),
|
|
90
80
|
)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
81
|
+
: undefined;
|
|
82
|
+
const leaves = [...categories]
|
|
83
|
+
.filter((category) => !nonEmpty || nonEmpty.has(category.id))
|
|
84
|
+
.sort(
|
|
85
|
+
(a, b) =>
|
|
86
|
+
creativeTabName(map, a.display?.name).localeCompare(
|
|
87
|
+
creativeTabName(map, b.display?.name),
|
|
88
|
+
) || a.id.localeCompare(b.id),
|
|
89
|
+
)
|
|
90
|
+
.map((category) => categoryLeaf(ref, category, map));
|
|
91
|
+
(trees[lang] ??= {})[id] = {
|
|
92
|
+
name: datasetTitle ?? id,
|
|
93
|
+
children: leaves,
|
|
94
|
+
$id: `recipe/${id}/${lang}`,
|
|
95
|
+
} satisfies PageTree.Root;
|
|
98
96
|
}
|
|
99
97
|
return trees;
|
|
100
98
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asNumber,
|
|
3
|
+
asRecord,
|
|
4
|
+
asString,
|
|
5
|
+
} from '@terrafirmagreg-team/dump/lib/dump/contract/read';
|
|
6
|
+
|
|
7
|
+
export type RecipeScroll = {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
w: number;
|
|
11
|
+
h: number;
|
|
12
|
+
axis: 'vertical' | 'horizontal';
|
|
13
|
+
contentH: number;
|
|
14
|
+
contentW: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function recipeScroll(
|
|
18
|
+
properties: Record<string, unknown> | undefined,
|
|
19
|
+
): RecipeScroll | undefined {
|
|
20
|
+
const raw = asRecord(properties?.scroll);
|
|
21
|
+
if (!raw) return undefined;
|
|
22
|
+
const x = asNumber(raw.x);
|
|
23
|
+
const y = asNumber(raw.y);
|
|
24
|
+
const w = asNumber(raw.w);
|
|
25
|
+
const h = asNumber(raw.h);
|
|
26
|
+
const contentH = asNumber(raw.contentH) ?? 0;
|
|
27
|
+
const contentW = asNumber(raw.contentW) ?? 0;
|
|
28
|
+
if (x === undefined || y === undefined || !w || !h) return undefined;
|
|
29
|
+
if (contentH <= h && contentW <= w) return undefined;
|
|
30
|
+
const axis = asString(raw.axis) === 'horizontal' ? 'horizontal' : 'vertical';
|
|
31
|
+
return { x, y, w, h, axis, contentH, contentW };
|
|
32
|
+
}
|
package/src/lib/og.ts
CHANGED
|
@@ -2,14 +2,13 @@ import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
|
2
2
|
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
3
3
|
import { clientDumpLang } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
4
4
|
import { loadClientTagMembers } from '@terrafirmagreg-team/dump/lib/dump/client/tags';
|
|
5
|
-
import type { ReferenceKind } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
6
5
|
import { stripMcFormat } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
|
|
7
6
|
import {
|
|
8
7
|
ogLocalized,
|
|
9
|
-
ogRefSprite,
|
|
10
8
|
ogStackName,
|
|
11
9
|
} from '@terrafirmagreg-team/dump/lib/dump/assets/og';
|
|
12
10
|
import {
|
|
11
|
+
ogImageQuery,
|
|
13
12
|
ogName,
|
|
14
13
|
registerOgResolver,
|
|
15
14
|
type OgContext,
|
|
@@ -25,25 +24,23 @@ async function recipeOgContext(
|
|
|
25
24
|
): Promise<OgContext> {
|
|
26
25
|
const tool = search.get('tool');
|
|
27
26
|
if (tool) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
imageQuery: `tool=${encodeURIComponent(tool)}`,
|
|
31
|
-
};
|
|
27
|
+
const entity = { kind: 'tool', name: recipeToolName(tool, lang) };
|
|
28
|
+
return { entity, imageQuery: ogImageQuery(entity, tool) };
|
|
32
29
|
}
|
|
33
30
|
const item = search.get('item');
|
|
34
31
|
const fluid = search.get('fluid');
|
|
35
32
|
if (item || fluid) {
|
|
36
33
|
const kind = fluid ? 'fluid' : 'item';
|
|
37
34
|
const id = (item ?? fluid)!;
|
|
35
|
+
const entity = {
|
|
36
|
+
kind,
|
|
37
|
+
name: await ogStackName(dataset, id, kind, lang),
|
|
38
|
+
id,
|
|
39
|
+
};
|
|
38
40
|
return {
|
|
39
|
-
entity
|
|
40
|
-
kind,
|
|
41
|
-
name: await ogStackName(dataset, id, kind, lang),
|
|
42
|
-
id,
|
|
43
|
-
},
|
|
44
|
-
icon: () => ogRefSprite(dataset, { kind, id }),
|
|
41
|
+
entity,
|
|
45
42
|
description: id,
|
|
46
|
-
imageQuery:
|
|
43
|
+
imageQuery: ogImageQuery(entity, id),
|
|
47
44
|
};
|
|
48
45
|
}
|
|
49
46
|
const type = search.get('type');
|
|
@@ -57,22 +54,12 @@ async function recipeOgContext(
|
|
|
57
54
|
const tagId = rest.length ? `${ns}:${tagPath}` : ns;
|
|
58
55
|
const members = await loadClientTagMembers(dataset, tagKind);
|
|
59
56
|
const list = tagId ? members?.[`#${tagId}`] : undefined;
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
kind: tagKind as ReferenceKind,
|
|
67
|
-
id: first,
|
|
68
|
-
})
|
|
69
|
-
: undefined,
|
|
70
|
-
description:
|
|
71
|
-
list != null
|
|
72
|
-
? `${list.length} member${list.length === 1 ? '' : 's'}`
|
|
73
|
-
: `${tagKind} tag`,
|
|
74
|
-
imageQuery: `type=emi:tag&id=${encodeURIComponent(id)}`,
|
|
75
|
-
};
|
|
57
|
+
const entity = { kind: 'tag', name: `#${tagId || id}`, id };
|
|
58
|
+
const description =
|
|
59
|
+
list != null
|
|
60
|
+
? `${list.length} member${list.length === 1 ? '' : 's'}`
|
|
61
|
+
: `${tagKind} tag`;
|
|
62
|
+
return { entity, description, imageQuery: ogImageQuery(entity, description) };
|
|
76
63
|
}
|
|
77
64
|
if (id) {
|
|
78
65
|
const recipe = await loadClientRecipe(dataset, id);
|
|
@@ -96,18 +83,9 @@ async function recipeOgContext(
|
|
|
96
83
|
lang,
|
|
97
84
|
).catch(() => recipe.id)
|
|
98
85
|
: recipe.id;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
? () =>
|
|
103
|
-
ogRefSprite(dataset, {
|
|
104
|
-
kind: out.kind === 'tag' ? 'itemTag' : out.kind,
|
|
105
|
-
id: out.id,
|
|
106
|
-
})
|
|
107
|
-
: undefined,
|
|
108
|
-
description: catName ?? recipe.id,
|
|
109
|
-
imageQuery: `id=${encodeURIComponent(id)}`,
|
|
110
|
-
};
|
|
86
|
+
const entity = { kind: 'recipe', name, id: recipe.id };
|
|
87
|
+
const description = catName ?? recipe.id;
|
|
88
|
+
return { entity, description, imageQuery: ogImageQuery(entity, description) };
|
|
111
89
|
}
|
|
112
90
|
if (!type || type === 'all') return {};
|
|
113
91
|
const [categories, map] = await Promise.all([
|
|
@@ -118,11 +96,11 @@ async function recipeOgContext(
|
|
|
118
96
|
if (!category) return {};
|
|
119
97
|
const localized =
|
|
120
98
|
ogLocalized(map, category.display?.name) ?? category.id;
|
|
99
|
+
const entity = { kind: 'category', ...ogName(localized), id: category.id };
|
|
121
100
|
return {
|
|
122
|
-
entity
|
|
123
|
-
icon: () => ogRefSprite(dataset, category.icon),
|
|
101
|
+
entity,
|
|
124
102
|
description: category.id,
|
|
125
|
-
imageQuery:
|
|
103
|
+
imageQuery: ogImageQuery(entity, category.id),
|
|
126
104
|
};
|
|
127
105
|
}
|
|
128
106
|
|