diff --git a/README.md b/README.md index fcb5712..96d7a97 100644 --- a/README.md +++ b/README.md @@ -16,4 +16,67 @@ https://matsuuratomoya.com 授業関係の連絡はこちら↓ Related to courseworks -- teach\[at\]matsuuratomoya.com \ No newline at end of file +- teach\[at\]matsuuratomoya.com + + +# 使い方のメモ + +## 新しい授業資料更新のファイル作成コマンド + +```sh +hugo new --kind class content/docs/2023/code-design/10 +``` + +## カスタムショートコード + +テーマのショートコードも使える。 + +https://github.com/alex-shpak/hugo-book#shortcodes  + + +### `embed_pdf` PDFの埋め込み + +embedで埋め込むだけ。Page Bundleになっている必要があるので`index.md`と同ディレクトリでないと使えない + +```md +{{< embed_pdf >}} +``` + +mdと同ディレクトリにあるPDFのうち一番先頭のファイルを埋め込む。 + +```md +--- +... +params: + pdf_path:hoge.pdf +... +--- + +{{< embed_pdf >}} +``` + +フロントマッターで相対指定したPDFファイルを埋め込む。 + +```md +{{< embed_pdf href = "hoge.pdf">}} +``` + +インライン指定したPDFファイルを埋め込む。 + +### `slides_jpg` + +```md +{{< slides_jpg >}} +``` + +Page Resourcesの中のJPGを全部名前順に連番で表示する。keynoteでjpgエクスポートした連番ファイルをそのまま突っ込んで表示できる想定。 + +### `preview_code` + +指定したファイルを読み込んで通常のコードハイライト表示をし、ダウンロードのボタンを追加する。 +これも埋め込むファイルがPage Resourcesになっている必要がある(サブディレクトリに入れることはできない。) +`type`でシンタックスハイライトの種類を指定できる。 + +```md +{{< preview_code href="tone_minimal.ino" type= "ino">}} +``` diff --git a/archetypes/class/_index.en.md b/archetypes/class/_index.en.md new file mode 100644 index 0000000..c17111a --- /dev/null +++ b/archetypes/class/_index.en.md @@ -0,0 +1,18 @@ +--- +title: Week N +date: {{.Date}} +weight: 1 +params: + pdf_path: "hoge.pdf" +draft: true +--- + +# {{.Date| dateFormat "2006"}} Class Name / Week N + +## Slides + +{{< embed_pdf >}} + +{{< button href=.Page.Params.pdf_path >}}Slides(PDF){{< /button >}} + +{{< button href="slides">}}Slides(HTML){{< /button >}} diff --git a/archetypes/class/_index.md b/archetypes/class/_index.md new file mode 100644 index 0000000..d04678d --- /dev/null +++ b/archetypes/class/_index.md @@ -0,0 +1,18 @@ +--- +title: 第N週 +date: {{.Date}} +weight: 1 +params: + pdf_path: "hoge.pdf" +draft: true +--- + +# {{.Date| dateFormat "2006"}}年 授業名 第N回 + +## スライド + +{{< embed_pdf >}} + +{{< button href=.Page.Params.pdf_path >}}スライド(PDF){{< /button >}} + +{{< button href="slides">}}スライド(HTML){{< /button >}} diff --git a/archetypes/class/slides/index.en.md b/archetypes/class/slides/index.en.md new file mode 100644 index 0000000..37a573d --- /dev/null +++ b/archetypes/class/slides/index.en.md @@ -0,0 +1,10 @@ +--- +title: "Class Name {{.Date| dateFormat "2006"}} Week N Slides" +date: {{.Date}} +bookHidden: true +--- + + +# Slides + +{{< slides_jpg >}} \ No newline at end of file diff --git a/archetypes/class/slides/index.md b/archetypes/class/slides/index.md new file mode 100644 index 0000000..d9a65bf --- /dev/null +++ b/archetypes/class/slides/index.md @@ -0,0 +1,10 @@ +--- +title: "授業名 {{.Date| dateFormat "2006"}}年 第N回 スライド" +date: {{.Date}} +bookHidden: true +--- + + +# スライド + +{{< slides_jpg >}} \ No newline at end of file diff --git a/config.toml b/config.toml index a068fa2..9a6978d 100644 --- a/config.toml +++ b/config.toml @@ -21,12 +21,6 @@ contentDir = 'content' weight = 2 title = "Classes by Matsuura Tomoya" -[mediaTypes] - [mediaTypes.'text/ino'] - suffixes = ['ino'] - [mediaTypes.'text/pde'] - suffixes = ['pde'] - # (Optional) Set Google Analytics if you use it to track your website. diff --git a/layouts/shortcodes/embed_pdf.html b/layouts/shortcodes/embed_pdf.html new file mode 100644 index 0000000..8a32cbb --- /dev/null +++ b/layouts/shortcodes/embed_pdf.html @@ -0,0 +1,17 @@ +{{ $target := "" }} + +{{with .Page.Resources.GetMatch "*.pdf"}} + {{ $target = . }} +{{end}} + +{{with .Page.Params.pdf_path}} + {{ $target = . }} +{{end}} + + +{{ with index .Params 0 }} + {{ $target = . }} +{{ end }} + + +