diff options
-rw-r--r-- | README.md | 22 | ||||
-rw-r--r-- | assets/_markdown.scss | 2 | ||||
-rw-r--r-- | assets/book.scss | 2 | ||||
-rw-r--r-- | exampleSite/config.yml | 4 | ||||
-rw-r--r-- | exampleSite/resources/_gen/assets/scss/book.scss_48b060fe05b0a273d182ef83c0605941.content | 2 | ||||
-rw-r--r-- | exampleSite/resources/_gen/assets/scss/book.scss_48b060fe05b0a273d182ef83c0605941.json | 2 | ||||
-rw-r--r-- | layouts/home.html | 29 | ||||
-rw-r--r-- | layouts/posts/baseof.html | 2 |
8 files changed, 59 insertions, 6 deletions
@@ -12,12 +12,14 @@ * Designed to not interfere with other layouts * Zero initial configuration + ## Requirements * Hugo 0.43 or higher * Hugo extended version, read more [here](https://gohugo.io/news/0.43-relnotes/) + ## Installation -Navigate to your hugo website root and run: +Navigate to your hugo project root and run: ``` git submodule add https://github.com/alex-shpak/hugo-book themes/book ``` @@ -27,11 +29,24 @@ Then run hugo (or set `theme: book` in configuration file) hugo server --theme book ``` +### Creating site from scratch +Below is example how to create new site from scratch +```sh +hugo new site mydocs; cd mydocs +git init +git submodule add https://github.com/alex-shpak/hugo-book themes/book +cp -R themes/book/exampleSite/content . +``` +```sh +hugo server --theme book +``` + ## Menu ### File tree menu (default) By default theme will render pages from `content/docs` section as menu in a tree structure. You can set `title` and `weight` in front matter of pages to adjust order and titles in menu. + ### Leaf bundle menu You can also use leaf bundle and content of it's `index.md` as menu. @@ -65,9 +80,11 @@ And Enable it by settings `BookMenuBundle: /docs/menu` in Site configuration - [Example config file](https://github.com/alex-shpak/hugo-book/blob/master/exampleSite/config.yml) - [Leaf bundles](https://gohugo.io/content-management/page-bundles/) + ## Blog Simple blog supported for section `posts` + ## Configuration ### Site Configuration There are few configuration options you can add to your `config.yml|json|toml` file @@ -116,6 +133,7 @@ params: BookEditPath: edit/master/exampleSite/content ``` + ### Page Configuration You can specify additional params per page in front matter ```yaml @@ -134,6 +152,7 @@ bookShowToC: false --- ``` + ### Partials There are few empty partials you can override in `layouts/partials/` @@ -154,5 +173,6 @@ Primary goals are: Feel free to open issue if you missing some configuration or customization option. + ## License [MIT](LICENSE) diff --git a/assets/_markdown.scss b/assets/_markdown.scss index 1fe1a50..fc8119c 100644 --- a/assets/_markdown.scss +++ b/assets/_markdown.scss @@ -29,9 +29,7 @@ $block-border-radius: 0.15rem; code { font-family: 'Oxygen Mono', monospace; - } - p code { padding: 0 $padding-4; background: $gray-100; border-radius: $block-border-radius; diff --git a/assets/book.scss b/assets/book.scss index b1b0892..13cdbd8 100644 --- a/assets/book.scss +++ b/assets/book.scss @@ -108,6 +108,7 @@ ul.pagination { .book-page { min-width: $body-min-width; + flex-grow: 1; padding: $padding-16; } @@ -147,6 +148,7 @@ ul.pagination { .book-posts { min-width: $body-min-width; max-width: $sm-breakpoint; + flex-grow: 1; padding: $padding-16; article { diff --git a/exampleSite/config.yml b/exampleSite/config.yml index 1815a9b..0cf2eb7 100644 --- a/exampleSite/config.yml +++ b/exampleSite/config.yml @@ -10,6 +10,10 @@ disableKinds: ["taxonomy", "taxonomyTerm"] disablePathToLower: true enableGitInfo: true +# Code highlight +pygmentsStyle: monokailight +pygmentsCodeFences: true + params: # Configure the date format utilised on the pages DateFormat: "Jan 2, 2006" diff --git a/exampleSite/resources/_gen/assets/scss/book.scss_48b060fe05b0a273d182ef83c0605941.content b/exampleSite/resources/_gen/assets/scss/book.scss_48b060fe05b0a273d182ef83c0605941.content index dd5bdc4..a3e16ca 100644 --- a/exampleSite/resources/_gen/assets/scss/book.scss_48b060fe05b0a273d182ef83c0605941.content +++ b/exampleSite/resources/_gen/assets/scss/book.scss_48b060fe05b0a273d182ef83c0605941.content @@ -1 +1 @@ -.markdown{line-height:1.7}.markdown>:first-child{margin-top:0;line-height:1em}.markdown h1,.markdown h2,.markdown h3,.markdown h4,.markdown h5{font-weight:400;line-height:1.25}.markdown b,.markdown optgroup,.markdown strong{font-weight:700}.markdown a{text-decoration:none}.markdown a:hover{text-decoration:underline}.markdown code{font-family:oxygen mono,monospace}.markdown p code{padding:0 .25rem;background:#f8f9fa;border-radius:.15rem}.markdown pre{padding:1rem;background:#f8f9fa;border-radius:.15rem;font-size:.875rem;overflow-x:auto}.markdown blockquote{border-left:2px solid #dee2e6;margin:0;padding:1px 1rem}.markdown blockquote :first-child{margin-top:0}.markdown blockquote :last-child{margin-bottom:0}.markdown table{border-spacing:0;border-collapse:collapse}.markdown table tr th,.markdown table tr td{padding:.5rem 1rem;line-height:1;border:1px solid #e9ecef}.markdown table tr:nth-child(2n){background:#f8f9fa}.flex{display:flex}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.align-center{align-items:center}.mx-auto{margin:0 auto}.mr-auto{margin-right:auto}.hide{display:none}html{font-size:16px;letter-spacing:.33px;scroll-behavior:smooth}html,body{min-width:20rem;overflow-x:hidden}body{color:#343a40;background:#fff;font-family:oxygen,sans-serif;font-weight:400;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;box-sizing:border-box}body *{box-sizing:inherit}h1,h2,h3,h4,h5{font-weight:400}a{text-decoration:none;color:#004ed0}a:visited{color:#8440f1}img{vertical-align:middle}aside nav ul{padding:0;margin:0;list-style:none}aside nav ul li{margin:1em 0}aside nav ul a{display:block}aside nav ul a:hover{opacity:.5}aside nav ul ul{padding-left:1rem}ul.pagination{display:flex;justify-content:center}ul.pagination .page-item a{padding:1rem}.container{max-width:80rem;margin:0 auto}.book-brand{margin-top:0}.book-menu{flex:0 0 16rem;font-size:.875rem}.book-menu nav{width:16rem;padding:1rem;position:fixed;top:0;bottom:0;overflow-x:hidden;overflow-y:auto}.book-menu a{color:#343a40}.book-menu a.active{color:#004ed0}.book-page{min-width:20rem;padding:1rem}.book-header{margin-bottom:1rem;display:none}.book-toc{flex:0 0 14rem;font-size:.75rem}.book-toc nav{width:14rem;padding:1rem;position:fixed;top:0;bottom:0;overflow-x:hidden;overflow-y:auto}.book-toc nav>ul>li{margin:0}.book-git-footer{display:flex;margin-top:1rem;font-size:.875rem;align-items:baseline}.book-git-footer img{width:.875rem;vertical-align:bottom}.book-posts{min-width:20rem;max-width:41rem;padding:1rem}.book-posts article{padding-bottom:1rem}aside nav,.book-page,.book-posts,.markdown{transition:.2s ease-in-out;transition-property:transform,margin-left,opacity;will-change:transform,margin-left}@media screen and (max-width:55rem){.book-toc{display:none}}@media screen and (max-width:41rem){.book-menu{margin-left:-16rem}.book-header{display:flex}#menu-control:checked+main .book-menu nav,#menu-control:checked+main .book-page,#menu-control:checked+main .book-posts{transform:translateX(16rem)}#menu-control:checked+main .book-header label{transform:rotate(90deg)}#menu-control:checked+main .markdown{opacity:.25}}@media screen and (min-width:80rem){.book-page,.book-menu nav,.book-toc nav{padding:2rem 1rem}}
\ No newline at end of file +.markdown{line-height:1.7}.markdown>:first-child{margin-top:0;line-height:1em}.markdown h1,.markdown h2,.markdown h3,.markdown h4,.markdown h5{font-weight:400;line-height:1.25}.markdown b,.markdown optgroup,.markdown strong{font-weight:700}.markdown a{text-decoration:none}.markdown a:hover{text-decoration:underline}.markdown code{font-family:oxygen mono,monospace;padding:0 .25rem;background:#f8f9fa;border-radius:.15rem}.markdown pre{padding:1rem;background:#f8f9fa;border-radius:.15rem;font-size:.875rem;overflow-x:auto}.markdown blockquote{border-left:2px solid #dee2e6;margin:0;padding:1px 1rem}.markdown blockquote :first-child{margin-top:0}.markdown blockquote :last-child{margin-bottom:0}.markdown table{border-spacing:0;border-collapse:collapse}.markdown table tr th,.markdown table tr td{padding:.5rem 1rem;line-height:1;border:1px solid #e9ecef}.markdown table tr:nth-child(2n){background:#f8f9fa}.flex{display:flex}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.align-center{align-items:center}.mx-auto{margin:0 auto}.mr-auto{margin-right:auto}.hide{display:none}html{font-size:16px;letter-spacing:.33px;scroll-behavior:smooth}html,body{min-width:20rem;overflow-x:hidden}body{color:#343a40;background:#fff;font-family:oxygen,sans-serif;font-weight:400;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;box-sizing:border-box}body *{box-sizing:inherit}h1,h2,h3,h4,h5{font-weight:400}a{text-decoration:none;color:#004ed0}a:visited{color:#8440f1}img{vertical-align:middle}aside nav ul{padding:0;margin:0;list-style:none}aside nav ul li{margin:1em 0}aside nav ul a{display:block}aside nav ul a:hover{opacity:.5}aside nav ul ul{padding-left:1rem}ul.pagination{display:flex;justify-content:center}ul.pagination .page-item a{padding:1rem}.container{max-width:80rem;margin:0 auto}.book-brand{margin-top:0}.book-menu{flex:0 0 16rem;font-size:.875rem}.book-menu nav{width:16rem;padding:1rem;position:fixed;top:0;bottom:0;overflow-x:hidden;overflow-y:auto}.book-menu a{color:#343a40}.book-menu a.active{color:#004ed0}.book-page{min-width:20rem;flex-grow:1;padding:1rem}.book-header{margin-bottom:1rem;display:none}.book-toc{flex:0 0 14rem;font-size:.75rem}.book-toc nav{width:14rem;padding:1rem;position:fixed;top:0;bottom:0;overflow-x:hidden;overflow-y:auto}.book-toc nav>ul>li{margin:0}.book-git-footer{display:flex;margin-top:1rem;font-size:.875rem;align-items:baseline}.book-git-footer img{width:.875rem;vertical-align:bottom}.book-posts{min-width:20rem;max-width:41rem;flex-grow:1;padding:1rem}.book-posts article{padding-bottom:1rem}aside nav,.book-page,.book-posts,.markdown{transition:.2s ease-in-out;transition-property:transform,margin-left,opacity;will-change:transform,margin-left}@media screen and (max-width:55rem){.book-toc{display:none}}@media screen and (max-width:41rem){.book-menu{margin-left:-16rem}.book-header{display:flex}#menu-control:checked+main .book-menu nav,#menu-control:checked+main .book-page,#menu-control:checked+main .book-posts{transform:translateX(16rem)}#menu-control:checked+main .book-header label{transform:rotate(90deg)}#menu-control:checked+main .markdown{opacity:.25}}@media screen and (min-width:80rem){.book-page,.book-menu nav,.book-toc nav{padding:2rem 1rem}}
\ No newline at end of file diff --git a/exampleSite/resources/_gen/assets/scss/book.scss_48b060fe05b0a273d182ef83c0605941.json b/exampleSite/resources/_gen/assets/scss/book.scss_48b060fe05b0a273d182ef83c0605941.json index d55fe76..e1ec107 100644 --- a/exampleSite/resources/_gen/assets/scss/book.scss_48b060fe05b0a273d182ef83c0605941.json +++ b/exampleSite/resources/_gen/assets/scss/book.scss_48b060fe05b0a273d182ef83c0605941.json @@ -1 +1 @@ -{"Target":"book.min.b8c2675c55d0a2fb28a8eb86fd73370149cfb0ea7b9751dc17cc2413537a1d44.css","MediaType":"text/css","Data":{"Integrity":"sha256-uMJnXFXQovsoqOuG/XM3AUnPsOp7l1HcF8wkE1N6HUQ="}}
\ No newline at end of file +{"Target":"book.min.b19e39655cbb35014c212261acf02c44c22b653e1183471f8513702b5bfd8f54.css","MediaType":"text/css","Data":{"Integrity":"sha256-sZ45ZVy7NQFMISJhrPAsRMIrZT4Rg0cfhRNwK1v9j1Q="}}
\ No newline at end of file diff --git a/layouts/home.html b/layouts/home.html new file mode 100644 index 0000000..d2db819 --- /dev/null +++ b/layouts/home.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +{{- partial "docs/shared" -}} +<html> + +<head> + {{ partial "docs/html-head" . }} + {{ partial "docs/inject/head" . }} +</head> +{{- $content := ` +# Hugo Book Theme + +This is a placeholder for home page. +You can override this page in: + + - `/content/_index.md` + - `/layouts/home.html` +` -}} +<body> + <main class="flex justify-center"> + <div class="book-page markdown"> + {{ replace $content "`" "`" | markdownify }} + </div> + </main> + + {{ partial "docs/inject/body" . }} + {{ template "_internal/google_analytics_async.html" . }} +</body> + +</html> diff --git a/layouts/posts/baseof.html b/layouts/posts/baseof.html index bbf5d45..6e49ce8 100644 --- a/layouts/posts/baseof.html +++ b/layouts/posts/baseof.html @@ -14,7 +14,7 @@ {{ partial "docs/menu" . }} </aside> - <div class="book-posts mr-auto"> + <div class="book-posts"> {{ partial "docs/mobile-header" . }} {{ template "main" . }} </div> |