From 8b93449cd18d745020d2d326e5ab25ff07b2ee2b Mon Sep 17 00:00:00 2001 From: Arun24-8 Date: Thu, 30 Oct 2025 11:37:48 +0000 Subject: [PATCH 1/2] Added printable Book layout and menu link --- org-cyf-guides/assets/css/book-print.css | 25 ++++++++++++++ org-cyf-guides/config.toml | 4 +++ org-cyf-guides/content/book/chapter1.md | 12 +++++++ org-cyf-guides/content/book/chapter2.md | 8 +++++ org-cyf-guides/go.mod | 4 +-- org-cyf-guides/layouts/_default/book.html | 41 +++++++++++++++++++++++ 6 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 org-cyf-guides/assets/css/book-print.css create mode 100644 org-cyf-guides/config.toml create mode 100644 org-cyf-guides/content/book/chapter1.md create mode 100644 org-cyf-guides/content/book/chapter2.md create mode 100644 org-cyf-guides/layouts/_default/book.html diff --git a/org-cyf-guides/assets/css/book-print.css b/org-cyf-guides/assets/css/book-print.css new file mode 100644 index 000000000..082c6db91 --- /dev/null +++ b/org-cyf-guides/assets/css/book-print.css @@ -0,0 +1,25 @@ +@media print { + body { + font-family: "Times New Roman", serif; + font-size: 12pt; + line-height: 1.6; + color: #000; + margin: 2cm; + } + + header, footer { + text-align: center; + } + + nav.toc { + page-break-after: always; + } + + article { + page-break-before: always; + } + + h1, h2 { + page-break-after: avoid; + } +} diff --git a/org-cyf-guides/config.toml b/org-cyf-guides/config.toml new file mode 100644 index 000000000..c371490b1 --- /dev/null +++ b/org-cyf-guides/config.toml @@ -0,0 +1,4 @@ +[[menu.main]] +name = "Book" +url = "/book/" +weight = 10 diff --git a/org-cyf-guides/content/book/chapter1.md b/org-cyf-guides/content/book/chapter1.md new file mode 100644 index 000000000..ee8e8e32e --- /dev/null +++ b/org-cyf-guides/content/book/chapter1.md @@ -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 + diff --git a/org-cyf-guides/content/book/chapter2.md b/org-cyf-guides/content/book/chapter2.md new file mode 100644 index 000000000..721cff973 --- /dev/null +++ b/org-cyf-guides/content/book/chapter2.md @@ -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. + diff --git a/org-cyf-guides/go.mod b/org-cyf-guides/go.mod index e6f2dd2d5..ebab863ee 100644 --- a/org-cyf-guides/go.mod +++ b/org-cyf-guides/go.mod @@ -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 ) diff --git a/org-cyf-guides/layouts/_default/book.html b/org-cyf-guides/layouts/_default/book.html new file mode 100644 index 000000000..35dc4dd93 --- /dev/null +++ b/org-cyf-guides/layouts/_default/book.html @@ -0,0 +1,41 @@ +{{ define "main" }} + + + + + + {{ .Site.Title }} — Book + + + +
+

{{ .Site.Title }}

+

Printable Book — generated on {{ now.Format "January 2, 2006" }}

+
+
+ + + + {{ range $sorted }} +
+

{{ .Title }}

+ {{ .Content }} +
+ {{ end }} + + + + +{{ end }} From a92dc6129901b5e9bcb5edbaddc6a5ba539d1bdb Mon Sep 17 00:00:00 2001 From: Arun24-8 Date: Thu, 30 Oct 2025 11:49:15 +0000 Subject: [PATCH 2/2] Feature: add printable Book layout, print stylesheet and sample chapters (Feature #127) --- assets/css/book-print.css | 16 +++++++++ assets/css/print.css | 16 +++++++++ layouts/_default/book.html | 42 ++++++++++++++++++++++++ org-cyf-guides/assets/css/book-print.css | 35 +++++++------------- org-cyf-guides/content/book/_index.md | 5 +++ 5 files changed, 91 insertions(+), 23 deletions(-) create mode 100644 assets/css/book-print.css create mode 100644 assets/css/print.css create mode 100644 layouts/_default/book.html create mode 100644 org-cyf-guides/content/book/_index.md diff --git a/assets/css/book-print.css b/assets/css/book-print.css new file mode 100644 index 000000000..ef4bd738f --- /dev/null +++ b/assets/css/book-print.css @@ -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; + } +} diff --git a/assets/css/print.css b/assets/css/print.css new file mode 100644 index 000000000..a4dc804f0 --- /dev/null +++ b/assets/css/print.css @@ -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; + } +} diff --git a/layouts/_default/book.html b/layouts/_default/book.html new file mode 100644 index 000000000..590d6cfd6 --- /dev/null +++ b/layouts/_default/book.html @@ -0,0 +1,42 @@ +{{ define "main" }} + + + + + + {{ .Site.Title }} — Book + + + +
+

{{ .Site.Title }}

+

Printable Book — generated on {{ now.Format "January 2, 2006" }}

+
+
+ + + + {{ range $sorted }} +
+

{{ .Title }}

+ {{ .Content }} +
+ {{ end }} + + + + +{{ end }} + diff --git a/org-cyf-guides/assets/css/book-print.css b/org-cyf-guides/assets/css/book-print.css index 082c6db91..023b7de62 100644 --- a/org-cyf-guides/assets/css/book-print.css +++ b/org-cyf-guides/assets/css/book-print.css @@ -1,25 +1,14 @@ -@media print { - body { - font-family: "Times New Roman", serif; - font-size: 12pt; - line-height: 1.6; - color: #000; - margin: 2cm; - } - - header, footer { - text-align: center; - } - - nav.toc { - page-break-after: always; - } +/* book-print.css - print-focused rules */ +@page { size: A4; margin: 20mm; } - article { - page-break-before: always; - } - - h1, h2 { - page-break-after: avoid; - } +@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; } } diff --git a/org-cyf-guides/content/book/_index.md b/org-cyf-guides/content/book/_index.md new file mode 100644 index 000000000..55b92604e --- /dev/null +++ b/org-cyf-guides/content/book/_index.md @@ -0,0 +1,5 @@ +--- +title: "Curriculum Book" +layout: "book" +--- +This page collects pages marked for the printed book.