diff --git a/packages/guides/src/Twig/AssetsExtension.php b/packages/guides/src/Twig/AssetsExtension.php index f77c32652..274dd2048 100644 --- a/packages/guides/src/Twig/AssetsExtension.php +++ b/packages/guides/src/Twig/AssetsExtension.php @@ -91,8 +91,7 @@ public function asset(array $context, string $path): string { $outputPath = $this->copyAsset($context['env'] ?? null, $path); - // make it relative so it plays nice with the base tag in the HEAD - return trim($outputPath, '/'); + return $this->urlGenerator->generateInternalUrl($context['env'] ?? null, trim($outputPath, '/')); } /** diff --git a/tests/Integration/tests/body-elements/image/expected/hero-illustration.svg b/tests/Integration/tests/body-elements/image-absolute/expected/hero-illustration.svg similarity index 100% rename from tests/Integration/tests/body-elements/image/expected/hero-illustration.svg rename to tests/Integration/tests/body-elements/image-absolute/expected/hero-illustration.svg diff --git a/tests/Integration/tests/body-elements/image/expected/images/hero2-illustration.svg b/tests/Integration/tests/body-elements/image-absolute/expected/images/hero2-illustration.svg similarity index 100% rename from tests/Integration/tests/body-elements/image/expected/images/hero2-illustration.svg rename to tests/Integration/tests/body-elements/image-absolute/expected/images/hero2-illustration.svg diff --git a/tests/Integration/tests/body-elements/image-absolute/expected/index.html b/tests/Integration/tests/body-elements/image-absolute/expected/index.html new file mode 100644 index 000000000..43a823d0a --- /dev/null +++ b/tests/Integration/tests/body-elements/image-absolute/expected/index.html @@ -0,0 +1,35 @@ + +
+

Document Title

+ +

Lorem Ipsum Dolor.

+
+

A local image

+ + Alternative text + +
+ +
+

An image with absolute paths

+ + Alternative text + +
+ +
+

An image with relative paths

+ + Alternative text + +
+ +
+ + diff --git a/tests/Integration/tests/body-elements/image-absolute/expected/subfolder/subpage.html b/tests/Integration/tests/body-elements/image-absolute/expected/subfolder/subpage.html new file mode 100644 index 000000000..e3b183862 --- /dev/null +++ b/tests/Integration/tests/body-elements/image-absolute/expected/subfolder/subpage.html @@ -0,0 +1,35 @@ + + + + Subpage + + + + +
+

Subpage

+ +

Lorem Ipsum Dolor.

+
+

An image with absolute paths

+ + Alternative text + +
+ +
+

An image with relative paths

+ + Alternative text + +
+ +
+ + + + diff --git a/tests/Integration/tests/body-elements/image-absolute/input/guides.xml b/tests/Integration/tests/body-elements/image-absolute/input/guides.xml new file mode 100644 index 000000000..1e9db742d --- /dev/null +++ b/tests/Integration/tests/body-elements/image-absolute/input/guides.xml @@ -0,0 +1,7 @@ + + + diff --git a/tests/Integration/tests/body-elements/image/input/hero-illustration.svg b/tests/Integration/tests/body-elements/image-absolute/input/hero-illustration.svg similarity index 100% rename from tests/Integration/tests/body-elements/image/input/hero-illustration.svg rename to tests/Integration/tests/body-elements/image-absolute/input/hero-illustration.svg diff --git a/tests/Integration/tests/body-elements/image/input/images/hero2-illustration.svg b/tests/Integration/tests/body-elements/image-absolute/input/images/hero2-illustration.svg similarity index 100% rename from tests/Integration/tests/body-elements/image/input/images/hero2-illustration.svg rename to tests/Integration/tests/body-elements/image-absolute/input/images/hero2-illustration.svg diff --git a/tests/Integration/tests/body-elements/image/input/index.rst b/tests/Integration/tests/body-elements/image-absolute/input/index.rst similarity index 100% rename from tests/Integration/tests/body-elements/image/input/index.rst rename to tests/Integration/tests/body-elements/image-absolute/input/index.rst diff --git a/tests/Integration/tests/body-elements/image/input/subfolder/subpage.rst b/tests/Integration/tests/body-elements/image-absolute/input/subfolder/subpage.rst similarity index 100% rename from tests/Integration/tests/body-elements/image/input/subfolder/subpage.rst rename to tests/Integration/tests/body-elements/image-absolute/input/subfolder/subpage.rst diff --git a/tests/Integration/tests/body-elements/image-relative/expected/hero-illustration.svg b/tests/Integration/tests/body-elements/image-relative/expected/hero-illustration.svg new file mode 100644 index 000000000..002f8feff --- /dev/null +++ b/tests/Integration/tests/body-elements/image-relative/expected/hero-illustration.svg @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Integration/tests/body-elements/image-relative/expected/images/hero2-illustration.svg b/tests/Integration/tests/body-elements/image-relative/expected/images/hero2-illustration.svg new file mode 100644 index 000000000..002f8feff --- /dev/null +++ b/tests/Integration/tests/body-elements/image-relative/expected/images/hero2-illustration.svg @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Integration/tests/body-elements/image/expected/index.html b/tests/Integration/tests/body-elements/image-relative/expected/index.html similarity index 100% rename from tests/Integration/tests/body-elements/image/expected/index.html rename to tests/Integration/tests/body-elements/image-relative/expected/index.html diff --git a/tests/Integration/tests/body-elements/image/expected/subfolder/subpage.html b/tests/Integration/tests/body-elements/image-relative/expected/subfolder/subpage.html similarity index 85% rename from tests/Integration/tests/body-elements/image/expected/subfolder/subpage.html rename to tests/Integration/tests/body-elements/image-relative/expected/subfolder/subpage.html index 6aabf492a..e263003c6 100644 --- a/tests/Integration/tests/body-elements/image/expected/subfolder/subpage.html +++ b/tests/Integration/tests/body-elements/image-relative/expected/subfolder/subpage.html @@ -7,7 +7,7 @@

Subpage

An image with absolute paths

Alternative text @@ -16,7 +16,7 @@

An image with absolute paths

An image with relative paths

Alternative text diff --git a/tests/Integration/tests/body-elements/image-relative/input/guides.xml b/tests/Integration/tests/body-elements/image-relative/input/guides.xml new file mode 100644 index 000000000..3f4740587 --- /dev/null +++ b/tests/Integration/tests/body-elements/image-relative/input/guides.xml @@ -0,0 +1,7 @@ + + + diff --git a/tests/Integration/tests/body-elements/image-relative/input/hero-illustration.svg b/tests/Integration/tests/body-elements/image-relative/input/hero-illustration.svg new file mode 100644 index 000000000..002f8feff --- /dev/null +++ b/tests/Integration/tests/body-elements/image-relative/input/hero-illustration.svg @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Integration/tests/body-elements/image-relative/input/images/hero2-illustration.svg b/tests/Integration/tests/body-elements/image-relative/input/images/hero2-illustration.svg new file mode 100644 index 000000000..002f8feff --- /dev/null +++ b/tests/Integration/tests/body-elements/image-relative/input/images/hero2-illustration.svg @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Integration/tests/body-elements/image-relative/input/index.rst b/tests/Integration/tests/body-elements/image-relative/input/index.rst new file mode 100644 index 000000000..4c821a696 --- /dev/null +++ b/tests/Integration/tests/body-elements/image-relative/input/index.rst @@ -0,0 +1,27 @@ +============== +Document Title +============== + +Lorem Ipsum Dolor. + +A local image +============= + +.. image:: hero-illustration.svg + :width: 400 + :alt: Alternative text + +An image with absolute paths +============================ + +.. image:: /images/hero2-illustration.svg + :width: 400 + :alt: Alternative text + + +An image with relative paths +============================ + +.. image:: images/hero2-illustration.svg + :width: 400 + :alt: Alternative text diff --git a/tests/Integration/tests/body-elements/image-relative/input/subfolder/subpage.rst b/tests/Integration/tests/body-elements/image-relative/input/subfolder/subpage.rst new file mode 100644 index 000000000..a059b255f --- /dev/null +++ b/tests/Integration/tests/body-elements/image-relative/input/subfolder/subpage.rst @@ -0,0 +1,20 @@ +======= +Subpage +======= + +Lorem Ipsum Dolor. + +An image with absolute paths +============================ + +.. image:: /images/hero2-illustration.svg + :width: 400 + :alt: Alternative text + + +An image with relative paths +============================ + +.. image:: ../images/hero2-illustration.svg + :width: 400 + :alt: Alternative text