Add home page placeholder to not display empty page

This commit is contained in:
Alex Shpak 2019-03-29 16:15:43 +01:00
parent 9a8b89cf24
commit 5b652a1bb1
8 changed files with 59 additions and 6 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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 {

View File

@ -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"

View File

@ -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}}
.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}}

View File

@ -1 +1 @@
{"Target":"book.min.b8c2675c55d0a2fb28a8eb86fd73370149cfb0ea7b9751dc17cc2413537a1d44.css","MediaType":"text/css","Data":{"Integrity":"sha256-uMJnXFXQovsoqOuG/XM3AUnPsOp7l1HcF8wkE1N6HUQ="}}
{"Target":"book.min.b19e39655cbb35014c212261acf02c44c22b653e1183471f8513702b5bfd8f54.css","MediaType":"text/css","Data":{"Integrity":"sha256-sZ45ZVy7NQFMISJhrPAsRMIrZT4Rg0cfhRNwK1v9j1Q="}}

29
layouts/home.html Normal file
View File

@ -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:
- &#96;/content/_index.md&#96;
- &#96;/layouts/home.html&#96;
` -}}
<body>
<main class="flex justify-center">
<div class="book-page markdown">
{{ replace $content "&#96;" "`" | markdownify }}
</div>
</main>
{{ partial "docs/inject/body" . }}
{{ template "_internal/google_analytics_async.html" . }}
</body>
</html>

View File

@ -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>