File tree Expand file tree Collapse file tree 2 files changed +25
-29
lines changed Expand file tree Collapse file tree 2 files changed +25
-29
lines changed Original file line number Diff line number Diff line change @@ -7,23 +7,20 @@ import { tagsValues } from "~/schemas/tags";
77type Props = z .infer <typeof props >;
88
99const props = z .object ({
10- tags: z
11- .array (z .string ())
12- .optional ()
13- .transform ((tags ) => {
14- if (tags ) {
15- // Only keep values that are in tagsValues
16- return tags .filter ((tag ) => tagsValues .includes (tag ));
17- }
18- return [];
19- }),
10+ tags: z .array (z .string ()).transform ((tags ) => {
11+ if (tags ) {
12+ // Only keep values that are in tagsValues
13+ return tags .filter ((tag ) => tagsValues .includes (tag ));
14+ }
15+ return [];
16+ }),
2017});
2118
2219const { tags } = props .parse (Astro .props );
2320---
2421
2522{
26- tags && (
23+ tags && tags ?. length > 0 && (
2724 <div class = " flex flex-row gap-2" >
2825 <strong >Page tags:</strong >
2926 { tags .map ((tag ) => (
Original file line number Diff line number Diff line change @@ -143,27 +143,26 @@ if (Astro.locals.starlightRoute.entry.data.tags) {
143143 type Props = z .infer <typeof props >;
144144
145145 const props = z .object ({
146- tags: z
147- .array (z .string ())
148- .optional ()
149- .transform ((tags ) => {
150- if (tags ) {
151- // Only keep values that are in tagsValues
152- return tags .filter ((tag ) => tagsValues .includes (tag ));
153- }
154- return [];
155- }),
146+ tags: z .array (z .string ()).transform ((tags ) => {
147+ if (tags ) {
148+ // Only keep values that are in tagsValues
149+ return tags .filter ((tag ) => tagsValues .includes (tag ));
150+ }
151+ return [];
152+ }),
156153 });
157154
158155 const { tags } = props .parse (Astro .locals .starlightRoute .entry .data );
159- head .push ({
160- tag: " meta" ,
161- attrs: {
162- name: " pcx_tags" ,
163- content: tags .toString (),
164- },
165- content: " " ,
166- });
156+ if (tags .length > 0 ) {
157+ head .push ({
158+ tag: " meta" ,
159+ attrs: {
160+ name: " pcx_tags" ,
161+ content: tags .toString (),
162+ },
163+ content: " " ,
164+ });
165+ }
167166}
168167
169168if (Astro .locals .starlightRoute .entry .data .updated ) {
You can’t perform that action at this time.
0 commit comments