Skip to content

Commit d2c16d3

Browse files
authored
Merge pull request velopert#122 from velopert/etc/use-cloudflare
Use cloudflare
2 parents a08220d + 987e67b commit d2c16d3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/components/post/PostContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function optimizeImagesFromPost(markdown: string) {
3131
if (!matches) return markdown;
3232
const replacers = matches.map(match => [
3333
match,
34-
match.replace('https://images./', 'https://img.').replace(/\)$/, '?w=1024)'),
34+
match.replace('https://images.velog.io', 'https://media.vlpt.us'),
3535
]);
3636
return replacers.reduce((acc, [original, optimized]) => {
3737
return acc.replace(original, optimized);

src/lib/optimizeImage.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
export default function optimizeImage(url: string, width: number) {
1+
export default function optimizeImage(url: string, width?: number) {
22
if (!url.includes('https://images.velog.io')) return url;
3-
return url.replace('://images', '://img').concat(`?w=${width}`);
3+
4+
let replaced = url.replace('://images.velog.io', '://media.vlpt.us');
5+
if (!width) {
6+
return replaced;
7+
}
8+
return replaced.concat(`?w=${width}`);
49
}

0 commit comments

Comments
 (0)