Skip to content

Commit d13cd07

Browse files
DDonochVAjakNatonek
authored andcommitted
fix(bff): replace image source to the new domain
1 parent 3bb3812 commit d13cd07

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

libs/blog-bff/articles/api/src/lib/mappers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import { WPPostDetailsDto, WPPostDto } from './dtos';
1313
import {
1414
crayonCodeRewriter,
15+
modifyImages,
1516
modifyLinks,
1617
removeEmptyParagraphs,
1718
rewriteHTML,
@@ -73,6 +74,7 @@ export const toArticle = (dto?: WPPostDetailsDto): Article => {
7374
crayonCodeRewriter,
7475
removeEmptyParagraphs,
7576
modifyLinks,
77+
modifyImages,
7678
)($);
7779

7880
// add id to anchorTypes elements for anchor links

libs/blog-bff/articles/api/src/lib/utils.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,24 @@ export const modifyLinks: RewriteAdapter = ($) => {
102102
}
103103
});
104104
};
105+
106+
/**
107+
* Replaces image source to the new domain
108+
* @param $
109+
*/
110+
export const modifyImages: RewriteAdapter = ($) => {
111+
$('img').each((_, element) => {
112+
const $element = $(element);
113+
const src = $element.attr('src');
114+
115+
if (src && src.startsWith('https://angular.love/wp-content')) {
116+
$element.attr(
117+
'src',
118+
src.replace(
119+
'https://angular.love/wp-content',
120+
'https://wp.angular.love/wp-content',
121+
),
122+
);
123+
}
124+
});
125+
};

0 commit comments

Comments
 (0)