YehYeh 記事本2.0

Version 0.8.3

竹科碼農的記事本

OtherFunction

SASS / SCSS

  • 要使用SASS,hugo安裝的版本要是extended版
<!-- 指定sass的原始檔 -->
{{ $sass := resources.Get "sass/main.scss" }}

<!-- 用resources.ToCSS將sass轉成CSS(將原始檔案轉成resource(Resource會放在assets資料夾裡)) -->
{{ $style := $sass | resources.ToCSS }}

MathJax

themes > xxx > layouts > partials > mathjax.html

{{ if and .IsPage (eq (.Param "mathjax") true) }}
<script src="{{ .Param "mathjaxPath" | default "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js" }}{{ with .Param "mathjaxConfig" | default "TeX-AMS-MML_HTMLorMML" }}?config={{ . }}{{ end }}" async></script>
{{ end }}

themes > XXX > layouts > _default > baseof.html

<!DOCTYPE html>
<html class="no-js" lang="{{ .Site.LanguageCode | default "en-us" }}">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>{{ block "title" . }}{{ if not .IsHome }}{{ .Title }} - {{ end }}{{ .Site.Title }}{{ end }}</title>
	<script>(function(d,e){d[e]=d[e].replace("no-js","js");})(document.documentElement,"className");</script>
	<meta name="description" content="{{ if .IsHome }}{{ .Site.Params.description }}{{ else }}{{ .Params.Description }}{{ end }}">
	{{ if .Site.Params.opengraph }}{{ template "_internal/opengraph.html" . }}{{ end }}
	{{ if .Site.Params.twitter_cards }}{{ template "_internal/twitter_cards.html" . }}{{ end }}
	<link rel="dns-prefetch" href="//fonts.googleapis.com">
	<link rel="dns-prefetch" href="//fonts.gstatic.com">
	{{ with .OutputFormats.Get "rss" -}}
	{{ printf `<link rel="%s" type="%s" href="%s" title="%s">` .Rel .MediaType.Type .RelPermalink $.Site.Title | safeHTML }}
	{{ end -}}
	<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700">
	{{ $style := resources.Get "css/style.css" | resources.ExecuteAsTemplate "css/style.css" . -}}
	<link rel="stylesheet" href="{{ $style.RelPermalink }}">
	{{ range .Site.Params.customCSS -}}
	<link rel="stylesheet" href="{{ . | relURL }}">
	{{- end }}
	<link rel="shortcut icon" href="{{ "favicon.ico" | relURL }}">
	{{- if not .Site.IsServer }}
		{{ template "_internal/google_analytics_async.html" . }}
	{{- end }}
</head>
<body class="body">
	<div class="container container--outer">
		{{ partial "header" . }}
		<div class="wrapper flex">
			<div class="primary">
			{{ block "main" . }}
				{{ with .Content }}
				<div class="content main__content clearfix">
					{{ . }}
				</div>
				{{ end }}
			{{ end }}
			</div>
			{{ partial "sidebar.html" . }}
		</div>
		{{ partial "footer" . }}
	</div>
<script async defer src="{{ "js/menu.js" | relURL }}"></script>
{{ range .Site.Params.customJS -}}
<script src="{{ . | relURL }}"></script>
{{- end }}
{{- partial "mathjax.html" . -}}
</body>
</html>

frontmatter

---
# Common-Defined params
title: "2"
date: 2020-03-20T22:57:54+08:00
draft: true
description: "Example article description"
categories:
  - "Category 1"
  - "Category 2"
tags:
  - "Test"
  - "Another test"
menu: main # Optional, add page to a menu. Options: main, side, footer

# Theme-Defined params
thumbnail: "img/placeholder.jpg" # Thumbnail image
lead: "Example lead - highlighted near the title" # Lead text
comments: false # Enable Disqus comments for specific page
authorbox: true # Enable authorbox for specific page
toc: true # Enable Table of Contents for specific page
mathjax: true # Enable MathJax for specific page
---
Last updated on 2020-04-05
Published on 2020-04-05
Edit on GitHub