@grove-dev/astro 1.0.1 → 1.1.0
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 +2 -2
- package/src/server/directory.ts +7 -0
- package/src/server/models.ts +26 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grove-dev/astro",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Astro integration + server view-models for Grove directories. UI ships from @grove-dev/registry, not from this package.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"sanitize-html": "^2.17.7",
|
|
52
52
|
"shiki": "^4.4.3",
|
|
53
53
|
"yaml": "^2.9.0",
|
|
54
|
-
"@grove-dev/core": "1.0
|
|
54
|
+
"@grove-dev/core": "1.1.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"astro": "^6.0.0 || ^7.0.0"
|
package/src/server/directory.ts
CHANGED
package/src/server/models.ts
CHANGED
|
@@ -78,6 +78,19 @@ export interface SiteIndexPolicy {
|
|
|
78
78
|
taxonomyIndexPolicy?: string;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* A category, stack or licence term with its optional editorial copy
|
|
83
|
+
* from `data/taxonomy/*.yml`: `description` is the page lede and meta
|
|
84
|
+
* description, `heading` the H1, `seoTitle` the `<title>`.
|
|
85
|
+
*/
|
|
86
|
+
export interface TaxonomyTermCopy {
|
|
87
|
+
id: string;
|
|
88
|
+
name: string;
|
|
89
|
+
description?: string;
|
|
90
|
+
heading?: string;
|
|
91
|
+
seoTitle?: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
81
94
|
export interface DirectorySiteConfig {
|
|
82
95
|
name: string;
|
|
83
96
|
tagline?: string;
|
|
@@ -120,11 +133,11 @@ export interface DirectorySiteConfig {
|
|
|
120
133
|
labelPlural?: string;
|
|
121
134
|
};
|
|
122
135
|
taxonomy?: {
|
|
123
|
-
categories?: Array<
|
|
124
|
-
stacks?: Array<
|
|
136
|
+
categories?: Array<TaxonomyTermCopy>;
|
|
137
|
+
stacks?: Array<TaxonomyTermCopy>;
|
|
125
138
|
platforms?: Array<{ id: string; name: string }>;
|
|
126
139
|
topics?: Array<{ id: string; name: string }>;
|
|
127
|
-
licenses?: Array<
|
|
140
|
+
licenses?: Array<TaxonomyTermCopy>;
|
|
128
141
|
distributionChannels?: Array<{ id: string; name: string }>;
|
|
129
142
|
};
|
|
130
143
|
contributors?: {
|
|
@@ -1126,7 +1139,7 @@ export function getTaxonomyPageModel(
|
|
|
1126
1139
|
? `${titleCaseFirst(plural)} built with ${displayName} on ${site.name}`
|
|
1127
1140
|
: `${licenseLabel}-licensed ${plural} on ${site.name}`;
|
|
1128
1141
|
const description = seoDescription(
|
|
1129
|
-
|
|
1142
|
+
site.taxonomy?.[kind]?.find((t) => t.id === id)?.description,
|
|
1130
1143
|
kind === 'categories'
|
|
1131
1144
|
? `${count} curated open-source ${plural} in the ${displayName} category on ${site.name}. Compare stars, activity, and licenses.`
|
|
1132
1145
|
: kind === 'stacks'
|
|
@@ -1149,13 +1162,11 @@ export function getTaxonomyPageModel(
|
|
|
1149
1162
|
...(r.description ? { description: r.description } : {}),
|
|
1150
1163
|
};
|
|
1151
1164
|
});
|
|
1152
|
-
// `seo.taxonomyIndexPolicy` covers categories
|
|
1153
|
-
// a term
|
|
1154
|
-
//
|
|
1155
|
-
|
|
1156
|
-
const term = kind === 'licenses' ? undefined : site.taxonomy?.[kind]?.find((t) => t.id === id);
|
|
1165
|
+
// `seo.taxonomyIndexPolicy` covers categories, stacks and licences:
|
|
1166
|
+
// under `editorial` a term needs intro copy (`description` in
|
|
1167
|
+
// data/taxonomy). An empty term is left to the page, as before.
|
|
1168
|
+
const term = site.taxonomy?.[kind]?.find((t) => t.id === id);
|
|
1157
1169
|
const excludedByPolicy =
|
|
1158
|
-
kind !== 'licenses' &&
|
|
1159
1170
|
count > 0 &&
|
|
1160
1171
|
!taxonomyTermIndexable(
|
|
1161
1172
|
{ count, description: term?.description },
|
|
@@ -1165,7 +1176,7 @@ export function getTaxonomyPageModel(
|
|
|
1165
1176
|
...(excludedByPolicy ? { noindex: true, robots: NOINDEX_FOLLOW } : {}),
|
|
1166
1177
|
// `main` already names the site, so seoTitle appends nothing —
|
|
1167
1178
|
// it still runs for the length/whitespace normalization.
|
|
1168
|
-
title: seoTitle(main, site.name),
|
|
1179
|
+
title: seoTitle(term?.seoTitle?.trim() || term?.heading?.trim() || main, site.name),
|
|
1169
1180
|
description,
|
|
1170
1181
|
image: ogPath(kind === 'categories' ? 'category' : kind === 'stacks' ? 'stack' : 'license', id),
|
|
1171
1182
|
imageAlt: `${displayName} — ${site.name}`,
|
|
@@ -1188,6 +1199,10 @@ export function getTaxonomyPageModel(
|
|
|
1188
1199
|
id,
|
|
1189
1200
|
displayName,
|
|
1190
1201
|
eyebrow: TAXONOMY_EYEBROW[kind],
|
|
1202
|
+
/** Editorial H1 (`heading`), when the term has one. */
|
|
1203
|
+
heading: term?.heading?.trim() || undefined,
|
|
1204
|
+
/** Editorial lede (`description`), when the term has one. */
|
|
1205
|
+
lede: term?.description?.trim() || undefined,
|
|
1191
1206
|
records,
|
|
1192
1207
|
count,
|
|
1193
1208
|
seo,
|