diff --git a/lerna.json b/lerna.json
index 155f380f..f3a10f6f 100644
--- a/lerna.json
+++ b/lerna.json
@@ -2,6 +2,6 @@
"packages": [
"packages/*"
],
- "version": "0.1.149",
+ "version": "0.1.150-alpha.0",
"npmClient": "pnpm"
}
diff --git a/packages/zenn-cli/articles/embed-examples.md b/packages/zenn-cli/articles/embed-examples.md
index e617bb6c..677050fe 100644
--- a/packages/zenn-cli/articles/embed-examples.md
+++ b/packages/zenn-cli/articles/embed-examples.md
@@ -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.
diff --git a/packages/zenn-cli/package.json b/packages/zenn-cli/package.json
index d780d920..a48459e2 100644
--- a/packages/zenn-cli/package.json
+++ b/packages/zenn-cli/package.json
@@ -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",
diff --git a/packages/zenn-content-css/package.json b/packages/zenn-content-css/package.json
index 2d71fccd..930d6727 100644
--- a/packages/zenn-content-css/package.json
+++ b/packages/zenn-content-css/package.json
@@ -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": {
diff --git a/packages/zenn-embed-elements/package.json b/packages/zenn-embed-elements/package.json
index b62fc81f..f6ba8b87 100644
--- a/packages/zenn-embed-elements/package.json
+++ b/packages/zenn-embed-elements/package.json
@@ -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": {
diff --git a/packages/zenn-markdown-html/__tests__/link.test.ts b/packages/zenn-markdown-html/__tests__/link.test.ts
index 5483a182..93ca3b4f 100644
--- a/packages/zenn-markdown-html/__tests__/link.test.ts
+++ b/packages/zenn-markdown-html/__tests__/link.test.ts
@@ -215,32 +215,64 @@ describe('Linkifyのテスト', () => {
});
describe('Tweet埋め込みのテスト', () => {
- test('ツイートリンクをに変換する', () => {
- 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('ツイートリンクをに変換する', () => {
+ 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('クエリ文字列を含むツイートリンクを埋め込みに変換する', () => {
+ 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('クエリ文字列を含むツイートリンクを埋め込みに変換する', () => {
- 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('ツイートリンクをに変換する', () => {
+ 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('クエリ文字列を含むツイートリンクを埋め込みに変換する', () => {
+ 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),
+ })
+ );
+ });
});
});
diff --git a/packages/zenn-markdown-html/package.json b/packages/zenn-markdown-html/package.json
index 2f9ac683..ba7d79fd 100644
--- a/packages/zenn-markdown-html/package.json
+++ b/packages/zenn-markdown-html/package.json
@@ -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",
diff --git a/packages/zenn-markdown-html/src/utils/url-matcher.ts b/packages/zenn-markdown-html/src/utils/url-matcher.ts
index 166eddce..ebc12421 100644
--- a/packages/zenn-markdown-html/src/utils/url-matcher.ts
+++ b/packages/zenn-markdown-html/src/utils/url-matcher.ts
@@ -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
);
}
diff --git a/packages/zenn-model/package.json b/packages/zenn-model/package.json
index 686aaba6..79865927 100644
--- a/packages/zenn-model/package.json
+++ b/packages/zenn-model/package.json
@@ -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",