Skip to content

Commit 899af87

Browse files
authored
Merge pull request #20 from ethmarks/component-export
Refactor asset publishing and add header/footer web component export
2 parents e7af7ac + f81a449 commit 899af87

7 files changed

Lines changed: 38 additions & 17 deletions

File tree

layouts/_default/baseof.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<head>
44
{{ partial "metadata.html" . -}}
55
{{- block "default-resources" . -}}
6-
{{ partial "css.html" "_global.scss" }}
6+
{{ partial "css.html" "global.scss" }}
77
{{ partial "js.html" "common.js" }}
88
{{ partial "js.html" "vendor/quicklink.js" }}
99
{{- end -}}
10-
{{- block "resources" . }}{{ end }}
10+
{{- block "resources" . }}{{ end -}}
1111
{{ partial "font-preload.html" . }}
1212
</head>
1313
<body>
@@ -19,4 +19,4 @@
1919
{{ partial "footer.html" . }}
2020
</body>
2121
</html>
22-
{{- partial "publish-all-media.html" . -}}
22+
{{- partial "publish.html" . -}}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{- $header := partial "header.html" . | jsonify -}}
2+
{{- $footer := partial "footer.html" . | jsonify -}}
3+
{{- $js := printf `// Ethmarks Web Components
4+
// Generated automatically from Hugo partials
5+
6+
class EthmarksHeader extends HTMLElement {
7+
connectedCallback() {
8+
this.innerHTML = %s;
9+
}
10+
}
11+
12+
class EthmarksFooter extends HTMLElement {
13+
connectedCallback() {
14+
this.innerHTML = %s;
15+
}
16+
}
17+
18+
// Register the custom elements
19+
customElements.define('ethmarks-header', EthmarksHeader);
20+
customElements.define('ethmarks-footer', EthmarksFooter);
21+
` $header $footer -}}
22+
{{- $resource := resources.FromString "js/ethmarks-components.js" $js -}}
23+
{{- $resource.Publish -}}

layouts/partials/publish-all-media.html

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{ range (resources.Match "media/**") }}
2+
{{ .Publish }}
3+
{{ end }}

layouts/partials/publish-scss.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{{ range resources.Match "css/*.scss" }}
2+
{{ $css := . | toCSS }}
3+
{{ $cssMin := $css | minify }}
4+
{{ $css.Publish }}
5+
{{ $cssMin.Publish }}
6+
{{ end }}

layouts/partials/publish.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{ partial "publish-media.html" . }}
2+
{{ partial "publish-scss.html" . }}
3+
{{ partial "ethmarks-components-js.html" . }}

0 commit comments

Comments
 (0)