Quellcode durchsuchen

feat(docs): Add breadcrumbs

Michael Bromley vor 7 Jahren
Ursprung
Commit
9c40f29186

+ 1 - 0
docs/assets/styles/_blog.scss

@@ -19,6 +19,7 @@
 .blog-post {
     max-width: 800px;
     margin: auto;
+    padding: 0 6px;
 
     header {
         overflow: hidden;

+ 22 - 0
docs/assets/styles/_breadcrumbs.scss

@@ -0,0 +1,22 @@
+@import "variables";
+
+ul.breadcrumbs {
+    list-style-type: none;
+    padding: 0;
+    font-size: 14px;
+    margin: 0;
+    li {
+        display: inline-block;
+        color: $gray-600;
+    }
+    li + li {
+        &:before {
+            content: '›';
+            margin: 0 3px;
+        }
+    }
+
+    @media all and (max-width: $sm-breakpoint){
+        font-size: 12px;
+    }
+}

+ 2 - 7
docs/assets/styles/main.scss

@@ -1,4 +1,3 @@
-@import "~@clr/icons/clr-icons.css";
 @import "variables";
 @import "markdown";
 @import "utils";
@@ -8,6 +7,7 @@
 @import "shortcodes";
 @import "syntax";
 @import "search-widget";
+@import "breadcrumbs";
 @import "blog";
 
 html {
@@ -124,7 +124,7 @@ ul.contents-list {
     min-width: $body-min-width;
     min-height: 80vh;
     flex: 1;
-    padding: $padding-16;
+    padding: $padding-16 * 1.6;
 }
 
 .book-header {
@@ -284,11 +284,6 @@ aside nav,
 
 // Extra space for big screens
 @media screen and (min-width: $container-max-width) {
-    .book-page,
-    .book-menu nav,
-    .book-toc nav {
-        padding: $padding-16 * 2 $padding-16;
-    }
     .book-menu nav {
         padding-top: $padding-16;
     }

+ 2 - 1
docs/content/docs/graphql-api/_index.md

@@ -4,7 +4,7 @@ weight: 3
 showtoc: false
 ---
 
-# GraphQL API Docs
+# GraphQL API 
 
 This section contains a description of all queries, mutations and related types available in the Vendure GraphQL API.
 
@@ -12,3 +12,4 @@ The API is split into two distinct endpoints: *Shop* and *Admin*. The Shop API i
 {{% alert %}}
 All documentation in this section is auto-generated from the Vendure GraphQL schema.
 {{% /alert %}}
+

+ 17 - 17
docs/layouts/docs/baseof.html

@@ -3,36 +3,36 @@
 <html>
 
 <head>
-  {{ partial "docs/html-head" . }}
+    {{ partial "docs/html-head" . }}
 </head>
 
 <body>
-  <input type="checkbox" style="display: none" id="menu-control" />
-  <main class="flex container">
+<input type="checkbox" style="display: none" id="menu-control" />
+<main class="flex container">
 
     <aside class="book-menu fixed">
-      <nav role="navigation">
-        {{ if .Site.Params.BookMenuBundle }}
-          {{ partial "docs/menu-bundle" . }}
-        {{ else }}
-          {{ partial "docs/menu-filetree" . }}
-        {{ end }}
-      </nav>
+        <nav role="navigation">
+            {{ if .Site.Params.BookMenuBundle }}
+            {{ partial "docs/menu-bundle" . }}
+            {{ else }}
+            {{ partial "docs/menu-filetree" . }}
+            {{ end }}
+        </nav>
     </aside>
 
     <div class="book-page">
-      {{ partial "docs/mobile-header" . }}
-      {{ template "main" . }}
-      <div class="book-footer">
+        {{ partial "docs/mobile-header" . }}
+        {{ template "main" . }}
+        <div class="book-footer">
 
-      </div>
+        </div>
     </div>
 
     {{ template "toc" . }}
-  </main>
+</main>
 
-  {{ partial "top-bar" (dict "isDocsPage" true) }}
-  {{ template "_internal/google_analytics_async.html" . }}
+{{ partial "top-bar" (dict "isDocsPage" true) }}
+{{ template "_internal/google_analytics_async.html" . }}
 </body>
 
 </html>

+ 1 - 0
docs/layouts/docs/list.html

@@ -1,5 +1,6 @@
 {{ define "main" }}
 <article class="markdown">
+    {{ partial "breadcrumbs" . }}
     {{- .Content -}}
     {{ $list := .Sections }}
     {{ $list = $list | append .Pages }}

+ 3 - 2
docs/layouts/docs/single.html

@@ -1,9 +1,10 @@
 {{ define "main" }}
 <article class="markdown">
-  {{- .Content -}}
+    {{ partial "breadcrumbs" . }}
+    {{- .Content -}}
 </article>
 {{ end }}
 
 {{ define "toc" }}
-  {{ partial "docs/toc" . }}
+{{ partial "docs/toc" . }}
 {{ end }}

+ 47 - 0
docs/layouts/partials/breadcrumbs.html

@@ -0,0 +1,47 @@
+<!--
+<div role="navigation" aria-label="breadcrumbs navigation">
+    {{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" }}
+    {{ $.Scratch.Add "path" .Site.BaseURL }}
+    {{ $.Scratch.Add "currentURL" .URL }}
+    {{ $pageNotFound := (eq (replace $.Site.BaseURL .Site.BaseURL "404.html") .URL) }}
+    <ul class="breadcrumbs">
+        {{ range $index, $element := split $url "/" }}
+        {{ $.Scratch.Add "path" $element }}
+        {{ $.Scratch.Add "path" "/" }}
+        &lt;!&ndash; Check if the current list item is the last one &ndash;&gt;
+        {{ $isLast := eq ($.Scratch.Get "path") $.Permalink }}
+
+        {{ if ne $element "" }}
+        {{ if and (not $isLast) (not $pageNotFound) }}
+        <li><a href='{{ $.Scratch.Get "path" }}'>{{ title ( replace . "-" " ") }}</a> &rsaquo;</li>
+        {{ else if $pageNotFound }}
+        <li>404</li>
+        {{ else }}
+        <li>{{ $.Title }}</li>
+        {{ end }}
+        {{ end }}
+        {{ end }}
+    </ul>
+</div>
+-->
+
+<ul class="breadcrumbs">
+    {{ template "breadcrumb" dict "currentPage" .Page "id" .UniqueID }}
+</ul>
+
+<!-- templates -->
+{{ define "breadcrumb" }}
+    {{ if .currentPage.Parent }}
+        {{ template "breadcrumb" dict "currentPage" .currentPage.Parent }}
+    {{ end }}
+    {{ $title := cond (eq .currentPage.RelPermalink "/docs/" ) "Docs" .currentPage.Title }}
+    {{ if (ne .currentPage.Parent .IsHome) }}
+        <li>
+            {{ if eq .id .currentPage.UniqueID }}
+                {{ $title }}
+            {{ else }}
+                <a href="{{ .currentPage.RelPermalink  }}">{{ $title }}</a>
+            {{ end }}
+        </li>
+    {{ end }}
+{{ end }}