File tree 4 files changed +23
-6
lines changed
docs/tutorialkit.dev/src/content/docs/reference
4 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -426,10 +426,11 @@ type DownloadAsZip =
426
426
427
427
` ` `
428
428
429
- # #### `meta`
429
+ # ## `meta`
430
430
431
431
Configures `<meta>` tags for Open Graph protocole and Twitter.
432
432
TutorialKit will use your logo as the default image.
433
+ Relative paths are resolved to `public` directory.
433
434
<PropertyTable inherited type="MetaTagsSchema" />
434
435
435
436
The `MetaTagsSchema` type has the following shape :
@@ -449,14 +450,21 @@ meta:
449
450
image: /cover.png
450
451
title: Title shown on social media and search engines
451
452
description: Description shown on social media and search engines
453
+
454
+ meta:
455
+ image: /cover.png # Resolves to public/cover.png
456
+
457
+ meta:
458
+ image: 'https://tutorialkit.dev/tutorialkit-opengraph.png' # URL is used as is
459
+
452
460
` ` `
453
461
454
462
:::tip
455
463
If your logo uses the SVG format, it may not display on most social platforms.
456
464
Use a raster format instead, such as WEBP or PNG.
457
465
:: :
458
466
459
- # #### `custom`
467
+ # ## `custom`
460
468
461
469
Assign custom fields to a chapter/part/lesson.
462
470
<PropertyTable inherited type="Record<string,any>" />
Original file line number Diff line number Diff line change @@ -7,13 +7,16 @@ interface Props {
7
7
meta? : MetaTagsConfig ;
8
8
}
9
9
const { meta = {} } = Astro .props ;
10
- let imageUrl;
11
- if (meta .image ) {
12
- imageUrl = readPublicAsset (meta .image , true );
10
+ let imageUrl = meta .image ;
11
+
12
+ if (imageUrl ?.startsWith (' /' ) || imageUrl ?.startsWith (' .' )) {
13
+ imageUrl = readPublicAsset (imageUrl , true );
14
+
13
15
if (! imageUrl ) {
14
16
console .warn (` Image ${meta .image } not found in "/public" folder ` );
15
17
}
16
18
}
19
+
17
20
imageUrl ?? = readLogoFile (' logo' , true );
18
21
---
19
22
Original file line number Diff line number Diff line change 1
1
---
2
+ import MetaTags from ' ../components/MetaTags.astro' ;
2
3
import { getTutorial } from ' ../utils/content' ;
3
4
import { joinPaths } from ' ../utils/url' ;
4
5
@@ -9,11 +10,16 @@ const part = lesson.part && tutorial.parts[lesson.part.id];
9
10
const chapter = lesson .chapter && part ?.chapters [lesson .chapter .id ];
10
11
11
12
const slug = [part ?.slug , chapter ?.slug , lesson .slug ].filter (Boolean ).join (' /' );
13
+ const meta = lesson .data ?.meta ?? {};
14
+
15
+ meta .title ?? = [lesson .part ?.title , lesson .chapter ?.title , lesson .data .title ].filter (Boolean ).join (' / ' );
16
+ meta .description ?? = ' A TutorialKit interactive lesson' ;
12
17
13
18
const redirect = joinPaths (import .meta .env .BASE_URL , ` /${slug } ` );
14
19
---
15
20
16
21
<!doctype html >
17
22
<link rel =" icon" type =" image/svg+xml" href =" /favicon.svg" />
18
23
<title >Redirecting to { redirect } </title >
24
+ <MetaTags slot =" meta" meta ={ meta } />
19
25
<meta http-equiv =" refresh" content =`0;url=${redirect }` />
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export const metaTagsSchema = z.object({
8
8
* Ideally we would want to use `image` from:
9
9
* https://docs.astro.build/en/guides/images/#images-in-content-collections .
10
10
*/
11
- . describe ( 'A relative path to an image that lives in the public folder to show on social previews .' ) ,
11
+ . describe ( 'Image to show on social previews. A relative path is resolved to the public folder .' ) ,
12
12
description : z . string ( ) . optional ( ) . describe ( 'A description for metadata' ) ,
13
13
title : z . string ( ) . optional ( ) . describe ( 'A title to use specifically for metadata' ) ,
14
14
} ) ;
You can’t perform that action at this time.
0 commit comments