Skip to content

Commit

Permalink
feat: change some URLs to relative to support IPFS
Browse files Browse the repository at this point in the history
  • Loading branch information
reuixiy committed Sep 15, 2019
1 parent bc7ca8a commit 6b678da
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 101 deletions.
7 changes: 5 additions & 2 deletions assets/scss/_common/fonts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@
@font-face {
font-family: 'glyph-correction';
font-display: swap;
src: url("/fonts/glyph-correction.eot");
src: url("/fonts/glyph-correction.eot") format('embedded-opentype'), url("/fonts/glyph-correction.woff2") format('woff2'), url("/fonts/glyph-correction.woff") format('woff'), url("/fonts/glyph-correction.ttf") format('truetype');
font-weight: inherit;
font-style: inherit;
src: url("../../fonts/glyph-correction.eot");
src: url("../../fonts/glyph-correction.eot?#iefix") format('embedded-opentype'),
url("../../fonts/glyph-correction.woff2") format('woff2'),
url("../../fonts/glyph-correction.woff") format('woff'),
url("../../fonts/glyph-correction.ttf") format('truetype');
}
}
75 changes: 0 additions & 75 deletions exampleSite/assets/scss/_common/fonts.scss

This file was deleted.

16 changes: 0 additions & 16 deletions exampleSite/static/manifest.json

This file was deleted.

12 changes: 8 additions & 4 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@
{{- $safariMaskIcon := "icons/safari-pinned-tab.svg" -}}
{{- $safariMaskColor := .Site.Params.safariMaskColor -}}
{{- $appleTouchIcon := "icons/apple-touch-icon.png" -}}
{{- $msApplicationStartURL := print `/` | absLangURL -}}
{{- partial "relative-url.html" (dict "Deliver" . "filename" "") -}}
{{- $url := .Scratch.Get "url" -}}
{{- $msApplicationStartURL := $url -}}
{{- $msApplicationTileColor := .Site.Params.msApplicationTileColor -}}
{{- $msApplicationTileImage := "icons/mstile-150x150.png" -}}
{{- partial "relative-url.html" (dict "Deliver" . "filename" "icons/mstile-150x150.png") -}}
{{- $url := .Scratch.Get "url" -}}
{{- $msApplicationTileImage := $url -}}
{{- $manifest := "manifest.json" -}}
<link rel="shortcut icon" type="image/ico" href="{{ $favicon | relURL }}" />
<link rel="mask-icon" href="{{ $safariMaskIcon | relURL }}" color="{{ $safariMaskColor }}" />
Expand All @@ -82,7 +86,7 @@
<meta name="application-name" content="{{ .Site.Title }}" />
<meta name="msapplication-starturl" content="{{ $msApplicationStartURL }}" />
<meta name="msapplication-TileColor" content="{{ $msApplicationTileColor }}" />
<meta name="msapplication-TileImage" content="{{ $msApplicationTileImage | relURL }}" />
<meta name="msapplication-TileImage" content="{{ $msApplicationTileImage }}" />
<link rel="manifest" href="{{ $manifest | relURL }}" />

<!-- Atom / RSS -->
Expand Down Expand Up @@ -117,4 +121,4 @@
{{- if and .Site.Params.enableGoogleAnalytics (eq hugo.Environment "production") }}
{{ partial "third-party/google-analytics.html" . }}
{{- end }}
</head>
</head>
20 changes: 20 additions & 0 deletions layouts/partials/relative-url.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- $Deliver := .Deliver -}}
{{- $filename := .filename -}}

{{- $url := $Deliver.RelPermalink -}}
{{- $depth := (len (split (strings.TrimSuffix "/" $url) "/")) -}}

{{- if eq $depth 1 -}}
{{- $url := printf "./%s" $filename | safeHTML -}}
{{- $Deliver.Scratch.Set "url" $url -}}
{{- else -}}
{{- $Deliver.Scratch.Set "level" "" -}}
{{- range $index, $value := (split (strings.TrimSuffix "/" $url) "/") -}}
{{- if lt $index (sub $depth 1) -}}
{{- $level := printf `../%s` ($Deliver.Scratch.Get "level") -}}
{{- $Deliver.Scratch.Set "level" $level -}}
{{- $url := printf `%s%s` $level $filename -}}
{{- $Deliver.Scratch.Set "url" $url -}}
{{- end -}}
{{- end -}}
{{- end -}}
7 changes: 5 additions & 2 deletions layouts/partials/third-party/service-worker.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{{ if and .Site.Params.enableServiceWorker (eq hugo.Environment "production") }}
{{- partial "relative-url.html" (dict "Deliver" . "filename" "sw.js") -}}
{{- $url := .Scratch.Get "url" }}

<script type="module" data-no-instant>
import {Workbox} from 'https://cdn.jsdelivr.net/npm/[email protected]/workbox/workbox-window.prod.mjs';

if ('serviceWorker' in navigator) {
const wb = new Workbox('/sw.js');

{{ printf `const wb = new Workbox('%s');` $url | safeJS }}
wb.addEventListener('activated', (event) => {
if (event.isUpdate) {
appRefresh ({
Expand Down
4 changes: 2 additions & 2 deletions static/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"short_name": "MemE",
"icons": [
{
"src": "/icons/android-chrome-512x512.png",
"src": "./icons/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
Expand All @@ -12,5 +12,5 @@
"background_color": "#fff",
"display": "standalone",
"orientation": "portrait-primary",
"start_url": "/?utm_source=homescreen"
"start_url": "./?utm_source=homescreen"
}

0 comments on commit 6b678da

Please sign in to comment.