From c9cd1afefb89e51cee771ab3aff735f43e231a9b Mon Sep 17 00:00:00 2001 From: George Cushen Date: Mon, 6 May 2019 15:53:16 +0100 Subject: [PATCH] demo: change Tutorials to Courses and add List of Courses Perhaps a more common use case of the docs layout. See #109 --- data/assets.toml | 4 +- exampleSite/config/_default/menus.toml | 4 +- exampleSite/content/courses/_index.md | 8 +++ exampleSite/content/courses/example/_index.md | 61 +++++++++++++++++++ .../{tutorial => courses/example}/example1.md | 2 +- .../{tutorial => courses/example}/example2.md | 2 +- exampleSite/content/tutorial/_index.md | 51 ---------------- layouts/_default/list.html | 8 --- layouts/_default/section.html | 20 ++++++ 9 files changed, 95 insertions(+), 65 deletions(-) create mode 100644 exampleSite/content/courses/_index.md create mode 100644 exampleSite/content/courses/example/_index.md rename exampleSite/content/{tutorial => courses/example}/example1.md (99%) rename exampleSite/content/{tutorial => courses/example}/example2.md (99%) delete mode 100644 exampleSite/content/tutorial/_index.md create mode 100644 layouts/_default/section.html diff --git a/data/assets.toml b/data/assets.toml index 75b29af0..be101661 100644 --- a/data/assets.toml +++ b/data/assets.toml @@ -8,8 +8,8 @@ # JavaScript [js.jQuery] - version = "3.3.1" - sri = "sha512-+NqPlbbtM1QqiK8ZAo4Yrj2c4lNQoGv8P79DPtKzj++l5jnN39rHA/xsqn8zE9l0uSoxaCdrOgFs6yjyfbBxSg==" + version = "3.4.1" + sri = "sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" url = "https://cdnjs.cloudflare.com/ajax/libs/jquery/%s/jquery.min.js" [js.highlight] version = "9.12.0" diff --git a/exampleSite/config/_default/menus.toml b/exampleSite/config/_default/menus.toml index e1c10c15..8800df80 100644 --- a/exampleSite/config/_default/menus.toml +++ b/exampleSite/config/_default/menus.toml @@ -24,8 +24,8 @@ weight = 40 [[main]] - name = "Tutorials" - url = "tutorial/" + name = "Courses" + url = "courses/" weight = 50 [[main]] diff --git a/exampleSite/content/courses/_index.md b/exampleSite/content/courses/_index.md new file mode 100644 index 00000000..fa5b6f6c --- /dev/null +++ b/exampleSite/content/courses/_index.md @@ -0,0 +1,8 @@ ++++ +title = "Courses" + +# Optional featured image (relative to `static/img/` folder). +[header] +image = "" +caption = "" ++++ diff --git a/exampleSite/content/courses/example/_index.md b/exampleSite/content/courses/example/_index.md new file mode 100644 index 00000000..07343636 --- /dev/null +++ b/exampleSite/content/courses/example/_index.md @@ -0,0 +1,61 @@ ++++ +# Course title, summary, and position. +linktitle = "An Example Course" +summary = "Learn how to use Academic's docs layout for publishing online courses, software documentation, and tutorials." +weight = 1 # Position of this course in course index. Comment out to order by date instead. + +# Page title +title = "Overview" + +date = 2018-09-09T00:00:00 # Date published +# lastmod = 2018-09-09T00:00:00 # Date modified + +draft = false # Is this a draft? true/false +toc = true # Show table of contents? true/false +type = "docs" # Do not modify. + +# Add menu entry to sidebar. +[menu.example] + name = "Overview" # Declare this menu item as a parent with ID `name`. + weight = 1 # Position of link in menu. ++++ + +## Flexibility + +This feature can be used for publishing content such as: + +* **Online courses** +* **Project or software documentation** +* **Tutorials** + +The `courses` folder may be renamed. For example, we can rename it to `docs` for software/project documentation or `tutorials` for creating an online course. + +## Delete tutorials + +**To remove these pages, delete the `courses` folder and see below to delete the associated menu link.** + +## Update site menu + +After renaming or deleting the `courses` folder, you may wish to update any `[[main]]` menu links to it by editing your menu configuration at `config/_default/menus.toml`. + +For example, if you delete this folder, you can remove the following from your menu configuration: + +```toml +[[main]] + name = "Courses" + url = "courses/" + weight = 50 +``` + +Or, if you are creating a software documentation site, you can rename the `courses` folder to `docs` and update the associated *Courses* menu configuration to: + +```toml +[[main]] + name = "Docs" + url = "docs/" + weight = 50 +``` + +## Update the docs menu + +If you use the *docs* layout, note that the name of the menu in the front matter should be in the form `[menu.X]` where `X` is the folder name. Hence, if you rename the `courses/example/` folder, you should also rename the menu definitions in the front matter of files within `courses/example/` from `[menu.example]` to `[menu.]`. diff --git a/exampleSite/content/tutorial/example1.md b/exampleSite/content/courses/example/example1.md similarity index 99% rename from exampleSite/content/tutorial/example1.md rename to exampleSite/content/courses/example/example1.md index 505e3824..8d113369 100644 --- a/exampleSite/content/tutorial/example1.md +++ b/exampleSite/content/courses/example/example1.md @@ -13,7 +13,7 @@ weight = 1 # Add menu entry to sidebar. linktitle = "Tips 1-2" # Menu text - remove to use page title instead. -[menu.tutorial] +[menu.example] parent = "Example Topic" # ID of parent menu entry. weight = 1 # Position of link in menu. +++ diff --git a/exampleSite/content/tutorial/example2.md b/exampleSite/content/courses/example/example2.md similarity index 99% rename from exampleSite/content/tutorial/example2.md rename to exampleSite/content/courses/example/example2.md index 6d87a95e..229f0255 100644 --- a/exampleSite/content/tutorial/example2.md +++ b/exampleSite/content/courses/example/example2.md @@ -13,7 +13,7 @@ weight = 2 # Add menu entry to sidebar. linktitle = "Tips 3-4" # Menu text - remove to use page title instead. -[menu.tutorial] +[menu.example] parent = "Example Topic" # ID of parent menu entry. weight = 2 # Position of link in menu. +++ diff --git a/exampleSite/content/tutorial/_index.md b/exampleSite/content/tutorial/_index.md deleted file mode 100644 index 51d10d6d..00000000 --- a/exampleSite/content/tutorial/_index.md +++ /dev/null @@ -1,51 +0,0 @@ -+++ -title = "Overview" - -date = 2018-09-09T00:00:00 # Date published -# lastmod = 2018-09-09T00:00:00 # Date modified - -draft = false # Is this a draft? true/false -toc = true # Show table of contents? true/false -type = "docs" # Do not modify. - -# Add menu entry to sidebar. -[menu.tutorial] - name = "Overview" # Declare this menu item as a parent with ID `name`. - weight = 1 # Position of link in menu. -+++ - -## Flexibility - -This feature can be used for publishing content such as: - -* **Project or software documentation** -* **Online courses** -* **Tutorials** - -The `tutorial` folder may be renamed. For example, we can rename it to `docs` for software/project documentation or `course` for creating an online course. - -## Delete tutorials - -**To remove these pages, delete the `tutorial` folder and see below to delete the associated menu link.** - -## Update site menu - -After renaming or deleting the `tutorial` folder, you may wish to update any `[[main]]` menu links to it by editing your menu configuration at `config/_default/menus.toml`. - -For example, if you delete this folder, you can remove the following from your menu configuration: - -```toml -[[main]] - name = "Tutorials" - url = "tutorial/" - weight = 50 -``` - -Or, if you are creating an online course, you can rename the `tutorial` folder to `course` and update the associated *Tutorials* menu configuration to: - -```toml -[[main]] - name = "My Course" - url = "course/" - weight = 50 -``` diff --git a/layouts/_default/list.html b/layouts/_default/list.html index f9dbe5bb..a24bdb29 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,9 +1,3 @@ -{{ if .Params.widgets }} - -{{ partial "widget_page.html" . }} - -{{ else }} - {{ partial "header.html" . }} {{ partial "navbar.html" . }} @@ -34,5 +28,3 @@ {{ partial "footer_container.html" . }} {{ partial "footer.html" . }} - -{{ end }} diff --git a/layouts/_default/section.html b/layouts/_default/section.html new file mode 100644 index 00000000..15a730dc --- /dev/null +++ b/layouts/_default/section.html @@ -0,0 +1,20 @@ +{{ partial "header.html" . }} +{{ partial "navbar.html" . }} + +{{ partial "page_header.html" . }} + +
+ {{ with .Content }} +
{{ . }}
+ {{ end }} +
    + {{ if gt (len .Sections) 0}} + {{ range .Sections }} +
  • {{.LinkTitle}}
    {{with .Params.summary}}

    {{. | plainify | emojify}}

    {{end}}
  • + {{end}} + {{end}} +
+
+ +{{ partial "footer_container.html" . }} +{{ partial "footer.html" . }}