From 12d8926b3824af5d2044e55f0107bce6c346a356 Mon Sep 17 00:00:00 2001
From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com>
Date: Tue, 22 Aug 2023 22:58:51 +0100
Subject: [PATCH 01/21] Algolia tutorials page test
---
assets/scss/_styles_project.scss | 71 +++++++++++++++++++
config.toml | 12 +++-
docs/tutorials/_index.md | 74 +------------------
docs/tutorials/template.md | 5 +-
layouts/_default/_markup/render-image.html | 2 +-
layouts/_default/list.algolia.json | 37 ++++++++++
layouts/docs/tutorials.html | 49 +++++++++++++
layouts/partials/imgproc.html | 4 +-
static/js/tutorials.js | 82 ++++++++++++++++++++++
9 files changed, 259 insertions(+), 77 deletions(-)
create mode 100644 layouts/_default/list.algolia.json
create mode 100644 layouts/docs/tutorials.html
create mode 100644 static/js/tutorials.js
diff --git a/assets/scss/_styles_project.scss b/assets/scss/_styles_project.scss
index 40e701aae7..35e70d5f78 100644
--- a/assets/scss/_styles_project.scss
+++ b/assets/scss/_styles_project.scss
@@ -566,6 +566,7 @@ END MARKETING CSS
.hover-card.tutorial > a {
width: 100%;
+ text-decoration: none;
}
// Text is black
@@ -1130,3 +1131,73 @@ ul.sectionlist > li:hover {
padding: 0;
font-size: 30px;
}
+
+// Tutorials page start
+
+.search-panel__results.card-container {
+ max-width: 100%;
+}
+
+.ais-Hits-item {
+ display: flex;
+}
+
+#hits .ais-Hits-list {
+ list-style-type: none;
+ display: flex;
+ flex-wrap: wrap;
+ width: 100%;
+}
+
+.ais-Pagination-item {
+ display: inline-block;
+ padding: 0.2rem 1rem;
+ margin: 0 0.2rem;
+ border: 1px solid black;
+}
+
+#pagination {
+ margin: 2rem auto;
+}
+
+.search-panel__filters {
+ margin-top: 2rem;
+}
+
+.ais-RefinementList-item {
+ list-style-type: none;
+}
+
+.ais-RefinementList-list {
+ padding: 0;
+}
+
+.ais-Panel-header {
+ font-size: 1.0625rem !important;
+ line-height: 1.4375em;
+ margin-bottom: 0.5rem;
+}
+
+.ais-RefinementList-count {
+ display: none;
+}
+
+.ais-Hits-list {
+ padding: 0;
+}
+
+.ais-RangeInput-label, .ais-RangeInput-separator {
+ margin-right: 0.1rem;
+}
+
+.ais-Pagination-link {
+ text-decoration: none;
+ color: black
+}
+
+.ais-Pagination-list {
+ text-align: center;
+ padding: 0;
+}
+
+// Tutorials page end
\ No newline at end of file
diff --git a/config.toml b/config.toml
index ef69a73780..8d0b9f859b 100644
--- a/config.toml
+++ b/config.toml
@@ -48,7 +48,13 @@ weight = 1
codeFences = true
[outputs]
-section = ["HTML"]
+section = ["HTML", "Algolia"]
+
+[outputFormats.Algolia]
+baseName = "algolia"
+isPlainText = true
+mediaType = "application/json"
+notAlternative = true
[params]
copyright = "Viam, Inc. - Documentation is licensed under Creative Commons ShareAlike License. "
@@ -133,6 +139,10 @@ enable = false
icon = "fa fa-envelope"
desc = "Ask questions about the Viam SDK"
+[params.algolia]
+vars = ["title", "summary", "date", "publishdate", "expirydate", "permalink", "image"]
+params = ["categories", "tags"]
+
[params.github]
repository = "viamrobotics/docs"
branch = "main"
diff --git a/docs/tutorials/_index.md b/docs/tutorials/_index.md
index 858dc3b38f..b210af441d 100644
--- a/docs/tutorials/_index.md
+++ b/docs/tutorials/_index.md
@@ -3,6 +3,7 @@ title: "Tutorials"
linkTitle: "Tutorials"
weight: 65
type: docs
+layout: "tutorials"
webmSrc: "/tutorials/videos/scuttle-gamepad-preview.webm"
mp4Src: "/tutorials/videos/scuttle-gamepad-preview.mp4"
videoAlt: "Drive a Scuttle robot with a Bluetooth gamepad."
@@ -13,75 +14,4 @@ sitemap:
priority: 1.0
aliases:
- "/build/"
----
-
-{{< alert title="Tip" color="tip" >}}
-While following a tutorial may require specific hardware, the hardware only affects the part of a project where you configure your components.
-If you are using different hardware your configuration will be different but you can still use the **same tutorial code**.
-
-For this reason, we list tutorials based on features you may be looking for.
-{{< /alert >}}
-
-## Your first robots
-
-{{< cards >}}
- {{% tutorialcard link="/tutorials/get-started/try-viam-sdk" %}}
- {{% tutorialcard link="/tutorials/get-started/blink-an-led/" %}}
- {{% tutorialcard link="/tutorials/get-started/servo-mousemover/" %}}
- {{% tutorialcard link="/tutorials/get-started/confetti-bot/" %}}
- {{% tutorialcard link="/tutorials/get-started/lazy-susan/" %}}
-{{< /cards >}}
-
-## Configuration and Testing
-
-{{< cards >}}
- {{% tutorialcard link="/tutorials/configure/build-a-mock-robot/" %}}
- {{% tutorialcard link="/tutorials/configure/scuttlebot/" %}}
-{{< /cards >}}
-
-## Controlling
-
-{{< cards >}}
- {{% tutorialcard link="/tutorials/control/scuttle-gamepad/" %}}
- {{% tutorialcard link="/tutorials/control/yahboom-rover/" %}}
-{{< /cards >}}
-
-## Services
-
-{{< cards >}}
- {{% tutorialcard link="/tutorials/services/accessing-and-moving-robot-arm/" %}}
- {{% tutorialcard link="/tutorials/services/plan-motion-with-arm-gripper/" %}}
- {{% tutorialcard link="/tutorials/services/constrain-motion/" %}}
- {{% tutorialcard link="/tutorials/services/data-management-tutorial/" %}}
- {{% tutorialcard link="/tutorials/services/try-viam-color-detection" %}}
- {{% tutorialcard link="/tutorials/services/color-detection-scuttle/" %}}
- {{% tutorialcard link="/tutorials/services/webcam-line-follower-robot/" %}}
-{{< /cards >}}
-
-## Custom Resources
-
-{{< cards >}}
- {{% tutorialcard link="/tutorials/custom/custom-base-dog/" %}}
- {{% tutorialcard link="/tutorials/custom/controlling-an-intermode-rover-canbus/" %}}
-{{< /cards >}}
-
-## Projects
-
-{{< cards >}}
- {{% tutorialcard link="/tutorials/projects/make-a-plant-watering-robot/" %}}
- {{% tutorialcard link="/tutorials/projects/foam-dart-launcher/" %}}
- {{% tutorialcard link="/tutorials/projects/light-up/" %}}
- {{% tutorialcard link="/tutorials/projects/send-security-photo/" %}}
- {{% tutorialcard link="/tutorials/projects/guardian/" %}}
- {{% tutorialcard link="/tutorials/projects/integrating-viam-with-openai/" %}}
- {{% tutorialcard link="/tutorials/projects/modernize-retro-robot/" %}}
- {{% tutorialcard link="/tutorials/projects/build-an-outdoor-rover/" %}}
- {{% tutorialcard link="/tutorials/projects/pet-treat-dispenser/" %}}
- {{% tutorialcard link="/tutorials/projects/tipsy/" %}}
- {{% tutorialcard link="/tutorials/projects/claw-game/" %}}
- {{% tutorialcard link="/tutorials/projects/bedtime-songs-bot/" %}}
-{{< /cards >}}
-
-
-
-Have questions, or want to meet other people working on robots? Join our [Community Discord](https://discord.gg/viam).
+---
\ No newline at end of file
diff --git a/docs/tutorials/template.md b/docs/tutorials/template.md
index 9634710cda..c074392a03 100644
--- a/docs/tutorials/template.md
+++ b/docs/tutorials/template.md
@@ -15,7 +15,10 @@ tags: ["tutorial"]
draft: true # Change this when you're ready
authors: [] # Your Name
languages: [] # Viam SDK programming languages used, if any
-viamresources: [] # Specific components or services used in this tutorial
+viamresources: [
+ "arm", "base", "board", "camera", "encoder", "gantry", "gripper", "input_controller", "motor", "movement_sensor", "sensor", "servo",
+ "data", "motion", "frame_system", "mlmodel", "navigation", "base_rc", "sensors", "slam", "vision"
+] # Specific components or services used in this tutorial
level: "" # Beginner, Intermediate, Advanced
# Beginner means: high level of explanation and guidance
# Intermediate means: commands/concepts you can assume the reader knows do not need to be explained, instead link.
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html
index 39bc8e4dfb..eac518bfc2 100644
--- a/layouts/_default/_markup/render-image.html
+++ b/layouts/_default/_markup/render-image.html
@@ -11,7 +11,7 @@
{{ $image_ext := index $image_type_arr 1 }}
{{ if eq $image_ext "svg" }}
- {{ warnf "Please use the imgproc shortcode for SVC images: %s" $image.RelPermalink }}
+ {{ warnf "Please use the imgproc shortcode for SVG images: %s" $image.RelPermalink }}
{{ else }}
{{ $webpsmall := $image.Resize "480x webp" }}
{{ $webpmedium := $image.Resize "768x webp" }}
diff --git a/layouts/_default/list.algolia.json b/layouts/_default/list.algolia.json
new file mode 100644
index 0000000000..91bc3be6aa
--- /dev/null
+++ b/layouts/_default/list.algolia.json
@@ -0,0 +1,37 @@
+{{- $.Scratch.Add "index" slice -}}
+{{- $section := $.Site.GetPage "section" .Section }}
+ {{- range .Site.AllPages -}}
+ {{- if or (and (.IsDescendant $section) (and (not .Draft) (and (not .Params.private) (not .Params.empty_node)))) $section.IsHome -}}
+ {{- $.Scratch.Add "index"
+ (dict
+ "objectID" .File.UniqueID
+ "date" .Date.UTC.Unix
+ "description" .Description
+ "expirydate" .ExpiryDate.UTC.Unix
+ "fuzzywordcount" .FuzzyWordCount
+ "lastmod" .Lastmod.UTC.Unix
+ "permalink" .Permalink
+ "publishdate" .PublishDate
+ "readingtime" .ReadingTime
+ "relpermalink" .RelPermalink
+ "title" .Title
+ "linktitle" .LinkTitle
+ "weight" .Weight
+ "wordcount" .WordCount
+ "section" .Section
+ "tags" .Params.Tags
+ "authors" .Params.Authors
+ "images" .Params.images
+ "webm" .Params.webmSrc
+ "mp4" .Params.mp4Src
+ "image" .Params.image
+ "languages" .Params.languages
+ "viamservices" (intersect (.Params.viamresources) (slice "data" "motion" "frame_system" "mlmodel" "navigation" "base_rc" "sensors" "slam" "vision"))
+ "viamcomponents" (intersect (.Params.viamresources) (slice "arm" "base" "board" "camera" "encoder" "gantry" "gripper" "input_controller" "motor" "movement_sensor" "sensor" "servo"))
+ "level" .Params.level
+ "cost" .Params.cost
+ "content" ( .Plain | safeHTML | truncate 8000 )
+ )}}
+ {{- end -}}
+ {{- end -}}
+{{- $.Scratch.Get "index" | jsonify -}}
\ No newline at end of file
diff --git a/layouts/docs/tutorials.html b/layouts/docs/tutorials.html
new file mode 100644
index 0000000000..0d985dc9e9
--- /dev/null
+++ b/layouts/docs/tutorials.html
@@ -0,0 +1,49 @@
+
+
+