Skip to content

Commit 43d2a77

Browse files
committed
feat: replace images.velog.io inside post content
1 parent 3383103 commit 43d2a77

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/components/post/PostContent.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ function optimizeImagesFromPost(markdown: string) {
2929
/(?:!\[(.*?)\]\(https:\/\/images.velog.io\/(.*?)\))/g,
3030
);
3131
if (!matches) return markdown;
32-
const replacers = matches.map(match => [
32+
const replacers = matches.map((match) => [
3333
match,
34-
match.replace('https://images.velog.io/', 'https://media.vlpt.us'),
34+
match.replace('https://images.velog.io/', 'https://velog.velcdn.com'),
3535
]);
3636
return replacers.reduce((acc, [original, optimized]) => {
3737
return acc.replace(original, optimized);
@@ -41,9 +41,10 @@ function optimizeImagesFromPost(markdown: string) {
4141
const PostContent: React.FC<PostContentProps> = ({ isMarkdown, body }) => {
4242
const [html, setHtml] = useState(isMarkdown ? null : body);
4343
const dispatch = usePostViewerDispatch();
44-
const imageOptimizedPost = useMemo(() => optimizeImagesFromPost(body), [
45-
body,
46-
]);
44+
const imageOptimizedPost = useMemo(
45+
() => optimizeImagesFromPost(body),
46+
[body],
47+
);
4748

4849
useEffect(() => {
4950
if (!html) return;

0 commit comments

Comments
 (0)