Skip to content

Commit

Permalink
fix: optimize user experience
Browse files Browse the repository at this point in the history
  • Loading branch information
reuixiy committed Mar 4, 2020
1 parent 6a08765 commit e9f6d90
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 0 additions & 6 deletions assets/js/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
// Wrap `<table>` to make it responsive
// Reference: https://github.com/stone-zeng/stone-zeng.github.io/blob/master/js/script.js

document.querySelectorAll('table').forEach((e) => {
e.outerHTML = `<div class="table-container">${e.outerHTML}</div>`;
});
6 changes: 6 additions & 0 deletions assets/js/wrap-table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Wrap `<table>` to make it responsive
// Reference: https://github.com/stone-zeng/stone-zeng.github.io/blob/master/js/script.js

document.querySelectorAll('table').forEach((e) => {
e.outerHTML = `<div class="table-container">${e.outerHTML}</div>`;
});
3 changes: 3 additions & 0 deletions layouts/partials/script.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{{- $backToTop := resources.Get "js/back-to-top.js" | resources.ExecuteAsTemplate "js/back-to-top-rendered.js" . -}}
{{- $darkMode := resources.Get "js/dark-mode.js" | resources.ExecuteAsTemplate "js/dark-mode-rendered.js" . -}}
{{- $lang := resources.Get "js/multilingual.js" | resources.ExecuteAsTemplate "js/multilingual-rendered.js" . -}}
{{- $wrapTable := resources.Get "js/wrap-table.js" | resources.ExecuteAsTemplate "js/wrap-table-rendered.js" . -}}
{{- $comments := resources.Get "js/comments.js" | resources.ExecuteAsTemplate "js/comments-rendered.js" . -}}
{{- $custom := resources.Get "js/custom.js" | resources.ExecuteAsTemplate "js/custom-rendered.js" . -}}

Expand All @@ -29,6 +30,8 @@
{{- .Scratch.Add "script" (slice $lang) -}}
{{- end -}}

{{- .Scratch.Add "script" (slice $wrapTable) -}}

{{- if and .Site.Params.enableComments (eq hugo.Environment "production") -}}
{{- .Scratch.Add "script" (slice $comments) -}}
{{- end -}}
Expand Down

0 comments on commit e9f6d90

Please sign in to comment.