Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release v0.1.150 #481

Merged
merged 4 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"packages": [
"packages/*"
],
"version": "0.1.149",
"version": "0.1.150-alpha.0",
"npmClient": "pnpm"
}
21 changes: 21 additions & 0 deletions packages/zenn-cli/articles/embed-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,31 @@ https://gist.github.com/hofmannsven/9164408?file=my.cnf

## Twitter

### `@[tweet]` 記法(`twitter.com`)

@[tweet](https://twitter.com/jack/status/20)

@[tweet](https://twitter.com/steelydylan/status/1253567029010825216)

### `@[tweet]` 記法(`x.com`)

@[tweet](https://x.com/jack/status/20)

@[tweet](https://x.com/steelydylan/status/1253567029010825216)

### URL埋め込み(`twitter.com`)

https://twitter.com/jack/status/20

https://twitter.com/steelydylan/status/1253567029010825216

### URL埋め込み(`x.com`)

https://x.com/jack/status/20

https://x.com/steelydylan/status/1253567029010825216


## 👇html tag cannot be embedded.

<iframe width="560" height="315" src="https://www.youtube.com/embed/ToLJE4YEQRI" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allow="fullscreen"></iframe>
2 changes: 1 addition & 1 deletion packages/zenn-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenn-cli",
"version": "0.1.149",
"version": "0.1.150-alpha.0",
"description": "Preview Zenn content locally.",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/zenn-content-css/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenn-content-css",
"version": "0.1.149",
"version": "0.1.150-alpha.0",
"license": "MIT",
"description": "Zenn flavor content style.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/zenn-embed-elements/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenn-embed-elements",
"version": "0.1.149",
"version": "0.1.150-alpha.0",
"license": "MIT",
"description": "Web components for embedded contents.",
"repository": {
Expand Down
80 changes: 56 additions & 24 deletions packages/zenn-markdown-html/__tests__/link.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,32 +215,64 @@ describe('Linkifyのテスト', () => {
});

describe('Tweet埋め込みのテスト', () => {
test('ツイートリンクを<iframe />に変換する', () => {
const url = 'https://twitter.com/jack/status/20';
const html = renderLink(`${url}`);
const iframe = parse(html).querySelector('span.zenn-embedded iframe');
const pattern = new RegExp(`${options.embedOrigin}/tweet#.+`);

expect(iframe?.attributes).toEqual(
expect.objectContaining({
src: expect.stringMatching(pattern),
'data-content': encodeURIComponent(url),
})
);
describe('twitter.com', () => {
test('ツイートリンクを<iframe />に変換する', () => {
const url = 'https://twitter.com/jack/status/20';
const html = renderLink(`${url}`);
const iframe = parse(html).querySelector('span.zenn-embedded iframe');
const pattern = new RegExp(`${options.embedOrigin}/tweet#.+`);

expect(iframe?.attributes).toEqual(
expect.objectContaining({
src: expect.stringMatching(pattern),
'data-content': encodeURIComponent(url),
})
);
});

test('クエリ文字列を含むツイートリンクを埋め込み<iframe />に変換する', () => {
const url = `https://twitter.com/jack/status/20?foo=123456&t=ab-cd_ef`;
const html = renderLink(url);
const iframe = parse(html).querySelector('span.zenn-embedded iframe');
const pattern = new RegExp(`${options.embedOrigin}/tweet#.+`);

expect(iframe?.attributes).toEqual(
expect.objectContaining({
src: expect.stringMatching(pattern),
'data-content': encodeURIComponent(url),
})
);
});
});

test('クエリ文字列を含むツイートリンクを埋め込み<iframe />に変換する', () => {
const url = `https://twitter.com/jack/status/20?foo=123456&t=ab-cd_ef`;
const html = renderLink(url);
const iframe = parse(html).querySelector('span.zenn-embedded iframe');
const pattern = new RegExp(`${options.embedOrigin}/tweet#.+`);

expect(iframe?.attributes).toEqual(
expect.objectContaining({
src: expect.stringMatching(pattern),
'data-content': encodeURIComponent(url),
})
);
describe('x.com', () => {
test('ツイートリンクを<iframe />に変換する', () => {
const url = 'https://x.com/jack/status/20';
const html = renderLink(`${url}`);
const iframe = parse(html).querySelector('span.zenn-embedded iframe');
const pattern = new RegExp(`${options.embedOrigin}/tweet#.+`);

expect(iframe?.attributes).toEqual(
expect.objectContaining({
src: expect.stringMatching(pattern),
'data-content': encodeURIComponent(url),
})
);
});

test('クエリ文字列を含むツイートリンクを埋め込み<iframe />に変換する', () => {
const url = `https://x.com/jack/status/20?foo=123456&t=ab-cd_ef`;
const html = renderLink(url);
const iframe = parse(html).querySelector('span.zenn-embedded iframe');
const pattern = new RegExp(`${options.embedOrigin}/tweet#.+`);

expect(iframe?.attributes).toEqual(
expect.objectContaining({
src: expect.stringMatching(pattern),
'data-content': encodeURIComponent(url),
})
);
});
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/zenn-markdown-html/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenn-markdown-html",
"version": "0.1.149",
"version": "0.1.150-alpha.0",
"license": "MIT",
"description": "Convert markdown to zenn flavor html.",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/zenn-markdown-html/src/utils/url-matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function isGistUrl(url: string): boolean {
}

export function isTweetUrl(url: string): boolean {
return /^https:\/\/twitter\.com\/[a-zA-Z0-9_-]+\/status\/[a-zA-Z0-9?=&\-_]+$/.test(
return /^https:\/\/(twitter|x)\.com\/[a-zA-Z0-9_-]+\/status\/[a-zA-Z0-9?=&\-_]+$/.test(
url
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/zenn-model/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenn-model",
"version": "0.1.149",
"version": "0.1.150-alpha.0",
"license": "MIT",
"description": "Model utils for Zenn contents",
"main": "lib/index.js",
Expand Down
Loading