Skip to content

Commit 257871c

Browse files
Merge branch 'main' into ronith/overriding-footer
2 parents 0cc38a6 + b2384ff commit 257871c

File tree

30 files changed

+313
-216
lines changed

30 files changed

+313
-216
lines changed

.github/workflows/publish-commit.yaml

Lines changed: 11 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,30 @@
1-
# PRs can be published by commenting `/pkg-pr-new` in the PR
1+
# PRs can be published by adding `pkg-pr-new` tag
22

3-
name: Publish Any Commit
3+
name: PR Preview Releases
44

55
on:
6-
issue_comment:
7-
types: [created]
6+
push:
7+
branches: [main]
8+
pull_request:
9+
types: [opened, synchronize, labeled]
810

911
jobs:
10-
build:
11-
if: github.repository == 'stackblitz/tutorialkit' && (github.event_name == 'push' || github.event.issue.pull_request && startsWith(github.event.comment.body, '/pkg-pr-new'))
12+
release:
13+
if: github.repository == 'stackblitz/tutorialkit' && (github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'pkg-pr-new'))
1214
runs-on: ubuntu-latest
15+
name: 'Release: pkg.pr.new'
1316

1417
steps:
15-
- if: github.event.issue.pull_request
16-
uses: actions/github-script@v7
17-
with:
18-
script: |
19-
const user = context.payload.sender.login
20-
console.log(`Validate user: ${user}`)
21-
22-
let hasTriagePermission = false
23-
try {
24-
const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
25-
owner: context.repo.owner,
26-
repo: context.repo.repo,
27-
username: user,
28-
});
29-
hasTriagePermission = data.user.permissions.triage
30-
} catch (e) {
31-
console.warn(e)
32-
}
33-
34-
if (hasTriagePermission) {
35-
console.log('Allowed')
36-
await github.rest.reactions.createForIssueComment({
37-
owner: context.repo.owner,
38-
repo: context.repo.repo,
39-
comment_id: context.payload.comment.id,
40-
content: '+1',
41-
})
42-
} else {
43-
console.log('Not allowed')
44-
await github.rest.reactions.createForIssueComment({
45-
owner: context.repo.owner,
46-
repo: context.repo.repo,
47-
comment_id: context.payload.comment.id,
48-
content: '-1',
49-
})
50-
throw new Error('not allowed')
51-
}
52-
5318
- name: Checkout
5419
uses: actions/checkout@v4
5520
with:
56-
ref: refs/pull/${{ github.event.issue.number }}/head
21+
fetch-depth: 0
5722

5823
- uses: ./.github/actions/setup-and-build
5924

6025
- name: Publish to pkg.pr.new
6126
run: >
62-
pnpm dlx pkg-pr-new@0.0 publish --compact --pnpm
27+
pnpm dlx pkg-pr-new publish --compact --pnpm
6328
./packages/astro
6429
./packages/react
6530
./packages/runtime

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## [1.3.1](https://github.com/stackblitz/tutorialkit/compare/1.3.0...1.3.1) (2024-11-25)
2+
3+
4+
### Bug Fixes
5+
6+
* **astro:** allow URLs in `meta.image` ([#422](https://github.com/stackblitz/tutorialkit/issues/422)) ([3125547](https://github.com/stackblitz/tutorialkit/commit/3125547c043fe4a76dca95b1eb973362967ccf02))
7+
* switch default `meta.image` to `.png` ([#427](https://github.com/stackblitz/tutorialkit/issues/427)) ([d39bf40](https://github.com/stackblitz/tutorialkit/commit/d39bf404bc1947c48b5cb15164f20f67c0be49bc))
8+
* warn when using `.svg` in `meta.image` ([#377](https://github.com/stackblitz/tutorialkit/issues/377)) ([6e1edc1](https://github.com/stackblitz/tutorialkit/commit/6e1edc1af274d0eb65587f358e5db9557d259171))
9+
10+
11+
112
# [1.3.0](https://github.com/stackblitz/tutorialkit/compare/1.2.2...1.3.0) (2024-11-15)
213

314

docs/tutorialkit.dev/src/content/docs/reference/configuration.mdx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,11 @@ type DownloadAsZip =
426426
427427
```
428428

429-
##### `meta`
429+
### `meta`
430430

431431
Configures `<meta>` tags for Open Graph protocole and Twitter.
432432
TutorialKit will use your logo as the default image.
433+
Relative paths are resolved to `public` directory.
433434
<PropertyTable inherited type="MetaTagsSchema" />
434435

435436
The `MetaTagsSchema` type has the following shape:
@@ -449,14 +450,21 @@ meta:
449450
image: /cover.png
450451
title: Title shown on social media and search engines
451452
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+
452460
```
453461

454462
:::tip
455463
If your logo uses the SVG format, it may not display on most social platforms.
456464
Use a raster format instead, such as WEBP or PNG.
457465
:::
458466

459-
##### `custom`
467+
### `custom`
460468

461469
Assign custom fields to a chapter/part/lesson.
462470
<PropertyTable inherited type="Record<string,any>" />

integration/cli/__snapshots__/npm-built.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
"logo-dark.svg",
1111
"logo.svg",
1212
"template-default.json"
13-
]
13+
]

integration/cli/__snapshots__/npm-created.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@
5050
"src/templates/default/style.css",
5151
"tsconfig.json",
5252
"uno.config.ts"
53-
]
53+
]

integration/cli/__snapshots__/pnpm-built.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
"logo-dark.svg",
1111
"logo.svg",
1212
"template-default.json"
13-
]
13+
]

integration/cli/__snapshots__/pnpm-created.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@
5050
"src/templates/default/style.css",
5151
"tsconfig.json",
5252
"uno.config.ts"
53-
]
53+
]

integration/cli/__snapshots__/yarn-built.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
"logo-dark.svg",
1111
"logo.svg",
1212
"template-default.json"
13-
]
13+
]

integration/cli/__snapshots__/yarn-created.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@
5050
"tsconfig.json",
5151
"uno.config.ts",
5252
"yarn.lock"
53-
]
53+
]

integration/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"@tutorialkit/theme": "workspace:*",
1010
"execa": "^9.2.0",
1111
"tempy": "^3.1.0",
12-
"vitest": "^2.1.1"
12+
"vitest": "^3.0.5"
1313
}
1414
}

packages/astro/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## [1.3.1](https://github.com/stackblitz/tutorialkit/compare/1.3.0...1.3.1) "@tutorialkit/astro" (2024-11-25)
2+
3+
4+
### Bug Fixes
5+
6+
* **astro:** allow URLs in `meta.image` ([#422](https://github.com/stackblitz/tutorialkit/issues/422)) ([3125547](https://github.com/stackblitz/tutorialkit/commit/3125547c043fe4a76dca95b1eb973362967ccf02))
7+
* switch default `meta.image` to `.png` ([#427](https://github.com/stackblitz/tutorialkit/issues/427)) ([d39bf40](https://github.com/stackblitz/tutorialkit/commit/d39bf404bc1947c48b5cb15164f20f67c0be49bc))
8+
* warn when using `.svg` in `meta.image` ([#377](https://github.com/stackblitz/tutorialkit/issues/377)) ([6e1edc1](https://github.com/stackblitz/tutorialkit/commit/6e1edc1af274d0eb65587f358e5db9557d259171))
9+
10+
11+
112
# [1.3.0](https://github.com/stackblitz/tutorialkit/compare/1.2.2...1.3.0) "@tutorialkit/astro" (2024-11-15)
213

314

packages/astro/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tutorialkit/astro",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "TutorialKit integration for Astro (https://astro.build)",
55
"author": "StackBlitz Inc.",
66
"type": "module",
@@ -73,7 +73,7 @@
7373
"execa": "^9.2.0",
7474
"typescript": "^5.4.5",
7575
"vite-plugin-inspect": "0.8.4",
76-
"vitest": "^2.1.1"
76+
"vitest": "^3.0.5"
7777
},
7878
"peerDependencies": {
7979
"astro": "^4.15.0"

packages/astro/src/default/components/MetaTags.astro

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,28 @@ import { readPublicAsset } from '../utils/publicAsset';
66
interface Props {
77
meta?: MetaTagsConfig;
88
}
9+
10+
const DEFAULT_OG_IMAGE = 'https://tutorialkit.dev/tutorialkit-opengraph.png';
11+
912
const { meta = {} } = Astro.props;
10-
let imageUrl;
11-
if (meta.image) {
12-
imageUrl = readPublicAsset(meta.image, true);
13+
let imageUrl = meta.image;
14+
15+
// Resolve relative paths to /public folder
16+
if (imageUrl?.startsWith('/') || imageUrl?.startsWith('.')) {
17+
imageUrl = readPublicAsset(imageUrl, true);
18+
1319
if (!imageUrl) {
14-
console.warn(`Image ${meta.image} not found in "/public" folder`);
20+
console.warn(`\nImage ${meta.image} not found in "/public" folder`);
1521
}
1622
}
17-
imageUrl ??= readLogoFile('logo', true);
23+
24+
imageUrl ??= DEFAULT_OG_IMAGE;
25+
26+
if (imageUrl?.endsWith('.svg')) {
27+
console.warn(
28+
`\nUsing a SVG open graph image "${imageUrl}". This is not supported by most social platforms. You should rather set "meta.image" to a raster image (PNG, WEBP).`,
29+
);
30+
}
1831
---
1932

2033
<meta charset="UTF-8" />

packages/astro/src/default/layouts/Layout.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface Props {
1111
}
1212
const { title, meta } = Astro.props;
1313
const faviconUrl = readPublicAsset('favicon.svg');
14+
const canonicalUrl = Astro.site ? new URL(Astro.url.pathname, Astro.site).toString() : null;
1415
---
1516

1617
<!doctype html>
@@ -20,6 +21,7 @@ const faviconUrl = readPublicAsset('favicon.svg');
2021
<title slot="title">{title}</title>
2122

2223
<Fragment slot="links">
24+
{canonicalUrl && <link rel="canonical" href={canonicalUrl} />}
2325
{faviconUrl ? <link rel="icon" type="image/svg+xml" href={faviconUrl} /> : null}
2426
<link rel="preconnect" href="https://fonts.googleapis.com" />
2527
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />

packages/astro/src/default/pages/index.astro

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
import MetaTags from '../components/MetaTags.astro';
23
import { getTutorial } from '../utils/content';
34
import { joinPaths } from '../utils/url';
45
@@ -9,11 +10,16 @@ const part = lesson.part && tutorial.parts[lesson.part.id];
910
const chapter = lesson.chapter && part?.chapters[lesson.chapter.id];
1011
1112
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';
1217
1318
const redirect = joinPaths(import.meta.env.BASE_URL, `/${slug}`);
1419
---
1520

1621
<!doctype html>
1722
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
1823
<title>Redirecting to {redirect}</title>
24+
<MetaTags slot="meta" meta={meta} />
1925
<meta http-equiv="refresh" content=`0;url=${redirect}` />

packages/astro/src/default/utils/content.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ describe('ordering', () => {
320320

321321
test('parts not mention in order are excluded ', async () => {
322322
vi.spyOn(logger, 'warn').mockImplementationOnce(vi.fn());
323+
vi.mocked(logger.warn).mockClear();
323324

324325
getCollection.mockReturnValueOnce([
325326
{
@@ -381,6 +382,7 @@ describe('ordering', () => {
381382

382383
test('chapters not mention in order are excluded ', async () => {
383384
vi.spyOn(logger, 'warn').mockImplementationOnce(vi.fn());
385+
vi.mocked(logger.warn).mockClear();
384386

385387
getCollection.mockReturnValueOnce([
386388
{ id: 'meta.md', ...tutorial },
@@ -515,6 +517,7 @@ describe('ordering', () => {
515517

516518
test('lessons not mention in order are excluded ', async () => {
517519
vi.spyOn(logger, 'warn').mockImplementationOnce(vi.fn());
520+
vi.mocked(logger.warn).mockClear();
518521

519522
getCollection.mockReturnValueOnce([
520523
{ id: 'meta.md', ...tutorial },

packages/cli/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.3.1](https://github.com/stackblitz/tutorialkit/compare/1.3.0...1.3.1) "@tutorialkit/cli" (2024-11-25)
2+
3+
4+
15
# [1.3.0](https://github.com/stackblitz/tutorialkit/compare/1.2.2...1.3.0) "@tutorialkit/cli" (2024-11-15)
26

37

packages/cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tutorialkit/cli",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Interactive tutorials powered by WebContainer API",
55
"author": "StackBlitz Inc.",
66
"type": "module",
@@ -53,7 +53,7 @@
5353
"esbuild-node-externals": "^1.13.1",
5454
"fs-extra": "^11.2.0",
5555
"tempy": "^3.1.0",
56-
"vitest": "^2.1.1"
56+
"vitest": "^3.0.5"
5757
},
5858
"engines": {
5959
"node": ">=18.18.0"

packages/create-tutorial/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.0.3](https://github.com/stackblitz/tutorialkit/compare/1.3.0...0.0.3) "create-tutorial" (2024-11-25)
2+
3+
4+
15
## [0.0.3](https://github.com/stackblitz/tutorialkit/compare/1.2.2...0.0.3) "create-tutorial" (2024-11-15)
26

37

packages/react/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.3.1](https://github.com/stackblitz/tutorialkit/compare/1.3.0...1.3.1) "@tutorialkit/react" (2024-11-25)
2+
3+
4+
15
# [1.3.0](https://github.com/stackblitz/tutorialkit/compare/1.2.2...1.3.0) "@tutorialkit/react" (2024-11-15)
26

37

packages/react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tutorialkit/react",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "TutorialKit's React components and utilities",
55
"author": "StackBlitz Inc.",
66
"type": "module",
@@ -104,6 +104,6 @@
104104
"chokidar": "3.6.0",
105105
"execa": "^9.2.0",
106106
"typescript": "^5.4.5",
107-
"vitest": "^2.1.1"
107+
"vitest": "^3.0.5"
108108
}
109109
}

packages/runtime/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.3.1](https://github.com/stackblitz/tutorialkit/compare/1.3.0...1.3.1) "@tutorialkit/runtime" (2024-11-25)
2+
3+
4+
15
# [1.3.0](https://github.com/stackblitz/tutorialkit/compare/1.2.2...1.3.0) "@tutorialkit/runtime" (2024-11-15)
26

37

packages/runtime/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tutorialkit/runtime",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "TutorialKit runtime",
55
"author": "StackBlitz Inc.",
66
"type": "module",
@@ -43,6 +43,6 @@
4343
"typescript": "^5.4.5",
4444
"vite": "^5.3.1",
4545
"vite-tsconfig-paths": "^4.3.2",
46-
"vitest": "^2.1.1"
46+
"vitest": "^3.0.5"
4747
}
4848
}

packages/test-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"devDependencies": {
88
"@webcontainer/api": "1.5.1",
99
"typescript": "^5.4.5",
10-
"vitest": "^2.1.1"
10+
"vitest": "^3.0.5"
1111
}
1212
}

0 commit comments

Comments
 (0)