Skip to content

Commit

Permalink
Use rev-web-assets to support better caching
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilafian committed Apr 28, 2024
1 parent 3f3588b commit 633bff8
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Downloaded and generated files
/node_modules/
/build/
/docs/
/package-lock.json

Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"runScriptsConfig": {
"clean": [
"rimraf docs"
"rimraf build docs"
],
"generated": [
"replacer src/website/article --ext=.html --content={{lt}}li{{gt}}{{lt}}a{{space}}href{{equals}}{[webRoot]}/article/{{file.folder}}{{gt}}{{articleTitle}}{{lt}}/a{{gt}}{{lt}}/li{{gt}} src/templates/generated --find=[webRoot] --replacement={webRoot} --concat=articles.html"
Expand All @@ -41,12 +41,13 @@
"jshint src"
],
"build": [
"copy-file src/cname.txt docs/CNAME",
"copy-folder src/website/graphics docs/graphics",
"copy-folder src/website/article docs/article --ext=.png,.jpg",
"copy-file src/website/app.js docs/app.js",
"lessc src/website/style.less docs/style.css",
"replacer src/website --ext=.html docs"
"copy-file src/cname.txt build/CNAME",
"copy-folder src/website/graphics build/graphics",
"copy-folder src/website/article build/article --ext=.png,.jpg",
"copy-file src/website/app.js build/app.js",
"lessc src/website/style.less build/style.css",
"replacer src/website --ext=.html build",
"rev-web-assets build docs --meta-content-base=https://think-metric.org"
]
},
"scripts": {
Expand All @@ -64,6 +65,7 @@
"jshint": "~2.13",
"less": "~4.2",
"replacer-util": "~1.3",
"rev-web-assets": "~1.3",
"rimraf": "~5.0",
"run-scripts-util": "~1.2",
"w3c-html-validator": "~1.8",
Expand Down
12 changes: 5 additions & 7 deletions src/templates/doc-begin.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{% assign imageUrl = 'https://think-metric.org/graphics/social-media/think-metric-logo-card.png' %}
{% if heroFile %}
{% assign imageUrl = 'https://think-metric.org/article/' | append: file.folder | append: '/' | append: heroFile %}
{% endif %}
{% assign heroCaption = heroCaption | default: 'Logo' %}
{% assign defaultImageUrl = webRoot | append: '/graphics/social-media/think-metric-logo-card.png' %}
{% assign imageUrl = heroImage | default: defaultImageUrl %}
{% assign imageCaption = heroCaption | default: 'Logo' %}
<!doctype html>
<!-- - - - - - - - -->
<!-- Think Metric -->
Expand All @@ -19,12 +17,12 @@
<meta name=twitter:title content="{{articleTitle}}">
<meta name=twitter:description content="Think Metric 🇺🇸 Americans for Metrication: Practical ways to go metric">
<meta name=twitter:image content="{{imageUrl}}">
<meta name=twitter:image:alt content="{{heroCaption}}">
<meta name=twitter:image:alt content="{{imageCaption}}">
<meta property=og:title content="{{articleTitle}}">
<meta property=og:description content="Think Metric 🇺🇸 Americans for Metrication: Practical ways to go metric">
<meta property=og:type content="website">
<meta property=og:image content="{{imageUrl}}">
<meta property=og:image:alt content="{{heroCaption}}">
<meta property=og:image:alt content="{{imageCaption}}">
<title>{{articleTitle}} 🇺🇸 Think Metric</title>
<link rel=icon href={{webRoot}}/graphics/bookmark.png>
<link rel=apple-touch-icon href={{webRoot}}/graphics/think-metric-logo.png>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% assign articleTitle = 'Go Fast With High Contrast Metric Only Tape Measures' %}
{% assign heroFile = 'high-contrast.jpg' %}
{% assign heroImage = 'high-contrast.jpg' %}
{% assign heroCaption = 'Big bold repeating digits from 1 to 9' %}
{% render 'src/templates/doc-begin.html', articleTitle: articleTitle, heroFile: heroFile, heroCaption: heroCaption %}
{% render 'src/templates/doc-begin.html', articleTitle: articleTitle, heroImage: heroImage, heroCaption: heroCaption %}

<main>

Expand All @@ -17,10 +17,10 @@ <h2>{{articleTitle}}</h2>

<section>
<figure>
<img src={{heroFile}} data-author=dem-pilafian data-license=cc0 alt=-tape-measure>
<img src={{heroImage}} data-author=dem-pilafian data-license=cc0 alt=-tape-measure>
<figcaption>{{heroCaption}}</figcaption>
</figure>
<p>
<p>
A newer high contrast design uses big bold digits that repeat from 1 to 9 on a white background.&nbsp;
Red boxes spaced every 10 centimeters show the total number of centimeters.&nbsp;
This vivid scale is super easy to read and makes measuring blazing fast.&nbsp;
Expand Down
6 changes: 3 additions & 3 deletions src/website/article/metric-poetry/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% assign articleTitle = 'Metric Poetry' %}
{% assign heroFile = 'si-wheel.png' %}
{% assign heroImage = 'si-wheel.png' %}
{% assign heroCaption = 'Common Words for SI' %}
{% render 'src/templates/doc-begin.html', articleTitle: articleTitle, heroFile: heroFile, heroCaption: heroCaption %}
{% render 'src/templates/doc-begin.html', articleTitle: articleTitle, heroImage: heroImage, heroCaption: heroCaption %}

<main>

Expand Down Expand Up @@ -29,7 +29,7 @@ <h3>Common words for SI</h3>

<section>
<figure class=small-picture>
<img src=si-wheel.png alt=si>
<img src={{heroImage}} alt=si>
</figure>
<h2>Table of Metric Common Words</h2>
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% assign articleTitle = 'Metrication is the Path of Least Resistance' %}
{% assign heroFile = 'martian-ice-age.jpg' %}
{% assign heroImage = 'martian-ice-age.jpg' %}
{% assign heroCaption = 'Signs of a Martian Ice Age (NASA ID: PIA20029)' %}
{% render 'src/templates/doc-begin.html', articleTitle: articleTitle, heroFile: heroFile, heroCaption: heroCaption %}
{% render 'src/templates/doc-begin.html', articleTitle: articleTitle, heroImage: heroImage, heroCaption: heroCaption %}

<main>

Expand All @@ -22,7 +22,7 @@ <h2>{{articleTitle}}</h2>

<section>
<figure>
<img src={{heroFile}} data-author=nasa data-license=public-domain alt=2d-radar>
<img src={{heroImage}} data-author=nasa data-license=public-domain alt=2d-radar>
<figcaption>{{heroCaption}}</figcaption>
</figure>
<p>
Expand Down
6 changes: 3 additions & 3 deletions src/website/do-not-learn-metric/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% assign articleTitle = 'Do Not Learn Metric' %}
{% assign heroFile = '../../graphics/tape-measure-by-dem-pilafian-cc0.jpg' %}
{% assign heroImage = '../graphics/tape-measure-by-dem-pilafian-cc0.jpg' %}
{% assign heroCaption = 'Easy Peasy' %}
{% render 'src/templates/doc-begin.html', articleTitle: articleTitle, heroFile: heroFile, heroCaption: heroCaption %}
{% render 'src/templates/doc-begin.html', articleTitle: articleTitle, heroImage: heroImage, heroCaption: heroCaption %}

<main>

Expand All @@ -24,7 +24,7 @@ <h2>{{articleTitle}}</h2>
After switching over to Celsius for a week you'll likely have a good intuitive sense of Celsius.&nbsp;
</p>
<figure>
<img src=../graphics/tape-measure-by-dem-pilafian-cc0.jpg data-author=dem-pilafian data-license=cc0 alt=measure>
<img src={{heroImage}} data-author=dem-pilafian data-license=cc0 alt=measure>
<figcaption>{{heroCaption}}</figcaption>
</figure>
<p>
Expand Down
6 changes: 3 additions & 3 deletions src/website/products/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% assign articleTitle = 'Timesaving Metric Products' %}
{% assign heroFile = '../../graphics/warehouse-by-axisadman-at-wikimedia-cc-by-sa.jpg' %}
{% assign heroImage = '../graphics/warehouse-by-axisadman-at-wikimedia-cc-by-sa.jpg' %}
{% assign heroCaption = 'Lots of Products' %}
{% render 'src/templates/doc-begin.html', articleTitle: articleTitle, heroFile: heroFile, heroCaption: heroCaption %}
{% render 'src/templates/doc-begin.html', articleTitle: articleTitle, heroImage: heroImage, heroCaption: heroCaption %}

<main>

Expand All @@ -16,7 +16,7 @@ <h3>Go metric to boost your efficiency</h3>
sell some metric only products.
</p>
<figure>
<img src=../graphics/warehouse-by-axisadman-at-wikimedia-cc-by-sa.jpg data-author=axisadman data-license=cc-by-sa alt=warehouse>
<img src={{heroImage}} data-author=axisadman data-license=cc-by-sa alt=warehouse>
</figure>
</section>

Expand Down

0 comments on commit 633bff8

Please sign in to comment.