From 35f5be26327fb74a8c27d57aafd3c429506c8fa4 Mon Sep 17 00:00:00 2001 From: Timur Osmanov <54434686+TOsmanov@users.noreply.github.com> Date: Mon, 30 Aug 2021 18:58:01 +0300 Subject: [PATCH] Improved documentation versioning (#3569) * add navbar-version-selector.html * update site/build_docs.py * update site/build_docs.py * update _index.html and fix mistakes in config.toml * fix _index.html * replace all tabs with spaces * update navbar-version-selector.html * fix link in the site/readme.md * replace tabs with spaces in custom.scss and 404.html * fix linter errors --- site/README.md | 2 +- site/build_docs.py | 3 +- site/config.toml | 2 +- site/content/en/_index.html | 2 + site/layouts/404.html | 14 ++--- site/layouts/partials/footer.html | 6 +- .../partials/navbar-version-selector.html | 11 ++++ site/layouts/partials/navbar.html | 62 +++++++++---------- 8 files changed, 58 insertions(+), 44 deletions(-) create mode 100644 site/layouts/partials/navbar-version-selector.html diff --git a/site/README.md b/site/README.md index c706e583..5e895393 100644 --- a/site/README.md +++ b/site/README.md @@ -44,7 +44,7 @@ To build and preview your site locally, use: cd /cvat/site/ hugo server -By default, your site will be available at . +By default, your site will be available at . Instead of a "hugo server" command, you can use the "hugo" command that generates the site into a "public" folder. diff --git a/site/build_docs.py b/site/build_docs.py index d649af46..37232b8f 100644 --- a/site/build_docs.py +++ b/site/build_docs.py @@ -54,7 +54,8 @@ def generate_docs(repo, output_dir, tags): generate_versioning_config(os.path.join(cwd, 'site', 'versioning.toml'), (t.name for t in tags), '/..') for tag in tags: - repo.git.checkout(tag.name) + repo.git.checkout(tag.name, '--', 'site/content/en/docs') + repo.git.checkout(tag.name, '--', 'site/content/en/images') destination_dir = os.path.join(output_dir, tag.name) os.makedirs(destination_dir) run_hugo(content_loc, destination_dir) diff --git a/site/config.toml b/site/config.toml index f0c55e78..b9f6f7ac 100644 --- a/site/config.toml +++ b/site/config.toml @@ -58,7 +58,7 @@ anchor = "smart" [services] [services.googleAnalytics] # Comment out the next line to disable GA tracking. Also disables the feature described in [params.ui.feedback]. -id = "UA-00000000-0" +# id = "UA-00000000-0" # Language configuration diff --git a/site/content/en/_index.html b/site/content/en/_index.html index 8c5fd7a3..1fe09b59 100644 --- a/site/content/en/_index.html +++ b/site/content/en/_index.html @@ -3,6 +3,8 @@ title = "Home" linkTitle = "Home" +++ + + {{< blocks/section height="full" color="docs" >}}
diff --git a/site/layouts/404.html b/site/layouts/404.html index 75f865fe..55f504f0 100644 --- a/site/layouts/404.html +++ b/site/layouts/404.html @@ -1,9 +1,9 @@ {{ define "main"}} -
-
-

404

-

Not found

-

Oops! This page doesn't exist. Try going back to our about page or documentation page.

-
-
+
+
+

404

+

Not found

+

Oops! This page doesn't exist. Try going back to our about page or documentation page.

+
+
{{ end }} diff --git a/site/layouts/partials/footer.html b/site/layouts/partials/footer.html index 61d283ba..53524702 100644 --- a/site/layouts/partials/footer.html +++ b/site/layouts/partials/footer.html @@ -26,9 +26,9 @@ - {{ if not .Site.Params.ui.footer_about_disable }} - {{ with .Site.GetPage "about" }}

{{ .Title }}

{{ end }} - {{ end }} + {{ if not .Site.Params.ui.footer_about_disable }} + {{ with .Site.GetPage "about" }}

{{ .Title }}

{{ end }} + {{ end }} diff --git a/site/layouts/partials/navbar-version-selector.html b/site/layouts/partials/navbar-version-selector.html new file mode 100644 index 00000000..619ca172 --- /dev/null +++ b/site/layouts/partials/navbar-version-selector.html @@ -0,0 +1,11 @@ +{{ $page_rel := .Page.RelPermalink | safeURL }} +{{ $page_rel_trim := strings.TrimLeft "/" $page_rel | safeURL }} + + diff --git a/site/layouts/partials/navbar.html b/site/layouts/partials/navbar.html index 54fccf7b..d8b5d580 100644 --- a/site/layouts/partials/navbar.html +++ b/site/layouts/partials/navbar.html @@ -1,35 +1,35 @@ {{ $cover := .HasShortcode "blocks/cover" }}