Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions assets/css/book-print.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@media print {
body {
font-family: "Times New Roman", serif;
font-size: 12pt;
line-height: 1.6;
color: #000;
}

header, footer, nav {
page-break-after: always;
}

article {
page-break-before: always;
}
}
16 changes: 16 additions & 0 deletions assets/css/print.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@media print {
body {
font-family: "Times New Roman", serif;
font-size: 12pt;
line-height: 1.6;
color: #000;
}

header, footer, nav {
display: none;
}

article {
page-break-after: always;
}
}
42 changes: 42 additions & 0 deletions layouts/_default/book.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{ define "main" }}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>{{ .Site.Title }} — Book</title>
<link rel="stylesheet" href="{{ "css/book-print.css" | relURL }}" media="print">
</head>
<body>
<header>
<h1>{{ .Site.Title }}</h1>
<p><em>Printable Book — generated on {{ now.Format "January 2, 2006" }}</em></p>
<hr/>
</header>

<nav class="toc">
<h2>Contents</h2>
<ol>
{{ $pages := where .Site.RegularPages "Params.book" true }}
{{ $sorted := sort $pages "Params.book_order" "asc" }}
{{ range $sorted }}
<li><a href="#{{ .File.UniqueID }}">{{ .Title }}</a></li>
{{ end }}
</ol>
</nav>

{{ range $sorted }}
<article id="{{ .File.UniqueID }}" class="chapter">
<h2>{{ .Title }}</h2>
{{ .Content }}
</article>
{{ end }}

<footer>
<hr/>
<p>Generated by Hugo on {{ now.Format "January 2, 2006" }}</p>
</footer>
</body>
</html>
{{ end }}

14 changes: 14 additions & 0 deletions org-cyf-guides/assets/css/book-print.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* book-print.css - print-focused rules */
@page { size: A4; margin: 20mm; }

@media print {
body { font-family: Georgia, "Times New Roman", serif; font-size: 12pt; color: #000; background:#fff; margin: 0; }
header, .site-header, .site-footer, nav, .no-print { display: none !important; }
.toc { page-break-after: always; }
.chapter { page-break-before: always; }
h1, h2 { break-inside: avoid; page-break-after: avoid; }
p { orphans: 3; widows: 3; }
pre { white-space: pre-wrap; word-wrap: break-word; font-family: monospace; font-size: 10pt; }
img { max-width: 100%; height: auto; }
table { page-break-inside: avoid; border-collapse: collapse; }
}
4 changes: 4 additions & 0 deletions org-cyf-guides/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[[menu.main]]
name = "Book"
url = "/book/"
weight = 10
5 changes: 5 additions & 0 deletions org-cyf-guides/content/book/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: "Curriculum Book"
layout: "book"
---
This page collects pages marked for the printed book.
12 changes: 12 additions & 0 deletions org-cyf-guides/content/book/chapter1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: "Chapter 1: Introduction"
book: true
book_order: 1
---

Welcome to the printable **Book Layout** in Hugo!
This is your first chapter. You can add more chapters by running:

```bash
hugo new book/chapter2.md

8 changes: 8 additions & 0 deletions org-cyf-guides/content/book/chapter2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: "Chapter 2: Advanced Topics"
book: true
book_order: 2
---

This chapter expands on the concepts from Chapter 1 and explores more advanced topics.

4 changes: 2 additions & 2 deletions org-cyf-guides/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/CodeYourFuture/curriculum/org-cyf-guides
go 1.24.5

require (
github.com/CodeYourFuture/curriculum/common-content v0.0.0-20241008095008-281a5517463f // indirect
github.com/CodeYourFuture/curriculum/common-theme v0.0.0-20241008095008-281a5517463f // indirect
github.com/CodeYourFuture/curriculum/common-content v0.0.0-20250801130816-705636729ea4 // indirect
github.com/CodeYourFuture/curriculum/common-theme v0.0.0-20250801130816-705636729ea4 // indirect
github.com/CodeYourFuture/curriculum/org-cyf-theme v0.0.0-20240818070728-e8702788f7cb // indirect
)

Expand Down
41 changes: 41 additions & 0 deletions org-cyf-guides/layouts/_default/book.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{ define "main" }}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>{{ .Site.Title }} — Book</title>
<link rel="stylesheet" href="{{ "css/book-print.css" | relURL }}" media="print">
</head>
<body>
<header>
<h1>{{ .Site.Title }}</h1>
<p><em>Printable Book — generated on {{ now.Format "January 2, 2006" }}</em></p>
<hr/>
</header>

<nav class="toc">
<h2>Contents</h2>
<ol>
{{ $pages := where .Site.RegularPages "Params.book" true }}
{{ $sorted := sort $pages "Params.book_order" "asc" }}
{{ range $sorted }}
<li><a href="#{{ .File.UniqueID }}">{{ .Title }}</a></li>
{{ end }}
</ol>
</nav>

{{ range $sorted }}
<article id="{{ .File.UniqueID }}" class="chapter">
<h2>{{ .Title }}</h2>
{{ .Content }}
</article>
{{ end }}

<footer>
<hr/>
<p>Generated by Hugo on {{ now.Format "January 2, 2006" }}</p>
</footer>
</body>
</html>
{{ end }}