diff --git a/packages/docusaurus-plugin-content-blog/package.json b/packages/docusaurus-plugin-content-blog/package.json index d4a8306f5854..adbed098b5d9 100644 --- a/packages/docusaurus-plugin-content-blog/package.json +++ b/packages/docusaurus-plugin-content-blog/package.json @@ -31,6 +31,7 @@ "fs-extra": "^11.1.1", "lodash": "^4.17.21", "reading-time": "^1.5.0", + "srcset": "^4.0.0", "tslib": "^2.6.0", "unist-util-visit": "^2.0.3", "utility-types": "^3.10.0", diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/blog/blog-with-links.mdx b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/blog/blog-with-links.mdx new file mode 100644 index 000000000000..3a7b6ddf192a --- /dev/null +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/blog/blog-with-links.mdx @@ -0,0 +1,31 @@ +--- +title: test links +date: 2023-07-23 +--- + +import useBaseUrl from '@docusaurus/useBaseUrl'; +import dino from '../static/img/test-image.png'; + +[absolute full url](https://github.com/facebook/docusaurus) + +[absolute pathname](/blog/heading-as-title) + +[relative pathname](heading-as-title) + +[md link](heading-as-title.md) + +[anchor](#title) + +[relative pathname + anchor](heading-as-title#title) + +![](/img/test-image.png) + +![](https://docusaurus.io/assets/images/slash-introducing-411a16dd05086935b8e9ddae38ae9b45.svg) + + + + diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/404.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/404.html index dcf1291ed021..944eb5f6bb98 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/404.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/404.html @@ -3,15 +3,15 @@ -Page Not Found | Docusaurus blog website fixture +Page Not Found | Docusaurus blog website fixture - - + +
Skip to main content

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/2018/12/14/Happy-First-Birthday-Slash/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/2018/12/14/Happy-First-Birthday-Slash/index.html index 0d9c913bf406..3cf7c4156a96 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/2018/12/14/Happy-First-Birthday-Slash/index.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/2018/12/14/Happy-First-Birthday-Slash/index.html @@ -3,17 +3,17 @@ -Happy 1st Birthday Slash! (translated) | Docusaurus blog website fixture +Happy 1st Birthday Slash! (translated) | Docusaurus blog website fixture - - + + -
Skip to main content
+
Skip to main content
\ No newline at end of file diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/archive/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/archive/index.html index 468c1d26823d..7faf4fe57430 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/archive/index.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/archive/index.html @@ -3,17 +3,17 @@ -Archive | Docusaurus blog website fixture +Archive | Docusaurus blog website fixture - - + + -
Skip to main content

Archive

Archive

+
Skip to main content

Archive

Archive

\ No newline at end of file diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/atom.xml b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/atom.xml index 93f32cd2c032..88f35a40be6e 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/atom.xml +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/atom.xml @@ -2,12 +2,29 @@ https://docusaurus.io/blog/ Docusaurus blog website fixture Blog - 2021-03-06T00:00:00.000Z + 2023-07-23T00:00:00.000Z https://github.com/jpmonette/feed Docusaurus blog website fixture Blog https://docusaurus.io/img/docusaurus.ico Copyright + + <![CDATA[test links]]> + https://docusaurus.io/blog/blog-with-links + + 2023-07-23T00:00:00.000Z + + absolute full url

+

absolute pathname

+

relative pathname

+

md link

+

anchor

+

relative pathname + anchor

+

+

+ +]]>
+
<![CDATA[MDX Blog Sample with require calls]]> https://docusaurus.io/blog/mdx-require-blog-post diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/blog-with-links/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/blog-with-links/index.html new file mode 100644 index 000000000000..c31f3d249be9 --- /dev/null +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/blog-with-links/index.html @@ -0,0 +1,28 @@ + + + + + +test links | Docusaurus blog website fixture + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/date-matter/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/date-matter/index.html index 09bdd8971f1f..8d0fad961801 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/date-matter/index.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/date-matter/index.html @@ -3,17 +3,17 @@ -date-matter | Docusaurus blog website fixture +date-matter | Docusaurus blog website fixture - - + + - + \ No newline at end of file diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/feed.json b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/feed.json index d2fa55d912c0..d5377e75c5c4 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/feed.json +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/feed.json @@ -4,6 +4,15 @@ "home_page_url": "https://docusaurus.io/blog/", "description": "Docusaurus blog website fixture Blog", "items": [ + { + "id": "https://docusaurus.io/blog/blog-with-links", + "content_html": "

absolute full url

\n

absolute pathname

\n

relative pathname

\n

md link

\n

anchor

\n

relative pathname + anchor

\n

\n

\"\"

\n\n", + "url": "https://docusaurus.io/blog/blog-with-links", + "title": "test links", + "summary": "absolute full url", + "date_modified": "2023-07-23T00:00:00.000Z", + "tags": [] + }, { "id": "https://docusaurus.io/blog/mdx-require-blog-post", "content_html": "

Test MDX with require calls

\n\n\n\n\n", diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/heading-as-title/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/heading-as-title/index.html index 89462fa86a5c..4b3e39eb132a 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/heading-as-title/index.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/heading-as-title/index.html @@ -3,17 +3,17 @@ -some heading | Docusaurus blog website fixture +some heading | Docusaurus blog website fixture - - + + - + \ No newline at end of file diff --git "a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/hey/my super path/h\303\251ll\303\264/index.html" "b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/hey/my super path/h\303\251ll\303\264/index.html" index 89a12664ca8d..ee0856269f00 100644 --- "a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/hey/my super path/h\303\251ll\303\264/index.html" +++ "b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/hey/my super path/h\303\251ll\303\264/index.html" @@ -3,17 +3,17 @@ -Complex Slug | Docusaurus blog website fixture +Complex Slug | Docusaurus blog website fixture - - + + - + \ No newline at end of file diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/index.html index c27d9d218179..0f32d3f19cc7 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/index.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/index.html @@ -3,23 +3,32 @@ -Blog | Docusaurus blog website fixture +Blog | Docusaurus blog website fixture - - + + -
Skip to main content

· One min read

Test MDX with require calls

+
+

link image

\ No newline at end of file diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/mdx-blog-post/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/mdx-blog-post/index.html index 920c7c06d0ea..5768f9d0e188 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/mdx-blog-post/index.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/mdx-blog-post/index.html @@ -3,18 +3,18 @@ -Full Blog Sample | Docusaurus blog website fixture +Full Blog Sample | Docusaurus blog website fixture - - + + -
Skip to main content

Full Blog Sample

· One min read

HTML Heading 1

+

Full Blog Sample

· One min read

HTML Heading 1

HTML Heading 2

HTML Paragraph

diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/mdx-require-blog-post/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/mdx-require-blog-post/index.html index a0f23c4ef6da..c8c7a170c0d1 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/mdx-require-blog-post/index.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/mdx-require-blog-post/index.html @@ -3,22 +3,22 @@ -MDX Blog Sample with require calls | Docusaurus blog website fixture +MDX Blog Sample with require calls | Docusaurus blog website fixture - - + + -

MDX Blog Sample with require calls

· One min read

Test MDX with require calls

+

MDX Blog Sample with require calls

· One min read

Test MDX with require calls

-
+
\ No newline at end of file diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/page/2/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/page/2/index.html index 8b0b50a48bda..b38f219c042d 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/page/2/index.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/page/2/index.html @@ -3,17 +3,17 @@ -Blog | Docusaurus blog website fixture +Blog | Docusaurus blog website fixture - - + + -

· One min read

date inside front matter

+
\ No newline at end of file diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/page/3/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/page/3/index.html index 326ccbc61ffa..3210fd3fb973 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/page/3/index.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/page/3/index.html @@ -3,17 +3,17 @@ -Blog | Docusaurus blog website fixture +Blog | Docusaurus blog website fixture - - + + -
+

· One min read

date inside front matter

\ No newline at end of file diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/rss.xml b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/rss.xml index 6eb89081aaa1..bc749a48f342 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/rss.xml +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/rss.xml @@ -4,11 +4,28 @@ Docusaurus blog website fixture Blog https://docusaurus.io/blog/ Docusaurus blog website fixture Blog - Sat, 06 Mar 2021 00:00:00 GMT + Sun, 23 Jul 2023 00:00:00 GMT https://validator.w3.org/feed/docs/rss2.html https://github.com/jpmonette/feed en Copyright + + <![CDATA[test links]]> + https://docusaurus.io/blog/blog-with-links + https://docusaurus.io/blog/blog-with-links + Sun, 23 Jul 2023 00:00:00 GMT + + absolute full url

+

absolute pathname

+

relative pathname

+

md link

+

anchor

+

relative pathname + anchor

+

+

+ +]]>
+
<![CDATA[MDX Blog Sample with require calls]]> https://docusaurus.io/blog/mdx-require-blog-post diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/simple/slug/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/simple/slug/index.html index 57781f0c98e5..7f60ef680b19 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/simple/slug/index.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/simple/slug/index.html @@ -3,17 +3,17 @@ -Simple Slug | Docusaurus blog website fixture +Simple Slug | Docusaurus blog website fixture - - + + - + \ No newline at end of file diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/tags/complex/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/tags/complex/index.html index 17f15a052dbc..e8ceaf557408 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/tags/complex/index.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/tags/complex/index.html @@ -3,17 +3,17 @@ -One post tagged with "complex" | Docusaurus blog website fixture +One post tagged with "complex" | Docusaurus blog website fixture - - + + -

One post tagged with "complex"

View All Tags
+

One post tagged with "complex"

View All Tags
\ No newline at end of file diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/tags/date/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/tags/date/index.html index 714f7832a7d0..fa8c63e91db6 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/tags/date/index.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/tags/date/index.html @@ -3,17 +3,17 @@ -2 posts tagged with "date" | Docusaurus blog website fixture +2 posts tagged with "date" | Docusaurus blog website fixture - - + + -

2 posts tagged with "date"

View All Tags

· One min read

date inside front matter

+

2 posts tagged with "date"

View All Tags

· One min read

date inside front matter

\ No newline at end of file diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/tags/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/tags/index.html index 67951eb3f371..a19fde15671d 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/tags/index.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/tags/index.html @@ -3,17 +3,17 @@ -Tags | Docusaurus blog website fixture +Tags | Docusaurus blog website fixture - - + + - + \ No newline at end of file diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/unlisted/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/unlisted/index.html index 20a148326ac2..b036938a8469 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/unlisted/index.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/blog/unlisted/index.html @@ -3,17 +3,17 @@ -unlisted | Docusaurus blog website fixture +unlisted | Docusaurus blog website fixture - - + + -
Unlisted page
This page is unlisted. Search engines will not index it, and only users having a direct link can access it.

unlisted

· One min read

this post is unlisted

+
Unlisted page
This page is unlisted. Search engines will not index it, and only users having a direct link can access it.

unlisted

· One min read

this post is unlisted

\ No newline at end of file diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/index.html index cb26a9a1f218..bd5ce2908562 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/index.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/index.html @@ -3,15 +3,15 @@ -Home | Docusaurus blog website fixture +Home | Docusaurus blog website fixture - - + + diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/search/index.html b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/search/index.html index 1063bf3c8804..60c3c5439119 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/search/index.html +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/search/index.html @@ -3,15 +3,15 @@ -Search the documentation | Docusaurus blog website fixture +Search the documentation | Docusaurus blog website fixture - - + +

Search the documentation

diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/sitemap.xml b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/sitemap.xml index f131680d500e..77b35be7b438 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/sitemap.xml +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__fixtures__/website/build-snap/sitemap.xml @@ -1 +1 @@ -https://docusaurus.io/blog/weekly0.5https://docusaurus.io/blog/2018/12/14/Happy-First-Birthday-Slashweekly0.5https://docusaurus.io/blog/archiveweekly0.5https://docusaurus.io/blog/date-matterweekly0.5https://docusaurus.io/blog/heading-as-titleweekly0.5https://docusaurus.io/blog/hey/my%20super%20path/h%C3%A9ll%C3%B4weekly0.5https://docusaurus.io/blog/mdx-blog-postweekly0.5https://docusaurus.io/blog/mdx-require-blog-postweekly0.5https://docusaurus.io/blog/page/2weekly0.5https://docusaurus.io/blog/page/3weekly0.5https://docusaurus.io/blog/simple/slugweekly0.5https://docusaurus.io/blog/tagsweekly0.5https://docusaurus.io/blog/tags/complexweekly0.5https://docusaurus.io/blog/tags/dateweekly0.5https://docusaurus.io/searchweekly0.5https://docusaurus.io/weekly0.5 \ No newline at end of file +https://docusaurus.io/blog/weekly0.5https://docusaurus.io/blog/2018/12/14/Happy-First-Birthday-Slashweekly0.5https://docusaurus.io/blog/archiveweekly0.5https://docusaurus.io/blog/blog-with-linksweekly0.5https://docusaurus.io/blog/date-matterweekly0.5https://docusaurus.io/blog/heading-as-titleweekly0.5https://docusaurus.io/blog/hey/my%20super%20path/h%C3%A9ll%C3%B4weekly0.5https://docusaurus.io/blog/mdx-blog-postweekly0.5https://docusaurus.io/blog/mdx-require-blog-postweekly0.5https://docusaurus.io/blog/page/2weekly0.5https://docusaurus.io/blog/page/3weekly0.5https://docusaurus.io/blog/simple/slugweekly0.5https://docusaurus.io/blog/tagsweekly0.5https://docusaurus.io/blog/tags/complexweekly0.5https://docusaurus.io/blog/tags/dateweekly0.5https://docusaurus.io/searchweekly0.5https://docusaurus.io/weekly0.5 \ No newline at end of file diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/__snapshots__/feed.test.ts.snap b/packages/docusaurus-plugin-content-blog/src/__tests__/__snapshots__/feed.test.ts.snap index 4c212c2cc9be..8af04cf9ae22 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/__snapshots__/feed.test.ts.snap +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/__snapshots__/feed.test.ts.snap @@ -6,12 +6,29 @@ exports[`atom filters to the first two entries 1`] = ` https://docusaurus.io/myBaseUrl/blog Hello Blog - 2021-03-06T00:00:00.000Z + 2023-07-23T00:00:00.000Z https://github.com/jpmonette/feed Hello Blog https://docusaurus.io/myBaseUrl/image/favicon.ico Copyright + + <![CDATA[test links]]> + https://docusaurus.io/myBaseUrl/blog/blog-with-links + + 2023-07-23T00:00:00.000Z + + absolute full url

+

absolute pathname

+

relative pathname

+

md link

+

anchor

+

relative pathname + anchor

+

+

+ +]]>
+
<![CDATA[MDX Blog Sample with require calls]]> https://docusaurus.io/myBaseUrl/blog/mdx-require-blog-post @@ -21,39 +38,9 @@ exports[`atom filters to the first two entries 1`] = ` Test MDX with require calls

- - -]]>
-
- - <![CDATA[Full Blog Sample]]> - https://docusaurus.io/myBaseUrl/blog/mdx-blog-post - - 2021-03-05T00:00:00.000Z - - HTML Heading 1 -

HTML Heading 2

-

HTML Paragraph

- - -

Import DOM

-

Heading 1

-

Heading 2

-

Heading 3

-

Heading 4

-
Heading 5
-
    -
  • list1
  • -
  • list2
  • -
  • list3
  • -
-
    -
  • list1
  • -
  • list2
  • -
  • list3
  • -
-

Normal Text Italics Text Bold Text

-

link image

]]>
+ + +]]>
", ] @@ -65,12 +52,29 @@ exports[`atom filters to the first two entries using limit 1`] = ` https://docusaurus.io/myBaseUrl/blog Hello Blog - 2021-03-06T00:00:00.000Z + 2023-07-23T00:00:00.000Z https://github.com/jpmonette/feed Hello Blog https://docusaurus.io/myBaseUrl/image/favicon.ico Copyright + + <![CDATA[test links]]> + https://docusaurus.io/myBaseUrl/blog/blog-with-links + + 2023-07-23T00:00:00.000Z + + absolute full url

+

absolute pathname

+

relative pathname

+

md link

+

anchor

+

relative pathname + anchor

+

+

+ +]]>
+
<![CDATA[MDX Blog Sample with require calls]]> https://docusaurus.io/myBaseUrl/blog/mdx-require-blog-post @@ -80,39 +84,9 @@ exports[`atom filters to the first two entries using limit 1`] = ` Test MDX with require calls

- - -]]>
-
- - <![CDATA[Full Blog Sample]]> - https://docusaurus.io/myBaseUrl/blog/mdx-blog-post - - 2021-03-05T00:00:00.000Z - - HTML Heading 1 -

HTML Heading 2

-

HTML Paragraph

- - -

Import DOM

-

Heading 1

-

Heading 2

-

Heading 3

-

Heading 4

-
Heading 5
-
    -
  • list1
  • -
  • list2
  • -
  • list3
  • -
-
    -
  • list1
  • -
  • list2
  • -
  • list3
  • -
-

Normal Text Italics Text Bold Text

-

link image

]]>
+ + +]]>
", ] @@ -124,12 +98,29 @@ exports[`atom has feed item for each post 1`] = ` https://docusaurus.io/myBaseUrl/blog Hello Blog - 2021-03-06T00:00:00.000Z + 2023-07-23T00:00:00.000Z https://github.com/jpmonette/feed Hello Blog https://docusaurus.io/myBaseUrl/image/favicon.ico Copyright + + <![CDATA[test links]]> + https://docusaurus.io/myBaseUrl/blog/blog-with-links + + 2023-07-23T00:00:00.000Z + + absolute full url

+

absolute pathname

+

relative pathname

+

md link

+

anchor

+

relative pathname + anchor

+

+

+ +]]>
+
<![CDATA[MDX Blog Sample with require calls]]> https://docusaurus.io/myBaseUrl/blog/mdx-require-blog-post @@ -139,9 +130,9 @@ exports[`atom has feed item for each post 1`] = ` Test MDX with require calls

- - -]]>
+ + +]]>
<![CDATA[Full Blog Sample]]> @@ -156,10 +147,10 @@ exports[`atom has feed item for each post 1`] = `

Import DOM

Heading 1

-

Heading 2

-

Heading 3

-

Heading 4

-
Heading 5
+

Heading 2

+

Heading 3

+

Heading 4

+
Heading 5
  • list1
  • list2
  • @@ -237,23 +228,23 @@ exports[`json filters to the first two entries 1`] = ` "home_page_url": "https://docusaurus.io/myBaseUrl/blog", "description": "Hello Blog", "items": [ + { + "id": "https://docusaurus.io/myBaseUrl/blog/blog-with-links", + "content_html": "

    absolute full url

    /n

    absolute pathname

    /n

    relative pathname

    /n

    md link

    /n

    anchor

    /n

    relative pathname + anchor

    /n

    /n

    \\"\\"

    /n/n", + "url": "https://docusaurus.io/myBaseUrl/blog/blog-with-links", + "title": "test links", + "summary": "absolute full url", + "date_modified": "2023-07-23T00:00:00.000Z", + "tags": [] + }, { "id": "https://docusaurus.io/myBaseUrl/blog/mdx-require-blog-post", - "content_html": "

    Test MDX with require calls

    /n/n/n/n/n", + "content_html": "

    Test MDX with require calls

    /n/n/n/n/n", "url": "https://docusaurus.io/myBaseUrl/blog/mdx-require-blog-post", "title": "MDX Blog Sample with require calls", "summary": "Test MDX with require calls", "date_modified": "2021-03-06T00:00:00.000Z", "tags": [] - }, - { - "id": "https://docusaurus.io/myBaseUrl/blog/mdx-blog-post", - "content_html": "

    HTML Heading 1

    /n

    HTML Heading 2

    /n

    HTML Paragraph

    /n/n/n

    Import DOM

    /n

    Heading 1

    /n

    Heading 2

    /n

    Heading 3

    /n

    Heading 4

    /n
    Heading 5
    /n
      /n
    • list1
    • /n
    • list2
    • /n
    • list3
    • /n
    /n
      /n
    • list1
    • /n
    • list2
    • /n
    • list3
    • /n
    /n

    Normal Text Italics Text Bold Text

    /n

    link \\"image\\"

    ", - "url": "https://docusaurus.io/myBaseUrl/blog/mdx-blog-post", - "title": "Full Blog Sample", - "summary": "HTML Heading 1", - "date_modified": "2021-03-05T00:00:00.000Z", - "tags": [] } ] }", @@ -268,23 +259,23 @@ exports[`json filters to the first two entries using limit 1`] = ` "home_page_url": "https://docusaurus.io/myBaseUrl/blog", "description": "Hello Blog", "items": [ + { + "id": "https://docusaurus.io/myBaseUrl/blog/blog-with-links", + "content_html": "

    absolute full url

    /n

    absolute pathname

    /n

    relative pathname

    /n

    md link

    /n

    anchor

    /n

    relative pathname + anchor

    /n

    /n

    \\"\\"

    /n/n", + "url": "https://docusaurus.io/myBaseUrl/blog/blog-with-links", + "title": "test links", + "summary": "absolute full url", + "date_modified": "2023-07-23T00:00:00.000Z", + "tags": [] + }, { "id": "https://docusaurus.io/myBaseUrl/blog/mdx-require-blog-post", - "content_html": "

    Test MDX with require calls

    /n/n/n/n/n", + "content_html": "

    Test MDX with require calls

    /n/n/n/n/n", "url": "https://docusaurus.io/myBaseUrl/blog/mdx-require-blog-post", "title": "MDX Blog Sample with require calls", "summary": "Test MDX with require calls", "date_modified": "2021-03-06T00:00:00.000Z", "tags": [] - }, - { - "id": "https://docusaurus.io/myBaseUrl/blog/mdx-blog-post", - "content_html": "

    HTML Heading 1

    /n

    HTML Heading 2

    /n

    HTML Paragraph

    /n/n/n

    Import DOM

    /n

    Heading 1

    /n

    Heading 2

    /n

    Heading 3

    /n

    Heading 4

    /n
    Heading 5
    /n
      /n
    • list1
    • /n
    • list2
    • /n
    • list3
    • /n
    /n
      /n
    • list1
    • /n
    • list2
    • /n
    • list3
    • /n
    /n

    Normal Text Italics Text Bold Text

    /n

    link \\"image\\"

    ", - "url": "https://docusaurus.io/myBaseUrl/blog/mdx-blog-post", - "title": "Full Blog Sample", - "summary": "HTML Heading 1", - "date_modified": "2021-03-05T00:00:00.000Z", - "tags": [] } ] }", @@ -299,9 +290,18 @@ exports[`json has feed item for each post 1`] = ` "home_page_url": "https://docusaurus.io/myBaseUrl/blog", "description": "Hello Blog", "items": [ + { + "id": "https://docusaurus.io/myBaseUrl/blog/blog-with-links", + "content_html": "

    absolute full url

    /n

    absolute pathname

    /n

    relative pathname

    /n

    md link

    /n

    anchor

    /n

    relative pathname + anchor

    /n

    /n

    \\"\\"

    /n/n", + "url": "https://docusaurus.io/myBaseUrl/blog/blog-with-links", + "title": "test links", + "summary": "absolute full url", + "date_modified": "2023-07-23T00:00:00.000Z", + "tags": [] + }, { "id": "https://docusaurus.io/myBaseUrl/blog/mdx-require-blog-post", - "content_html": "

    Test MDX with require calls

    /n/n/n/n/n", + "content_html": "

    Test MDX with require calls

    /n/n/n/n/n", "url": "https://docusaurus.io/myBaseUrl/blog/mdx-require-blog-post", "title": "MDX Blog Sample with require calls", "summary": "Test MDX with require calls", @@ -310,7 +310,7 @@ exports[`json has feed item for each post 1`] = ` }, { "id": "https://docusaurus.io/myBaseUrl/blog/mdx-blog-post", - "content_html": "

    HTML Heading 1

    /n

    HTML Heading 2

    /n

    HTML Paragraph

    /n/n/n

    Import DOM

    /n

    Heading 1

    /n

    Heading 2

    /n

    Heading 3

    /n

    Heading 4

    /n
    Heading 5
    /n
      /n
    • list1
    • /n
    • list2
    • /n
    • list3
    • /n
    /n
      /n
    • list1
    • /n
    • list2
    • /n
    • list3
    • /n
    /n

    Normal Text Italics Text Bold Text

    /n

    link \\"image\\"

    ", + "content_html": "

    HTML Heading 1

    /n

    HTML Heading 2

    /n

    HTML Paragraph

    /n/n/n

    Import DOM

    /n

    Heading 1

    /n

    Heading 2

    /n

    Heading 3

    /n

    Heading 4

    /n
    Heading 5
    /n
      /n
    • list1
    • /n
    • list2
    • /n
    • list3
    • /n
    /n
      /n
    • list1
    • /n
    • list2
    • /n
    • list3
    • /n
    /n

    Normal Text Italics Text Bold Text

    /n

    link \\"image\\"

    ", "url": "https://docusaurus.io/myBaseUrl/blog/mdx-blog-post", "title": "Full Blog Sample", "summary": "HTML Heading 1", @@ -386,11 +386,28 @@ exports[`rss filters to the first two entries 1`] = ` Hello Blog https://docusaurus.io/myBaseUrl/blog Hello Blog - Sat, 06 Mar 2021 00:00:00 GMT + Sun, 23 Jul 2023 00:00:00 GMT https://validator.w3.org/feed/docs/rss2.html https://github.com/jpmonette/feed en Copyright + + <![CDATA[test links]]> + https://docusaurus.io/myBaseUrl/blog/blog-with-links + https://docusaurus.io/myBaseUrl/blog/blog-with-links + Sun, 23 Jul 2023 00:00:00 GMT + + absolute full url

    +

    absolute pathname

    +

    relative pathname

    +

    md link

    +

    anchor

    +

    relative pathname + anchor

    +

    +

    + +]]>
    +
    <![CDATA[MDX Blog Sample with require calls]]> https://docusaurus.io/myBaseUrl/blog/mdx-require-blog-post @@ -400,39 +417,9 @@ exports[`rss filters to the first two entries 1`] = ` Test MDX with require calls

    - - -]]>
    -
    - - <![CDATA[Full Blog Sample]]> - https://docusaurus.io/myBaseUrl/blog/mdx-blog-post - https://docusaurus.io/myBaseUrl/blog/mdx-blog-post - Fri, 05 Mar 2021 00:00:00 GMT - - HTML Heading 1 -

    HTML Heading 2

    -

    HTML Paragraph

    - - -

    Import DOM

    -

    Heading 1

    -

    Heading 2

    -

    Heading 3

    -

    Heading 4

    -
    Heading 5
    -
      -
    • list1
    • -
    • list2
    • -
    • list3
    • -
    -
      -
    • list1
    • -
    • list2
    • -
    • list3
    • -
    -

    Normal Text Italics Text Bold Text

    -

    link image

    ]]>
    + + +]]>
    ", @@ -447,11 +434,28 @@ exports[`rss filters to the first two entries using limit 1`] = ` Hello Blog https://docusaurus.io/myBaseUrl/blog Hello Blog - Sat, 06 Mar 2021 00:00:00 GMT + Sun, 23 Jul 2023 00:00:00 GMT https://validator.w3.org/feed/docs/rss2.html https://github.com/jpmonette/feed en Copyright + + <![CDATA[test links]]> + https://docusaurus.io/myBaseUrl/blog/blog-with-links + https://docusaurus.io/myBaseUrl/blog/blog-with-links + Sun, 23 Jul 2023 00:00:00 GMT + + absolute full url

    +

    absolute pathname

    +

    relative pathname

    +

    md link

    +

    anchor

    +

    relative pathname + anchor

    +

    +

    + +]]>
    +
    <![CDATA[MDX Blog Sample with require calls]]> https://docusaurus.io/myBaseUrl/blog/mdx-require-blog-post @@ -461,39 +465,9 @@ exports[`rss filters to the first two entries using limit 1`] = ` Test MDX with require calls

    - - -]]>
    -
    - - <![CDATA[Full Blog Sample]]> - https://docusaurus.io/myBaseUrl/blog/mdx-blog-post - https://docusaurus.io/myBaseUrl/blog/mdx-blog-post - Fri, 05 Mar 2021 00:00:00 GMT - - HTML Heading 1 -

    HTML Heading 2

    -

    HTML Paragraph

    - - -

    Import DOM

    -

    Heading 1

    -

    Heading 2

    -

    Heading 3

    -

    Heading 4

    -
    Heading 5
    -
      -
    • list1
    • -
    • list2
    • -
    • list3
    • -
    -
      -
    • list1
    • -
    • list2
    • -
    • list3
    • -
    -

    Normal Text Italics Text Bold Text

    -

    link image

    ]]>
    + + +]]>
    ", @@ -508,11 +482,28 @@ exports[`rss has feed item for each post 1`] = ` Hello Blog https://docusaurus.io/myBaseUrl/blog Hello Blog - Sat, 06 Mar 2021 00:00:00 GMT + Sun, 23 Jul 2023 00:00:00 GMT https://validator.w3.org/feed/docs/rss2.html https://github.com/jpmonette/feed en Copyright + + <![CDATA[test links]]> + https://docusaurus.io/myBaseUrl/blog/blog-with-links + https://docusaurus.io/myBaseUrl/blog/blog-with-links + Sun, 23 Jul 2023 00:00:00 GMT + + absolute full url

    +

    absolute pathname

    +

    relative pathname

    +

    md link

    +

    anchor

    +

    relative pathname + anchor

    +

    +

    + +]]>
    +
    <![CDATA[MDX Blog Sample with require calls]]> https://docusaurus.io/myBaseUrl/blog/mdx-require-blog-post @@ -522,9 +513,9 @@ exports[`rss has feed item for each post 1`] = ` Test MDX with require calls

    - - -]]>
    + + +]]>
    <![CDATA[Full Blog Sample]]> @@ -539,10 +530,10 @@ exports[`rss has feed item for each post 1`] = `

    Import DOM

    Heading 1

    -

    Heading 2

    -

    Heading 3

    -

    Heading 4

    -
    Heading 5
    +

    Heading 2

    +

    Heading 3

    +

    Heading 4

    +
    Heading 5
    • list1
    • list2
    • diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/index.test.ts b/packages/docusaurus-plugin-content-blog/src/__tests__/index.test.ts index ee7c68680cb5..8b392611e741 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/index.test.ts +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/index.test.ts @@ -325,29 +325,32 @@ describe('blog plugin', () => { it('builds simple website blog with localized dates', async () => { const siteDir = path.join(__dirname, '__fixtures__', 'website'); const blogPostsFrench = await getBlogPosts(siteDir, {}, getI18n('fr')); - expect(blogPostsFrench).toHaveLength(9); + expect(blogPostsFrench).toHaveLength(10); expect(blogPostsFrench[0]!.metadata.formattedDate).toMatchInlineSnapshot( - `"6 mars 2021"`, + `"23 juillet 2023"`, ); expect(blogPostsFrench[1]!.metadata.formattedDate).toMatchInlineSnapshot( - `"5 mars 2021"`, + `"6 mars 2021"`, ); expect(blogPostsFrench[2]!.metadata.formattedDate).toMatchInlineSnapshot( - `"16 août 2020"`, + `"5 mars 2021"`, ); expect(blogPostsFrench[3]!.metadata.formattedDate).toMatchInlineSnapshot( - `"15 août 2020"`, + `"16 août 2020"`, ); expect(blogPostsFrench[4]!.metadata.formattedDate).toMatchInlineSnapshot( - `"27 février 2020"`, + `"15 août 2020"`, ); expect(blogPostsFrench[5]!.metadata.formattedDate).toMatchInlineSnapshot( `"27 février 2020"`, ); expect(blogPostsFrench[6]!.metadata.formattedDate).toMatchInlineSnapshot( - `"2 janvier 2019"`, + `"27 février 2020"`, ); expect(blogPostsFrench[7]!.metadata.formattedDate).toMatchInlineSnapshot( + `"2 janvier 2019"`, + ); + expect(blogPostsFrench[8]!.metadata.formattedDate).toMatchInlineSnapshot( `"1 janvier 2019"`, ); }); @@ -377,7 +380,7 @@ describe('blog plugin', () => { expect(blogPost.metadata.editUrl).toEqual(hardcodedEditUrl); }); - expect(editUrlFunction).toHaveBeenCalledTimes(9); + expect(editUrlFunction).toHaveBeenCalledTimes(10); expect(editUrlFunction).toHaveBeenCalledWith({ blogDirPath: 'blog', diff --git a/packages/docusaurus-plugin-content-blog/src/feed.ts b/packages/docusaurus-plugin-content-blog/src/feed.ts index 3cfa0f929716..22b7f53cbb80 100644 --- a/packages/docusaurus-plugin-content-blog/src/feed.ts +++ b/packages/docusaurus-plugin-content-blog/src/feed.ts @@ -9,6 +9,7 @@ import path from 'path'; import fs from 'fs-extra'; import logger from '@docusaurus/logger'; import {Feed, type Author as FeedAuthor} from 'feed'; +import * as srcset from 'srcset'; import {normalizeUrl, readOutputHTMLFile} from '@docusaurus/utils'; import {blogPostContainerID} from '@docusaurus/utils-common'; import {load as cheerioLoad} from 'cheerio'; @@ -110,11 +111,41 @@ async function defaultCreateFeedItems({ ); const $ = cheerioLoad(content); - const link = normalizeUrl([siteUrl, permalink]); + const blogPostAbsoluteUrl = normalizeUrl([siteUrl, permalink]); + + const toAbsoluteUrl = (src: string) => + String(new URL(src, blogPostAbsoluteUrl)); + + // Make links and image urls absolute + // See https://github.com/facebook/docusaurus/issues/9136 + $(`div#${blogPostContainerID} a, div#${blogPostContainerID} img`).each( + (_, elm) => { + if (elm.tagName === 'a') { + const {href} = elm.attribs; + if (href) { + elm.attribs.href = toAbsoluteUrl(href); + } + } else if (elm.tagName === 'img') { + const {src, srcset: srcsetAttr} = elm.attribs; + if (src) { + elm.attribs.src = toAbsoluteUrl(src); + } + if (srcsetAttr) { + elm.attribs.srcset = srcset.stringify( + srcset.parse(srcsetAttr).map((props) => ({ + ...props, + url: toAbsoluteUrl(props.url), + })), + ); + } + } + }, + ); + const feedItem: BlogFeedItem = { title: metadataTitle, - id: link, - link, + id: blogPostAbsoluteUrl, + link: blogPostAbsoluteUrl, date, description, // Atom feed demands the "term", while other feeds use "name" diff --git a/project-words.txt b/project-words.txt index 0b79256233b4..e93b272812d8 100644 --- a/project-words.txt +++ b/project-words.txt @@ -152,6 +152,7 @@ jodyheavener joshcena jscodeshift jssdk +juillet kaszubowski katex kato diff --git a/website/_dogfooding/_blog tests/2023-07-19-a.mdx b/website/_dogfooding/_blog tests/2023-07-19-a.mdx new file mode 100644 index 000000000000..16cdfd88d675 --- /dev/null +++ b/website/_dogfooding/_blog tests/2023-07-19-a.mdx @@ -0,0 +1,9 @@ +--- +title: 'Test if href in feed resolved correctly' +--- + +[absolute full url](https://github.com/facebook/docusaurus) + +[absolute url with implicit domain name](/tests/blog/2023/07/19/b) + +[relative url](2023-07-19-b.mdx) diff --git a/website/_dogfooding/_blog tests/2023-07-19-b.mdx b/website/_dogfooding/_blog tests/2023-07-19-b.mdx new file mode 100644 index 000000000000..d6a54897045a --- /dev/null +++ b/website/_dogfooding/_blog tests/2023-07-19-b.mdx @@ -0,0 +1 @@ +# Test Relative Path diff --git a/yarn.lock b/yarn.lock index 7d071f4393f5..12c0f4ccb8c3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15367,6 +15367,11 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== +srcset@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/srcset/-/srcset-4.0.0.tgz#336816b665b14cd013ba545b6fe62357f86e65f4" + integrity sha512-wvLeHgcVHKO8Sc/H/5lkGreJQVeYMm9rlmt8PuR1xE31rIuXhuzznUUqAt8MqLhB3MqJdFzlNAfpcWnxiFUcPw== + ssri@9.0.1, ssri@^9.0.0: version "9.0.1" resolved "https://registry.yarnpkg.com/ssri/-/ssri-9.0.1.tgz#544d4c357a8d7b71a19700074b6883fcb4eae057"