Permalink
Browse files

Use Hugo pipes to process assets (#134)

- refactor: use inline svgs
- refactor: hugo pipes sass
- refactor: hugo pipes js
- refactor: remove no need files (use hugo pipes)
- fix: commit resources/
- refactor: better inline svgs, embed external *.svg files

close: #103
  • Loading branch information...
xianmin committed Oct 30, 2018
1 parent 335d0c2 commit 8a1f701826bb1d8e89286f8f29907fa929c8a121
Showing with 753 additions and 1,085 deletions.
  1. +228 −0 assets/js/main.js
  2. 0 {src/css → assets/sass}/_base.scss
  3. 0 {src/css → assets/sass}/_common/_animation.scss
  4. 0 {src/css → assets/sass}/_common/_normalize.scss
  5. 0 {src/css → assets/sass}/_common/_utils.scss
  6. 0 {src/css → assets/sass}/_custom/_custom.scss
  7. 0 {src/css → assets/sass}/_iconfont.scss
  8. 0 {src/css → assets/sass}/_partial/_404.scss
  9. 0 {src/css → assets/sass}/_partial/_archive.scss
  10. +3 −2 {src/css → assets/sass}/_partial/_back-to-top.scss
  11. 0 {src/css → assets/sass}/_partial/_categories.scss
  12. 0 {src/css → assets/sass}/_partial/_footer.scss
  13. 0 {src/css → assets/sass}/_partial/_footer/_copyright.scss
  14. +6 −2 {src/css → assets/sass}/_partial/_footer/_social.scss
  15. 0 {src/css → assets/sass}/_partial/_header.scss
  16. 0 {src/css → assets/sass}/_partial/_header/_logo.scss
  17. 0 {src/css → assets/sass}/_partial/_header/_menu.scss
  18. 0 {src/css → assets/sass}/_partial/_mobile.scss
  19. 0 {src/css → assets/sass}/_partial/_pagination.scss
  20. 0 {src/css → assets/sass}/_partial/_post.scss
  21. 0 {src/css → assets/sass}/_partial/_post/_chroma_highlight.scss
  22. 0 {src/css → assets/sass}/_partial/_post/_code.scss
  23. 0 {src/css → assets/sass}/_partial/_post/_content.scss
  24. 0 {src/css → assets/sass}/_partial/_post/_copyright.scss
  25. 0 {src/css → assets/sass}/_partial/_post/_disqus.scss
  26. 0 {src/css → assets/sass}/_partial/_post/_footer.scss
  27. 0 {src/css → assets/sass}/_partial/_post/_footnote.scss
  28. 0 {src/css → assets/sass}/_partial/_post/_header.scss
  29. 0 {src/css → assets/sass}/_partial/_post/_reward.scss
  30. 0 {src/css → assets/sass}/_partial/_post/_shortcode_notice.scss
  31. 0 {src/css → assets/sass}/_partial/_post/_toc.scss
  32. 0 {src/css → assets/sass}/_partial/_post/_utteranc.scss
  33. 0 {src/css → assets/sass}/_partial/_slideout.scss
  34. 0 {src/css → assets/sass}/_partial/_tags.scss
  35. +11 −11 {src/css → assets/sass}/_variables.scss
  36. +1 −1 src/css/style.scss → assets/sass/jane.scss
  37. +4 −1 layouts/_default/baseof.html
  38. +5 −16 layouts/partials/footer.html
  39. +2 −1 layouts/partials/head.html
  40. +8 −2 layouts/partials/header.html
  41. +6 −2 layouts/partials/pagination.html
  42. +4 −1 layouts/partials/scripts.html
  43. +8 −2 layouts/partials/slideout.html
  44. +24 −0 layouts/partials/social_links.html
  45. +8 −0 layouts/partials/svg/bilibili.svg
  46. +11 −0 layouts/partials/svg/coding.svg
  47. +9 −0 layouts/partials/svg/douban.svg
  48. +6 −0 layouts/partials/svg/email.svg
  49. +9 −0 layouts/partials/svg/facebook.svg
  50. +9 −0 layouts/partials/svg/github.svg
  51. +9 −0 layouts/partials/svg/gitlab.svg
  52. +4 −0 layouts/partials/svg/globe.svg
  53. +6 −0 layouts/partials/svg/goodreads.svg
  54. +9 −0 layouts/partials/svg/google.svg
  55. +9 −0 layouts/partials/svg/heart.svg
  56. +9 −0 layouts/partials/svg/instagram.svg
  57. +9 −0 layouts/partials/svg/left.svg
  58. +9 −0 layouts/partials/svg/linkedin.svg
  59. +11 −0 layouts/partials/svg/new_window.svg
  60. +9 −0 layouts/partials/svg/pocket.svg
  61. +9 −0 layouts/partials/svg/right.svg
  62. +9 −0 layouts/partials/svg/rss.svg
  63. +6 −0 layouts/partials/svg/stack-overflow.svg
  64. +9 −0 layouts/partials/svg/tumblr.svg
  65. +6 −0 layouts/partials/svg/twitter.svg
  66. +9 −0 layouts/partials/svg/up.svg
  67. +9 −0 layouts/partials/svg/weibo.svg
  68. +11 −0 layouts/partials/svg/zhihu.svg
  69. +8 −2 layouts/post/single.html
  70. +228 −0 resources/_gen/assets/js/js/main.js_dd8e2cf639efdbde29d18adce2335348.content
  71. +1 −0 resources/_gen/assets/js/js/main.js_dd8e2cf639efdbde29d18adce2335348.json
  72. +1 −0 resources/_gen/assets/scss/sass/jane.scss_48b060fe05b0a273d182ef83c0605941.content
  73. +1 −0 resources/_gen/assets/scss/sass/jane.scss_48b060fe05b0a273d182ef83c0605941.json
  74. +0 −10 src/.babelrc
  75. BIN src/fonts/chancery/apple-chancery-webfont.eot
  76. +0 −228 src/fonts/chancery/apple-chancery-webfont.svg
  77. BIN src/fonts/chancery/apple-chancery-webfont.ttf
  78. BIN src/fonts/chancery/apple-chancery-webfont.woff
  79. BIN src/fonts/chancery/apple-chancery-webfont.woff2
  80. +0 −96 src/fonts/svg/bilibili.svg
  81. +0 −70 src/fonts/svg/coding.svg
  82. +0 −1 src/fonts/svg/douban.svg
  83. +0 −1 src/fonts/svg/email.svg
  84. +0 −1 src/fonts/svg/facebook.svg
  85. +0 −1 src/fonts/svg/github.svg
  86. +0 −1 src/fonts/svg/gitlab.svg
  87. +0 −31 src/fonts/svg/globe.svg
  88. +0 −56 src/fonts/svg/goodreads.svg
  89. +0 −1 src/fonts/svg/google.svg
  90. +0 −1 src/fonts/svg/heart.svg
  91. +0 −1 src/fonts/svg/instagram.svg
  92. +0 −1 src/fonts/svg/left.svg
  93. +0 −1 src/fonts/svg/linkedin.svg
  94. +0 −1 src/fonts/svg/new-window.svg
  95. +0 −1 src/fonts/svg/pocket.svg
  96. +0 −1 src/fonts/svg/right.svg
  97. +0 −1 src/fonts/svg/rss.svg
  98. +0 −1 src/fonts/svg/stack-overflow.svg
  99. +0 −1 src/fonts/svg/tumblr.svg
  100. +0 −1 src/fonts/svg/twitter.svg
  101. +0 −1 src/fonts/svg/up.svg
  102. +0 −1 src/fonts/svg/weibo.svg
  103. +0 −1 src/fonts/svg/zhihu.svg
  104. +0 −19 src/js/backToTop.js
  105. +0 −32 src/js/footnoteTooltip.js
  106. +0 −36 src/js/headerAnchor.js
  107. +0 −34 src/js/highlight.js
  108. +0 −19 src/js/main.js
  109. +0 −49 src/js/mobileNavbar.js
  110. +0 −29 src/js/toc.js
  111. +0 −7 src/postcss.config.js
  112. BIN static/dist/fonts/chancery/apple-chancery-webfont.eot
  113. +0 −228 static/dist/fonts/chancery/apple-chancery-webfont.svg
  114. BIN static/dist/fonts/chancery/apple-chancery-webfont.ttf
  115. BIN static/dist/fonts/chancery/apple-chancery-webfont.woff
  116. BIN static/dist/fonts/chancery/apple-chancery-webfont.woff2
  117. +0 −4 static/dist/jane.min.css
  118. +0 −1 static/dist/jane.min.css.map
  119. +0 −2 static/dist/jane.min.js
  120. +0 −1 static/dist/jane.min.js.map
  121. +0 −70 webpack.config.js
View
@@ -0,0 +1,228 @@
// import backToTop from './backToTop';
// import mobileNavbar from './mobileNavbar';
// import toc from './toc';
// import headerAnchor from './headerAnchor';
// import fnTooltip from './footnoteTooltip';
// import highlight from './highlight';
/**
* back to top
*/
var backToTop = function() {
const $backToTop = $('#back-to-top');
$(window)
.scroll(function() {
if ($(window)
.scrollTop() > 100) {
$backToTop.fadeIn(1000);
} else {
$backToTop.fadeOut(1000);
}
})
$backToTop.click(function() {
$('body,html')
.animate({
scrollTop: 0
});
})
}
/**
* mobile Navbar
*/
var mobileNavbar = function() {
const $mobileNav = $('#mobile-navbar');
const $mobileNavIcon = $('.mobile-navbar-icon');
const slideout = new Slideout({
'panel': document.getElementById('mobile-panel'),
'menu': document.getElementById('mobile-menu'),
'padding': 180,
'tolerance': 70
})
slideout.disableTouch()
$mobileNavIcon.click(function () {
slideout.toggle()
})
slideout.on('beforeopen', function () {
$mobileNav.addClass('fixed-open')
$mobileNavIcon.addClass('icon-click').removeClass('icon-out')
})
slideout.on('beforeclose', function () {
$mobileNav.removeClass('fixed-open')
$mobileNavIcon.addClass('icon-out').removeClass('icon-click')
})
$('#mobile-panel').on('touchend', function () {
slideout.isOpen() && $mobileNavIcon.click()
})
$('.mobile-submenu-open').on('click', function () {
const $mobileSubmenuList = $('.mobile-submenu-list')
const $mobileMenuParent = $('.mobile-menu-parent')
if ($(this).parent().next().css('display') == "none") {
$mobileSubmenuList.slideUp(300)
$(this).parent().next('ul').slideDown(300)
$(this).parent().addClass('mobile-submenu-show')
$(this).parent().parent().siblings().children().removeClass('mobile-submenu-show')
} else {
$(this).parent().next('ul').slideUp(300)
$mobileMenuParent.removeClass('mobile-submenu-show')
}
});
}
/**
* Table of Content fix
*/
function initToc() {
const $toc = $('#post-toc');
if ($toc.length && $(window)
.width() >= 1080) {
$(window)
.scroll(function() {
if ($(window)
.scrollTop() > 100) {
$toc.fadeIn(1000);
} else {
$toc.fadeOut(100);
}
});
}
}
var toc = function() {
const tocContainer = document.getElementById('post-toc');
if (tocContainer !== null) {
const toc = document.getElementById('TableOfContents');
if (toc === null) {
// if global config 'toc = true', but there are no headings
tocContainer.parentNode.removeChild(tocContainer);
} else {
initToc();
}
}
}
/**
* Anchor for post content header
**/
var anchorForId = function (id) {
var anchor = document.createElement("a");
anchor.className = "header-link";
anchor.href = "#" + id;
anchor.innerHTML = '<svg viewBox="0 0 16 10" version="1.1" width="24" height="24"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg>';
return anchor;
};
var linkifyAnchors = function (level, containingElement) {
var headers = containingElement.getElementsByTagName("h" + level);
for (var h = 0; h < headers.length; h++) {
var header = headers[h];
header.className = "post-content-header";
if (typeof header.id !== "undefined" && header.id !== "") {
// insert header-link before the header
header.appendChild(anchorForId(header.id));
}
}
};
var headerAnchor = function() {
var contentBlock = document.getElementsByClassName("post-content")[0];
if (!contentBlock) {
return;
}
for (var level = 1; level <= 4; level++) {
linkifyAnchors(level, contentBlock);
}
};
/**
* footnote tooltip
*/
var fnTooltip = function () {
$(".footnote-ref").each(function () {
var id = $(this).children("a").attr("href").substr(1),
footnote = $(document.getElementById(id)).clone(),
outer_wrapper = $("<span>", { "class": "fn-content" }),
inner_wrapper = $("<span>", { "class": "fn-text" });
footnote.find(".footnote-return").remove();
$(this).append(outer_wrapper.append(inner_wrapper.html(footnote.html())));
});
// fix tooltip position & width
var position = function () {
var content = $(".fn-content").removeAttr("style");
if ($(window).width() < 640)
content.css("width", $(window).width() / 2);
else
content.css("width", 340); // default value
content.each(function () {
var width = $(this).children(".fn-text").outerWidth();
$(this).css({
"width": width,
"margin-left": width / -2
});
});
}
position();
$(window).resize(position());
}
/**
* highlight
*/
var highlight = function () {
document.querySelectorAll('.chroma>table')
.forEach((element) => {
const sub = element.querySelector('code[data-lang]');
if (sub !== null) {
element.setAttribute('data-lang', mapLang(sub.getAttribute('data-lang')));
}
});
}
function mapLang(name) {
return {
coffeescript: 'CoffeeScript',
cpp: 'C++',
cs: 'C#',
css: 'CSS',
html: 'HTML',
http: 'HTTP',
js: 'JavaScript',
json: 'JSON',
objectivec: 'Objective-C',
php: 'PHP',
sql: 'SQL',
toml: 'TOML',
ts: 'TypeScript',
typescript: 'TypeScript',
xml: 'XML',
yaml: 'YAML',
}[name] || name;
}
/* main */
$(document).ready(function () {
backToTop();
mobileNavbar();
toc();
headerAnchor();
fnTooltip();
});
highlight();
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -11,14 +11,15 @@
transition-timing-function: ease-out;
transition-duration: 0.3s;
z-index: 10;
cursor: pointer;
&:hover {
transform: translateY(-5px);
transform: translateY(-5px);
}
}
@include max-screen() {
.back-to-top {
display: none !important;
}
}
}
File renamed without changes.
@@ -13,10 +13,14 @@
& + .iconfont {
margin-left: $social-link-margin-left;
}
}
&:hover {
color: $theme-color;
svg {
fill: $theme-color;
}
}
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -79,17 +79,17 @@ $global-headings: (
// $header-padding: 20px 20px !default;
// Font family: Chancery
@font-face {
font-family: 'Chancery';
src: url('../fonts/chancery/apple-chancery-webfont.eot');
src: local('Apple Chancery'), url('../fonts/chancery/apple-chancery-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/chancery/apple-chancery-webfont.woff2') format('woff2'),
url('../fonts/chancery/apple-chancery-webfont.woff') format('woff'),
url('../fonts/chancery/apple-chancery-webfont.ttf') format('truetype'),
url('../fonts/chancery/apple-chancery-webfont.svg#apple-chancery') format('svg');
font-weight: lighter;
font-style: normal;
}
// @font-face {
// font-family: 'Chancery';
// src: url('../fonts/chancery/apple-chancery-webfont.eot');
// src: local('Apple Chancery'), url('../fonts/chancery/apple-chancery-webfont.eot?#iefix') format('embedded-opentype'),
// url('../fonts/chancery/apple-chancery-webfont.woff2') format('woff2'),
// url('../fonts/chancery/apple-chancery-webfont.woff') format('woff'),
// url('../fonts/chancery/apple-chancery-webfont.ttf') format('truetype'),
// url('../fonts/chancery/apple-chancery-webfont.svg#apple-chancery') format('svg');
// font-weight: lighter;
// font-style: normal;
// }
// Font size of the logo.
$logo-font-size: 36px !default;
@@ -5,7 +5,7 @@
@import "_common/animation";
@import "_base";
@import "_iconfont";
// @import "_iconfont";
@import "_partial/header";
@import "_partial/post";
@import "_partial/pagination";
@@ -54,7 +54,10 @@
</footer>
<div class="back-to-top" id="back-to-top">
<i class="iconfont icon-up"></i>
<i class="iconfont">
{{/* icon up */}}
{{ partial "svg/up.svg" }}
</i>
</div>
</div>
{{ partial "scripts.html" . }}
@@ -1,19 +1,5 @@
<div class="social-links">
{{- range $name, $path := .Site.Params.social }}
{{- if $path }}
{{- $realName := slicestr $name 2 }}
<a href="{{ $path | safeURL }}" rel="me noopener" class="iconfont icon-{{ $realName }}"
title="{{ $realName }}"{{ if not (hasPrefix $path "mailto:") }} target="_blank"{{ end }}>
</a>
{{- end }}
{{- end }}
{{ with .Site.GetPage "home" -}}
{{- with .OutputFormats.Get "RSS" -}}
<a href="{{ .Permalink }}" rel="noopener {{ .Rel }}" type="{{ .MediaType.Type }}" class="iconfont icon-rss"
title="rss" target="_blank">
</a>
{{ end -}}
{{- end -}}
{{ partial "social_links.html" . }}
</div>
<div class="copyright">
@@ -33,7 +19,10 @@
{{ end }}
{{- $current }}
<span class="heart">
<i class="iconfont icon-heart"></i>
{{/* icon heart */}}
<i class="iconfont">
{{ partial "svg/heart.svg" }}
</i>
</span>
{{- if or .Site.Copyright .Site.Author.name -}}
<span class="author">
@@ -74,7 +74,8 @@
{{- end }}
<!-- Styles -->
<link href="{{ "dist/jane.min.css?v=2.7.0" | relURL }}" rel="stylesheet">
{{ $style := resources.Get "sass/jane.scss" | toCSS | minify | fingerprint }}
<link rel="stylesheet" href="{{ $style.Permalink }}">
<!-- custom css -->
{{ range .Site.Params.customCSS }}
@@ -28,7 +28,10 @@
{{ if hasPrefix .URL "http" }}
<a class="menu-item-link" href="{{ .URL | absLangURL | safeURL }}" rel="noopener" target="_blank">
{{ .Name }}
<i class="iconfont icon-new-window"></i>
{{/* icon new window */}}
<i class="iconfont">
{{ partial "svg/new_window.svg" }}
</i>
</a>
{{ else }}
<a class="menu-item-link" href="{{ .URL | absLangURL | safeURL }}">{{ .Name }}</a>
@@ -43,7 +46,10 @@
<li class="menu-item">
<!-- drop down navigation MENU -->
<a class="menu-item-link menu-parent menu-item-lang" href="#">
<i class="iconfont icon-globe"></i>
{{/* icon globe */}}
<i class="iconfont">
{{ partial "svg/globe.svg" }}
</i>
{{ .Site.Language.LanguageName }}
</a>
<ul class="submenu">
Oops, something went wrong.

0 comments on commit 8a1f701

Please sign in to comment.