Newer
Older

Marlène SIMONDANT
committed
import { ConfigurationService } from '../configuration/configuration.service';
import { Page } from '../pages/schemas/page.schema';
import { Post } from '../posts/schemas/post.schema';
export function rewriteGhostImgUrl(configService: ConfigurationService, itemData: Page | Post): Page | Post {
// Handle image display. Rewrite image URL to fit ghost infra issue.
if (!configService.isLocalConf()) {
if (itemData.feature_image) {
itemData.feature_image = `https://${configService.config.host}/blog/content${
itemData.feature_image.split('/content')[1]
}`;
}
const regex = /(https?:\/\/ghost):(\d*)?/g;
itemData.html = itemData.html.replace(regex, `https://${configService.config.host}/blog`);
}
return itemData;
}