Skip to content

Commit 730d224

Browse files
committed
Fix static replacement workflow
This would work even when traling slash is missing from the requested url.
1 parent bda5e98 commit 730d224

File tree

6 files changed

+17
-21
lines changed

6 files changed

+17
-21
lines changed

404.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<meta property="og:type" content="article">
2525
<meta property="og:url" content="https://www.greenpeace.org">
2626
<meta property="og:description" content="Together we can change the world">
27-
<meta property="og:image" content="https://www.greenpeace.org/global/static/img/404.jpg">
27+
<meta property="og:image" content="/static/img/404.jpg">
2828
<meta property="og:image:width" content="1200">
2929
<meta property="og:image:height" content="800">
3030
<meta property="og:site_name" content="Greenpeace">
@@ -33,14 +33,12 @@
3333
<meta name="twitter:site" content="Greenpeace">
3434
<meta name="twitter:title" content="Greenpeace">
3535
<meta name="twitter:description" content="Together we can change the world">
36-
<meta name="twitter:image" content="https://www.greenpeace.org/global/static/img/404.jpg">
36+
<meta name="twitter:image" content="/static/img/404.jpg">
3737

3838
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
3939
<link rel="shortcut icon" type="image/ico" href="favicon.ico">
4040

41-
<link rel='stylesheet' href='static/404.css' type='text/css' media='all'>
42-
43-
<base href="{{static}}">
41+
<link rel='stylesheet' href='/static/404.css' type='text/css' media='all'>
4442
</head>
4543

4644
<body>
@@ -52,12 +50,12 @@
5250
<header>
5351
<nav id="header" class="top-navigation navbar">
5452
<a class="site-logo" href="https://www.greenpeace.org/global/">
55-
<img src="static/img/gp-logo.svg" alt="Greenpeace" class="logo">
53+
<img src="/static/img/gp-logo.svg" alt="Greenpeace" class="logo">
5654
</a>
5755
</nav>
5856

5957
<div class="page-header-background">
60-
<img src="img/404.jpg" srcset="static/img/404.jpg 1200w, static/img/404-992w.jpg 992w, static/img/404-768w.jpg 768w, static/img/404-575w.jpg 575w, static/img/404-320w.jpg 320w" class="page-header-image">
58+
<img src="/static/img/404.jpg" srcset="/static/img/404.jpg 1200w, /static/img/404-992w.jpg 992w, /static/img/404-768w.jpg 768w, /static/img/404-575w.jpg 575w, /static/img/404-320w.jpg 320w" class="page-header-image">
6159
</div>
6260
</header>
6361

@@ -68,6 +66,6 @@ <h2 data-l10n-key="title">We looked everywhere...</h2>
6866
<a class="btn cta-btn" href="https://www.greenpeace.org/global/" data-l10n-key="cta">Go to homepage</a>
6967
</section>
7068

71-
<script src="static/404.js"></script>
69+
<script src="/static/404.js"></script>
7270
</body>
7371
</html>

STATIC.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/
1+
/static/

deploy/env/dev/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ api: >
55
https://www-stage.greenpeace.org/international/
66
wp-content/themes/planet4-master-theme/templates/countries.json
77
static: >
8-
https://www-dev.greenpeace.org/global/
8+
https://www-dev.greenpeace.org/global/static/
99
nginxingress:
1010
hosts:
1111
- name: www-dev.greenpeace.org

deploy/env/prod/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ api: >
55
https://www.greenpeace.org/international/wp-content/
66
themes/planet4-master-theme/templates/countries.json
77
static: >
8-
https://www.greenpeace.org/global/
8+
https://www.greenpeace.org/global/static/
99
nginxingress:
1010
hosts:
1111
- name: www.greenpeace.org

gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ function replace_static() {
6060
const static = fs.readFileSync('STATIC.txt', 'utf8').trim();
6161

6262
return gulp.src('./index.html')
63-
.pipe(replace('{{static}}', static))
63+
.pipe(replace('/static/', static))
6464
.pipe(gulp.dest(dest));
6565
}
6666

6767
function replace_static_404() {
6868
const static = fs.readFileSync('STATIC.txt', 'utf8').trim();
6969

7070
return gulp.src('./404.html')
71-
.pipe(replace('{{static}}', static))
71+
.pipe(replace('/static/', static))
7272
.pipe(gulp.dest(dest));
7373
}
7474

index.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<meta property="og:type" content="article">
2525
<meta property="og:url" content="https://www.greenpeace.org">
2626
<meta property="og:description" content="Together we can change the world">
27-
<meta property="og:image" content="https://www.greenpeace.org/global/static/img/image.jpg">
27+
<meta property="og:image" content="/static/img/image.jpg">
2828
<meta property="og:image:width" content="1200">
2929
<meta property="og:image:height" content="800">
3030
<meta property="og:site_name" content="Greenpeace">
@@ -33,14 +33,12 @@
3333
<meta name="twitter:site" content="Greenpeace">
3434
<meta name="twitter:title" content="Greenpeace">
3535
<meta name="twitter:description" content="Together we can change the world">
36-
<meta name="twitter:image" content="https://www.greenpeace.org/global/static/img/image.jpg">
36+
<meta name="twitter:image" content="/static/img/image.jpg">
3737

3838
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
3939
<link rel="shortcut icon" type="image/ico" href="favicon.ico">
4040

41-
<link rel='stylesheet' href='static/style.css' type='text/css' media='all'>
42-
43-
<base href="{{static}}">
41+
<link rel='stylesheet' href='/static/style.css' type='text/css' media='all'>
4442
</head>
4543

4644
<body data-code="__P4_GEOIP_COUNTRY_CODE__">
@@ -51,11 +49,11 @@
5149

5250
<header>
5351
<div class="page-header-background">
54-
<img alt="Greenpeace" src="static/img/image.jpg" srcset="static/img/image.jpg 1200w, static/img/image-992w.jpg 992w, static/img/image-768w.jpg 768w, static/img/image-575w.jpg 575w, static/img/image-320w.jpg 320w" class="page-header-image">
52+
<img alt="Greenpeace" src="/static/img/image.jpg" srcset="/static/img/image.jpg 1200w, /static/img/image-992w.jpg 992w, /static/img/image-768w.jpg 768w, /static/img/image-575w.jpg 575w, /static/img/image-320w.jpg 320w" class="page-header-image">
5553
</div>
5654

5755
<div>
58-
<img src="static/img/gp-logo.svg" alt="Greenpeace" class="logo">
56+
<img src="/static/img/gp-logo.svg" alt="Greenpeace" class="logo">
5957
</div>
6058

6159
<h1 class="heading">
@@ -77,6 +75,6 @@ <h1 class="heading">
7775

7876
<div id="country-list-wrapper" class="country-list-wrapper"></div>
7977

80-
<script src="static/main.js"></script>
78+
<script src="/static/main.js"></script>
8179
</body>
8280
</html>

0 commit comments

Comments
 (0)