mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-03-20 16:15:09 +00:00
theme: add version selector #1050
This commit is contained in:
parent
bc0011fc05
commit
5ba09afb6c
53 changed files with 459 additions and 18 deletions
2
assets/_relearn_versionindex.js
Normal file
2
assets/_relearn_versionindex.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
{{- $versions := partialCached "_relearn/siteVersions.gotmpl" . -}}
|
||||
var relearn_versionindex = {{ $versions | jsonify (dict "indent" " ") }}
|
|
@ -1950,3 +1950,81 @@ function normalizeColor(c) {
|
|||
c = c.replace(/ +/g, ' ');
|
||||
return c;
|
||||
}
|
||||
|
||||
function initVersionIndex(index) {
|
||||
if (!index || !index.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
var select = document.querySelector('#R-select-version');
|
||||
if (!select) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remember the currently selected option
|
||||
var selectedOption = null;
|
||||
if (select.selectedIndex >= 0) {
|
||||
selectedOption = select.options[select.selectedIndex].cloneNode(true);
|
||||
}
|
||||
|
||||
// Remove all existing options
|
||||
while (select.firstChild) {
|
||||
select.removeChild(select.firstChild);
|
||||
}
|
||||
|
||||
// Add all options from the index
|
||||
index.forEach(function (version) {
|
||||
// Create new option element
|
||||
var option = document.createElement('option');
|
||||
option.id = 'R-select-version-' + version.value;
|
||||
option.value = version.value;
|
||||
option.dataset.abs = version.isAbs;
|
||||
option.dataset.uri = version.baseURL;
|
||||
option.dataset.identifier = version.identifier;
|
||||
option.textContent = version.title;
|
||||
|
||||
// Add the option to the select
|
||||
select.appendChild(option);
|
||||
});
|
||||
|
||||
// Re-select the previously selected option if it exists
|
||||
if (selectedOption) {
|
||||
for (var i = 0; i < select.options.length; i++) {
|
||||
if (select.options[i].dataset.identifier === selectedOption.dataset.identifier) {
|
||||
select.selectedIndex = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If the previously selected option doesn't exist, add it at the end
|
||||
select.appendChild(selectedOption);
|
||||
select.selectedIndex = select.options.length - 1;
|
||||
return;
|
||||
} else if (select.options.length > 0) {
|
||||
// If there was no selection before, select the first option
|
||||
select.selectedIndex = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function initVersionJs() {
|
||||
if (window.relearn.version_js_url) {
|
||||
var js = document.createElement('script');
|
||||
// we need to add a random number on each call to read this file fresh from the server;
|
||||
// it may reside in a different Hugo instance and therefore we do not know when it changes
|
||||
var url = new URL(window.relearn.version_js_url, window.location.href);
|
||||
var randomNum = Math.floor(Math.random() * 1000000);
|
||||
url.searchParams.set('v', randomNum.toString());
|
||||
js.src = url.toString();
|
||||
js.setAttribute('async', '');
|
||||
js.onload = function () {
|
||||
initVersionIndex(relearn_versionindex);
|
||||
};
|
||||
js.onerror = function (e) {
|
||||
console.error('Error getting version index file');
|
||||
};
|
||||
document.head.appendChild(js);
|
||||
}
|
||||
}
|
||||
|
||||
initVersionJs();
|
||||
|
|
|
@ -134,6 +134,40 @@ errorignore = []
|
|||
# See the docs how this works.
|
||||
# [relearn.dependencies]
|
||||
|
||||
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
# Versioning
|
||||
# These options control versioning of your site..
|
||||
|
||||
# Available verions
|
||||
# Default: not set
|
||||
# A list of version items that are available to the version switcher. Each item
|
||||
# can contain the following parameter:
|
||||
# - identifier: mandatory, not displayed
|
||||
# - title: mandatory, text, shown in the version swicher
|
||||
# - baseURL: mandatory, the base URL of that specific version
|
||||
# - isLateste: optional, but must be set exactly once in the set of items, marks
|
||||
# the latest version of the site, used to retrieve the index of available versions
|
||||
# during runtime for older sites.
|
||||
versions = ''
|
||||
|
||||
# Version identifier of this site
|
||||
# Default: not set
|
||||
# If versioning is configured, this is mandatory and must be one of the identifiers
|
||||
# from the `versions` array.
|
||||
version = 'v1.0'
|
||||
|
||||
# Hide deprecated version warning
|
||||
# Default: false
|
||||
# If you want to hide the deprecation warning, visible on all pages that to not
|
||||
# belong to the latest version of the site, set this to `true`.
|
||||
disableVersionWarning = false
|
||||
|
||||
# URL of the version index file relative to the language home.
|
||||
# Default: 'versionindex.js'
|
||||
# You have to set this option if your page already has a content file named
|
||||
# `versionindex.js` in the language home.
|
||||
versionIndexURL = 'versionindex.js'
|
||||
|
||||
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
# Topbar
|
||||
# These options modify the topbar appearance.
|
||||
|
@ -318,6 +352,7 @@ disableShortcutsTitle = false
|
|||
# all accept the `icon` parameter to overwrite the default icon
|
||||
# - languageswitcher: will display the language switcher
|
||||
# - variantswitcher: will display the variant switcher
|
||||
# - versionswitcher: will display the version switcher
|
||||
# - historyclearer: will display a button to clear the history of visited links
|
||||
|
||||
# The sidebar header menu.
|
||||
|
|
|
@ -190,6 +190,7 @@ collapsibleMenu = true
|
|||
# all accept the `icon` parameter to overwrite the default icon
|
||||
# - languageswitcher: will display the language switcher
|
||||
# - variantswitcher: will display the variant switcher
|
||||
# - versionswitcher: will display the version switcher
|
||||
# - historyclearer: will display a button to clear the history of visited links
|
||||
|
||||
# The sidebar header menu.
|
||||
|
|
|
@ -215,7 +215,7 @@ If you want to learn how to configure different Hugo menus for each language, [s
|
|||
|
||||
## Defining Sidebar Menus
|
||||
|
||||
{{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} Menus are defined for individual areas of the sidebar::
|
||||
{{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} Menus are defined for individual areas of the sidebar:
|
||||
|
||||
- `sidebarheadermenus`: the non-scrolling area below the search box
|
||||
- `sidebarmenus`: the scrolling area below the search box
|
||||
|
@ -227,6 +227,7 @@ If you don't set these options in your `hugo.toml`, the theme defaults as follow
|
|||
|
||||
- `sidebarheadermenus`:
|
||||
- a home button if [configured](configuration/sidebar/headerfooter#home-button-configuration), if you redefine this, use a Hugo menu and a `type=menu` to replicate this
|
||||
- the version switcher if versioning is [configured](configuration/sitemanagement/versioning)
|
||||
- a divider to separate from the `sidebarmenus` (depending on the configuration of the theme variant)
|
||||
- `sidebarmenus`:
|
||||
- the main page menu based on your [content structure](authoring/structure)
|
||||
|
@ -286,7 +287,7 @@ A HTML snippet has its own parameter. Your self-defined snippets can contain fur
|
|||
|
||||
| Name | Default | Notes |
|
||||
|-----------------------|-----------------|-------------|
|
||||
| **type** | _<empty>_ | The theme ships with the following snippets:<br><br>- `languageswitcher`: will display the language switcher<br>- `variantswitcher`: will display the variant switcher<br>- `historyclearer`: will display a button to clear the history of visited links |
|
||||
| **type** | _<empty>_ | The theme ships with the following snippets:<br><br>- `languageswitcher`: will display the language switcher<br>- `variantswitcher`: will display the variant switcher<br>- `versionswitcher`: will display the version switcher<br>- `historyclearer`: will display a button to clear the history of visited links |
|
||||
| **icon** | see notes | [Font Awesome icon name](shortcodes/icon#finding-an-icon) set to the left of the list entry. Depending on the **type** there is a default icon. Any given value will overwrite the default. |
|
||||
|
||||
### Divider
|
||||
|
@ -316,7 +317,6 @@ sidebarmenus = [
|
|||
sidebarfootermenus = []
|
||||
{{< /multiconfig >}}
|
||||
|
||||
|
||||
## Redefining Sidebar Menus for Certain Pages
|
||||
|
||||
Suppose you are building a site that contains a topmost `log` and `ship` section.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
categories = ["howto"]
|
||||
description = "Options for specific deployment needs"
|
||||
title = "Deployment Scenarios"
|
||||
weight = 4
|
||||
weight = 5
|
||||
+++
|
||||
|
||||
## Offline Usage
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
categories = ["howto"]
|
||||
description = "Options for specific deployment needs"
|
||||
title = "Deployment Scenarios"
|
||||
weight = 4
|
||||
weight = 5
|
||||
+++
|
||||
{{< piratify >}}
|
|
@ -4,7 +4,7 @@ description = "What site-wide meta information can be set"
|
|||
frontmatter = ["description"]
|
||||
options = ["author.email", "author.name"]
|
||||
title = "Meta Information"
|
||||
weight = 3
|
||||
weight = 4
|
||||
+++
|
||||
|
||||
## Site Author Information
|
||||
|
|
|
@ -4,6 +4,6 @@ description = "What site-wide meta information can be set"
|
|||
frontmatter = ["description"]
|
||||
options = ["author.email", "author.name"]
|
||||
title = "Meta Information"
|
||||
weight = 3
|
||||
weight = 4
|
||||
+++
|
||||
{{< piratify >}}
|
|
@ -3,7 +3,7 @@ categories = ["howto"]
|
|||
description = "What formats can a page be displayed in"
|
||||
outputs = ["html", "rss", "print", "markdown", "source"]
|
||||
title = "Available Output Formats"
|
||||
weight = 5
|
||||
weight = 6
|
||||
+++
|
||||
|
||||
The Relearn theme by default comes with templates for HTML and RSS for each page.
|
||||
|
|
|
@ -3,6 +3,6 @@ categories = ["howto"]
|
|||
description = "What formats can a page be displayed in"
|
||||
outputs = ["html", "rss", "print", "markdown", "source"]
|
||||
title = "Available Output Formats"
|
||||
weight = 5
|
||||
weight = 6
|
||||
+++
|
||||
{{< piratify >}}
|
|
@ -3,7 +3,7 @@ categories = ["howto"]
|
|||
description = "How to make your generated HTML output stable"
|
||||
options = ["disableAssetsBusting", "disableGeneratorVersion", "disableRandomIds", "minify"]
|
||||
title = "Stable Output"
|
||||
weight = 6
|
||||
weight = 7
|
||||
+++
|
||||
|
||||
## Disabling the Generator Meta
|
||||
|
|
|
@ -3,6 +3,6 @@ categories = ["howto"]
|
|||
description = "How to make your generated HTML output stable"
|
||||
options = ["disableAssetsBusting", "disableGeneratorVersion", "disableRandomIds", "minify"]
|
||||
title = "Stable Output"
|
||||
weight = 6
|
||||
weight = 7
|
||||
+++
|
||||
{{< piratify >}}
|
|
@ -0,0 +1,124 @@
|
|||
+++
|
||||
categories = ["howto"]
|
||||
description = "How to keep older versions of your site"
|
||||
options = ["disableVersionWarning", "version", "versionIndexURL", "versions"]
|
||||
title = "Versioning"
|
||||
weight = 3
|
||||
+++
|
||||
|
||||
{{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} The theme offers a way to version your site. This is useful if you want to keep older versions of your site available while also providing links to the current version. Each site version needs to be created separately and is functional independent of each other.
|
||||
|
||||
A version switcher will be displayed at the top of the sidebar if versioning is configured. If the user selects a different version, the theme will navigate to the actual page location but in the selected version. If this page does not exist in the selected version, the 404 page will be displayed.
|
||||
|
||||
If you want to have more control, where the version switcher is positioned or you want to configure a different icon, see the [chapter on sidebar configuration](configuration/sidebar/menus#defining-sidebar-menus).
|
||||
|
||||
## Example: Versioning an Existing Site
|
||||
|
||||
Assume, you are writing a documentation for an app. At some point you are a releasing a new major version. This new version requires enhanced documentation while the older documentation must still be available for users of the older app version.
|
||||
|
||||
This is your intial `hugo.toml` file:
|
||||
|
||||
{{< multiconfig file=hugo >}}
|
||||
baseURL = 'https://example.com/'
|
||||
{{< /multiconfig >}}
|
||||
|
||||
To setup versioning, you have to do the following steps:
|
||||
|
||||
1. Prepare your old site for versioning.
|
||||
- add an array of all available `versions` to your `hugo.toml`
|
||||
- add information, which of these versions is the latest by setting the `isLatest` option on **one** item in the `versions` array
|
||||
- add information, which of these versions your site actually is, by setting the `version` option
|
||||
- change your `baseURL` to the version specific URL
|
||||
{{< multiconfig file=hugo >}}
|
||||
baseURL = 'https://example.com/v1.0/'
|
||||
params = { version = 'v1.0', versions = [
|
||||
{ identifier = 'v2.0', title = 'Latest', baseURL = 'https://example.com/', isLatest = true },
|
||||
{ identifier = 'v1.0', title = 'v1.0', baseURL = 'https://example.com/v1.0/' }
|
||||
]}
|
||||
{{< /multiconfig >}}
|
||||
2. Generate your old site into the `baseURL` (in our case `https://example.com/v1.0/`)
|
||||
3. Copy you Hugo project into a new directory
|
||||
4. Make changes to the documentation for the new version
|
||||
5. Prepare your new site for release.
|
||||
- leave the previously set array of available `versions` as is
|
||||
- change the information, which of the versions your site actually is, by setting the `version` option
|
||||
- change your `baseURL` back to the original URL
|
||||
{{< multiconfig file=hugo >}}
|
||||
baseURL = 'https://example.com/'
|
||||
params = { version = 'v2.0', versions = [
|
||||
{ identifier = 'v2.0', title = 'Latest', baseURL = 'https://example.com/', isLatest = true },
|
||||
{ identifier = 'v1.0', title = 'v1.0', baseURL = 'https://example.com/v1.0/' }
|
||||
]}
|
||||
{{< /multiconfig >}}
|
||||
6. Generate your new site to the chosen location (in our case `https://example.com/`)
|
||||
|
||||
A few things to note here:
|
||||
|
||||
- `version` must be an `identifier` of one of the entries in the `versions` array
|
||||
- you are not limited with the `baseURL`, these can be absolute or relative to your server root
|
||||
- you can generate your old versions into the directory of the new version
|
||||
|
||||
## Example: Add New Versions to a Versioned Site
|
||||
|
||||
At some point, your version 2 of the app may be deprecated, too, as you've released a new version 3.
|
||||
|
||||
You only need to create two versions of your site, the former current one and the new current one.
|
||||
|
||||
1. Prepare your old site.
|
||||
- add the new version to the array of available `versions` in your `hugo.toml`
|
||||
- revise information, which of these versions is the latest by setting the `isLatest` option on **one** item in the `versions` array
|
||||
- change your `baseURL` to the version specific URL
|
||||
{{< multiconfig file=hugo >}}
|
||||
baseURL = 'https://example.com/v2.0/'
|
||||
params = { version = 'v2.0', versions = [
|
||||
{ identifier = 'v3.0', title = 'Latest', baseURL = 'https://example.com/', isLatest = true },
|
||||
{ identifier = 'v2.0', title = 'v2.0', baseURL = 'https://example.com/v2.0/' },
|
||||
{ identifier = 'v1.0', title = 'v1.0', baseURL = 'https://example.com/v1.0/' }
|
||||
]}
|
||||
{{< /multiconfig >}}
|
||||
2. Generate your old site into the `baseURL` (in our case `https://example.com/v2.0/`)
|
||||
3. Copy you Hugo project into a new directory
|
||||
4. Make changes to the documentation for the new version
|
||||
5. Prepare your new site for release.
|
||||
- leave the previously set array of available `versions` as is
|
||||
- change the information, which of the versions your site actually is, by setting the `version` option
|
||||
- change your `baseURL` back to the original URL
|
||||
{{< multiconfig file=hugo >}}
|
||||
baseURL = 'https://example.com/'
|
||||
params = { version = 'v3.0', versions = [
|
||||
{ identifier = 'v3.0', title = 'Latest', baseURL = 'https://example.com/', isLatest = true },
|
||||
{ identifier = 'v2.0', title = 'v2.0', baseURL = 'https://example.com/v2.0/' },
|
||||
{ identifier = 'v1.0', title = 'v1.0', baseURL = 'https://example.com/v1.0/' }
|
||||
]}
|
||||
{{< /multiconfig >}}
|
||||
6. Generate your new site to the chosen location (in our case `https://example.com/`)
|
||||
|
||||
A few things to note here:
|
||||
|
||||
- you **don't need to recreate version 1** of your site as long as the `baseURL` for the entry marked with `isLatest=true` hasn't changed. The old versions will access the version index of the latest site to display all available versions in the version switcher
|
||||
|
||||
## Hiding the Deprecation Warning
|
||||
|
||||
{{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} If visitors navigate to an old version of your site, they will see a deprecation warning at the top of each page.
|
||||
|
||||
You can disable it be setting the `disableVersionWarning` option to `true` in your `hugo.toml`.
|
||||
|
||||
{{< multiconfig file=hugo >}}
|
||||
[params]
|
||||
disableVersionWarning = true
|
||||
{{< /multiconfig >}}
|
||||
|
||||
## Change URL of the Version Index
|
||||
|
||||
{{%badge style="cyan" icon="gears" title=" "%}}Option{{%/badge%}} The default URL for the version index can be changed with the `versionIndexURL` parameter
|
||||
|
||||
{{< multiconfig file=hugo >}}
|
||||
[params]
|
||||
versionIndexURL = 'myversionindex.js'
|
||||
{{< /multiconfig >}}
|
||||
|
||||
{{% notice note %}}
|
||||
You only need to change these if you have other own content created for those URLs.
|
||||
|
||||
Check for duplicate URLs by running `hugo --printPathWarnings`.
|
||||
{{% /notice %}}
|
|
@ -0,0 +1,8 @@
|
|||
+++
|
||||
categories = ["howto"]
|
||||
description = "How to keep older versions of your site"
|
||||
options = ["disableVersionWarning", "version", "versionIndexURL", "versions"]
|
||||
title = "Versioning"
|
||||
weight = 3
|
||||
+++
|
||||
{{< piratify >}}
|
|
@ -10,6 +10,8 @@ weight = -6
|
|||
|
||||
### New
|
||||
|
||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The theme [supports versioning](configuration/sitemanagement/versioning) now, were you can keep older versions of your site while showing a version switcher at the top of the menu.
|
||||
|
||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The menu configuration for the main menu area, [introduced in 7.1.0](introduction/releasenotes/7/1), is extended to the non-scrolling menu header area between search box and main scrolling area using the `sidebarheadermenus` option and to the menu footer area using the `sidebarfootermenus` option.
|
||||
|
||||
The [configuration for all sidebar menus](/configuration/sidebar/menus#defining-sidebar-menus) is similar and now comes with two new types of menus.
|
||||
|
@ -20,6 +22,7 @@ weight = -6
|
|||
|
||||
- `languageswitcher`: will display the language switcher
|
||||
- `variantswitcher`: will display the variant switcher
|
||||
- `versionswitcher`: will display the version switcher
|
||||
- `historyclearer`: will display a button to clear the history of visited links
|
||||
|
||||
You don’t need to change anything in your existing installation as the old configuration is used as a default.
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'You are reading version {{.version}} of this page. The current version can be found <a href="{{.latestUrl}}">here</a>'
|
||||
|
||||
[Search]
|
||||
other = "Searrrch"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'You are reading version {{.version}} of this page. The current version can be found <a href="{{.latestUrl}}">here</a>'
|
||||
|
||||
[Search]
|
||||
other = "Searrrch"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "rtl"
|
||||
|
||||
[Version-warning]
|
||||
other = 'أنت تقرأ الإصدار {{.version}} من هذه الصفحة. يمكن العثور على الإصدار الحالي <a href="{{.latestUrl}}">هنا</a>'
|
||||
|
||||
[Search]
|
||||
other = "البحث"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'Právě si prohlížíte verzi {{.version}} této stránky. Aktuální verzi naleznete <a href="{{.latestUrl}}">tady</a>'
|
||||
|
||||
[Search]
|
||||
other = "Hledat"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'Du liest gerade die Version {{.version}} dieser Seite. Die aktuelle Version finden Sie <a href="{{.latestUrl}}">hier</a>'
|
||||
|
||||
[Search]
|
||||
other = "Suchen"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'You are reading version {{.version}} of this page. The current version can be found <a href="{{.latestUrl}}">here</a>'
|
||||
|
||||
[Search]
|
||||
other = "Search"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'Estás leyendo la versión {{.version}} de esta página. La versión actual se puede encontrar <a href="{{.latestUrl}}">aquí</a>'
|
||||
|
||||
[Search]
|
||||
other = "Buscar"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "rtl"
|
||||
|
||||
[Version-warning]
|
||||
other = 'شما در حال خواندن نسخه {{.version}} این صفحه هستید. نسخه فعلی را می توان یافت <a href="{{.latestUrl}}">اینجا</a>'
|
||||
|
||||
[Search]
|
||||
other = "جستجو"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'Luet tämän sivun versiota {{.version}}. Nykyinen versio löytyy <a href="{{.latestUrl}}">täällä</a>'
|
||||
|
||||
[Search]
|
||||
other = "Etsi"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'Vous êtes en train de lire la version {{.version}} de cette page. La version actuelle peut être trouvée <a href="{{.latestUrl}}">ici</a>'
|
||||
|
||||
[Search]
|
||||
other = "Rechercher"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'आप इस पृष्ठ का संस्करण {{.version}} पढ़ रहे हैं। वर्तमान संस्करण पाया जा सकता है <a href="{{.latestUrl}}">यहाँ</a>'
|
||||
|
||||
[Search]
|
||||
other = "खोजे"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'A lap {{.version}} verzióját olvasod. Az aktuális verzió megtalálható <a href="{{.latestUrl}}">itt</a>'
|
||||
|
||||
[Search]
|
||||
other = "Keresés"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'Anda sedang membaca versi {{.version}} dari halaman ini. Versi saat ini dapat ditemukan <a href="{{.latestUrl}}">sini</a>'
|
||||
|
||||
[Search]
|
||||
other = "Telusuri"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'Stai leggendo la versione {{.version}} di questa pagina. La versione attuale può essere trovata <a href="{{.latestUrl}}">qui</a>'
|
||||
|
||||
[Search]
|
||||
other = "Cerca"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'このページのバージョン{{.version}}を読んでいます。現在のバージョンを見つけることができます<a href="{{.latestUrl}}">ここは</a>'
|
||||
|
||||
[Search]
|
||||
other = "検索"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = '이 페이지의 {{.version}} 버전을 읽고 계십니다. 현재 버전을 찾을 수 있습니다 <a href="{{.latestUrl}}">여기</a>'
|
||||
|
||||
[Search]
|
||||
other = "검색"
|
||||
|
||||
|
@ -83,15 +86,12 @@ other = "주의"
|
|||
other = "중요"
|
||||
|
||||
[info]
|
||||
# 예제 내용상 learn theme 참고 용도로 사용되어 위와 같이 번역합니다.
|
||||
other = "참고"
|
||||
|
||||
[note]
|
||||
# code snippent 내의 comment(주석)과의 혼동 방지를 위해 위와 같이 번역합니다.
|
||||
other = "주"
|
||||
|
||||
[tip]
|
||||
# 우리말 순화어로 기록 가능하고, note, info와 의미상 좀 더 명확한 구분이 되어 아래처럼 기록합니다.
|
||||
other = "도움말"
|
||||
|
||||
[warning]
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'U leest versie {{.version}} van deze pagina. De huidige versie is te vinden <a href="{{.latestUrl}}">hier</a>'
|
||||
|
||||
[Search]
|
||||
other = "Zoeken"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'Czytasz wersję {{.version}} tej strony. Aktualną wersję można znaleźć <a href="{{.latestUrl}}">tu</a>'
|
||||
|
||||
[Search]
|
||||
other = "Szukaj"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'Você está lendo a versão {{.version}} desta página. A versão atual pode ser encontrada <a href="{{.latestUrl}}">aqui</a>'
|
||||
|
||||
[Search]
|
||||
other = "Procurar"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'Citiți versiunea {{.version}} a acestei pagini. Versiunea curentă poate fi găsită <a href="{{.latestUrl}}">aici</a>'
|
||||
|
||||
[Search]
|
||||
other = "Caută"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'Вы читаете версию {{.version}} этой страницы. Актуальную версию можно найти <a href="{{.latestUrl}}">здесь</a>'
|
||||
|
||||
[Search]
|
||||
other = "Поиск"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'Unasoma toleo {{.version}} la ukurasa huu. Toleo la sasa linaweza kupatikana <a href="{{.latestUrl}}">hapa</a>'
|
||||
|
||||
[Search]
|
||||
other = "Tafuta"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'Bu sayfanın {{.version}} sürümünü okuyorsunuz. Güncel sürüm bulunabilir <a href="{{.latestUrl}}">burada</a>'
|
||||
|
||||
[Search]
|
||||
other = "Ara"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'Ви читаєте версію {{.version}} цієї сторінки. Актуальну версію можна знайти <a href="{{.latestUrl}}">тут</a>'
|
||||
|
||||
[Search]
|
||||
other = "Пошук"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = 'Bạn đang đọc phiên bản {{.version}} của trang này. Phiên bản hiện tại có thể được tìm thấy <a href="{{.latestUrl}}">Ở đây</a>'
|
||||
|
||||
[Search]
|
||||
other = "Tìm kiếm"
|
||||
|
||||
|
@ -67,9 +70,6 @@ other = "Menu"
|
|||
[Toc-toggle]
|
||||
other = "Mục lục"
|
||||
|
||||
[BinaryPrefix-kilobyte]
|
||||
other = "kb"
|
||||
|
||||
[Byte-symbol]
|
||||
other = "B"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = '您正在阅读此页面的 {{.version}} 版本。可以找到当前版本<a href="{{.latestUrl}}">这里</a>'
|
||||
|
||||
[Search]
|
||||
other = "搜索"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = '您正在阅读此页面的 {{.version}} 版本。可以找到当前版本<a href="{{.latestUrl}}">这里</a>'
|
||||
|
||||
[Search]
|
||||
other = "搜索"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = '您正在閱讀此頁面的 {{.version}} 版本。可以找到當前版本<a href="{{.latestUrl}}">這裡</a>'
|
||||
|
||||
[Search]
|
||||
other = "搜尋"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = '您正在閱讀此頁面的 {{.version}} 版本。可以找到當前版本<a href="{{.latestUrl}}">這裡</a>'
|
||||
|
||||
[Search]
|
||||
other = "搜尋"
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[Reading-direction]
|
||||
other = "ltr"
|
||||
|
||||
[Version-warning]
|
||||
other = '您正在阅读此页面的 {{.version}} 版本。可以找到当前版本<a href="{{.latestUrl}}">这里</a>'
|
||||
|
||||
[Search]
|
||||
other = "搜索"
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{{- $defaultmenuconfigs := slice }}
|
||||
{{- $defaultconfigelements := slice }}
|
||||
|
||||
{{- if not site.Params.disableLandingPageButton }}
|
||||
{{- if (ne site.Params.landingPageURL nil) }}
|
||||
{{- warnf "UNSUPPORTED usage of 'landingPageURL' config parameter found, remove it and optionally overwrite the `logo.html` partial to provide a link if it should not point to the project's home page; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/4/#4-2-0" }}
|
||||
|
@ -23,5 +25,17 @@
|
|||
))
|
||||
}}
|
||||
{{- end }}
|
||||
|
||||
{{- $versions := partialCached "_relearn/siteVersions.gotmpl" . }}
|
||||
{{- if $versions }}
|
||||
{{- $defaultconfigelements = $defaultconfigelements | append (dict "type" "versionswitcher") }}
|
||||
{{- end }}
|
||||
|
||||
{{- if $defaultconfigelements }}
|
||||
{{- $defaultmenuconfigs = $defaultmenuconfigs | append
|
||||
(dict "type" "custom" "identifier" "controls" "disableTitle" true "elements" $defaultconfigelements)
|
||||
}}
|
||||
{{- end }}
|
||||
|
||||
{{- $defaultmenuconfigs = $defaultmenuconfigs | append (dict "type" "divider") }}
|
||||
{{- return $defaultmenuconfigs }}
|
11
layouts/partials/_relearn/siteVersions.gotmpl
Normal file
11
layouts/partials/_relearn/siteVersions.gotmpl
Normal file
|
@ -0,0 +1,11 @@
|
|||
{{- $versions := slice }}
|
||||
{{- range site.Params.versions | default slice }}
|
||||
{{- $version := . }}
|
||||
{{- $isAbs := (urls.Parse .baseURL).IsAbs }}
|
||||
{{- $url := trim .baseURL "/" }}
|
||||
{{- $version = merge $version (dict "isAbs" $isAbs) }}
|
||||
{{- $version = merge $version (dict "value" (.identifier | anchorize)) }}
|
||||
{{- $version = merge $version (dict "baseURL" (cond (or $isAbs (not $url)) $url (print "/" $url))) }}
|
||||
{{- $versions = $versions | append $version }}
|
||||
{{- end -}}
|
||||
{{- return $versions }}
|
|
@ -1,4 +1,5 @@
|
|||
{{/* the following check avoids to print out content of headless bundles if called from nestedContent.gotmpl */}}
|
||||
{{- if .RelPermalink }}
|
||||
{{- partial "content-lead.html" . | safeHTML }}
|
||||
{{- partial "content.html" . | safeHTML }}
|
||||
{{- end }}
|
35
layouts/partials/content-lead.html
Normal file
35
layouts/partials/content-lead.html
Normal file
|
@ -0,0 +1,35 @@
|
|||
{{- $versions := partialCached "_relearn/siteVersions.gotmpl" . }}
|
||||
{{- $pageVersion := site.Params.version | default "" }}
|
||||
{{- if and $versions (not $pageVersion) }}
|
||||
{{- warnf "WARNING you have configured `versions` but did not mark this site with a `version`; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/7/#7-6-0" }}
|
||||
{{- end }}
|
||||
{{- $latestVersion := "" }}
|
||||
{{- with (where $versions "isLatest" true | first 1) }}
|
||||
{{- range . }}
|
||||
{{- $latestVersion = . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with (where $versions "identifier" $pageVersion | first 1) }}
|
||||
{{- range . }}
|
||||
{{- $pageVersion = . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if and
|
||||
(not (site.Params.disableVersionWarning | default .Params.disableVersionWarning))
|
||||
(eq (.Store.Get "relearnOutputFormat") "html")
|
||||
$pageVersion
|
||||
$latestVersion
|
||||
(ne $pageVersion.identifier $latestVersion.identifier)
|
||||
}}
|
||||
{{- $url := print $latestVersion.baseURL (partial "permalink.gotmpl" (dict "to" .)) }}
|
||||
{{- if not $latestVersion.isAbs }}
|
||||
{{- $url = print (partial "_relearn/relBaseUri.gotmpl" .) $url }}
|
||||
{{- end }}
|
||||
{{- partial "shortcodes/notice.html" (dict
|
||||
"page" .
|
||||
"content" (T "Version-warning" (dict "version" $pageVersion.title "latestUrl" $url ))
|
||||
"icon" " "
|
||||
"style" "warning"
|
||||
"title" " "
|
||||
) }}
|
||||
{{- end }}
|
24
layouts/partials/sidebar/element/versionswitcher.html
Normal file
24
layouts/partials/sidebar/element/versionswitcher.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
{{- $versions := partialCached "_relearn/siteVersions.gotmpl" .page }}
|
||||
{{- $pageVersion := site.Params.version | default "" }}
|
||||
{{- $icon := .element.icon | default "code-branch" }}
|
||||
{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }}
|
||||
{{- $icon = printf "fa-fw fas fa-%s" $icon }}
|
||||
{{- end }}
|
||||
<li class="R-versionswitcher">
|
||||
<div class="padding menu-control">
|
||||
<i class="{{ $icon }}"></i>
|
||||
<span> </span>
|
||||
<div class="control-style">
|
||||
<label class="a11y-only" for="R-select-version">{{ T "Version" }}</label>
|
||||
<select id="R-select-version" onchange="location = this.querySelector( `#R-select-version-${this.value}` ).dataset.abs == 'true' ?
|
||||
this.querySelector( `#R-select-version-${this.value}` ).dataset.uri + window.relearn.path :
|
||||
window.relearn.relBaseUri + this.querySelector( `#R-select-version-${this.value}` ).dataset.uri + window.relearn.path;"
|
||||
>
|
||||
{{- range $versions }}
|
||||
<option id="R-select-version-{{ .identifier | anchorize }}" value="{{ .identifier | anchorize }}" data-identifier="{{ .identifier }}" data-abs="{{ .isAbs }}" data-uri="{{ .baseURL }}"{{ if eq $pageVersion .identifier }} selected{{ end }}>{{ .title }}</option>
|
||||
{{- end }}
|
||||
</select>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</li>
|
|
@ -33,6 +33,7 @@
|
|||
{{- $pageBaseLang := replaceRE "([a-z]+).*" "${1}" .Page.Language.LanguageCode }}
|
||||
{{- $contentlangs := (union (slice | append (site.Params.additionalContentLanguage | default slice)) (slice $pageBaseLang)) }}
|
||||
{{- $quotedcontentlangs := slice }}
|
||||
{{- $versionIndexUrl := "" }}
|
||||
{{- $searchIndexUrl := "" }}
|
||||
<link href="{{(printf "css/theme%s.css" $min) | relURL}}{{ $assetBusting }}" rel="stylesheet">
|
||||
<link href="{{(printf "css/format-%s%s.css" $outputFormat $min) | relURL}}{{ $assetBusting }}" rel="stylesheet" id="R-format-style">
|
||||
|
@ -43,6 +44,22 @@
|
|||
{{- with resources.Get "/js/auto-complete/auto-complete.js" }}
|
||||
<script src="{{ (. | minify).RelPermalink }}{{ $assetBusting }}" defer></script>
|
||||
{{- end }}
|
||||
{{- $versions := partialCached "_relearn/siteVersions.gotmpl" . }}
|
||||
{{- if $versions }}
|
||||
{{- $versionIndexUrl = trim (or .Site.Params.versionIndexURL "versionindex.js") "/" }}
|
||||
{{- $versionIndexUrl = path.Join (path.Dir $versionIndexUrl) (print (path.BaseName $versionIndexUrl) "." site.Language.Lang (path.Ext $versionIndexUrl)) }}
|
||||
{{- if .IsHome }}
|
||||
{{- $templateres := resources.Get "/_relearn_versionindex.js" }}
|
||||
{{- $resultres := $templateres | resources.ExecuteAsTemplate $versionIndexUrl site.Home }}
|
||||
{{- /* the following code causes Hugo to generate our file in public */}}
|
||||
{{- $url := $resultres.RelPermalink }}
|
||||
{{- end }}
|
||||
{{- with (where $versions "isLatest" true | first 1) }}
|
||||
{{- range . }}
|
||||
{{- $versionIndexUrl = path.Join .baseURL $versionIndexUrl }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if not .Site.Params.disableSearchIndex }}
|
||||
{{- $searchIndexUrl = trim (or .Site.Params.searchIndexURL "searchindex.js") "/" }}
|
||||
{{- $searchIndexUrl = path.Join (path.Dir $searchIndexUrl) (print (path.BaseName $searchIndexUrl) "." .Language.Lang (path.Ext $searchIndexUrl)) }}
|
||||
|
@ -101,6 +118,7 @@
|
|||
window.relearn = window.relearn || {};
|
||||
{{ "// configuration" | safeJS }}
|
||||
{{ printf "window.relearn.min = `%s`;" $min | safeJS }}
|
||||
window.relearn.path='{{ partial "permalink.gotmpl" (dict "to" .) | safeJS }}';
|
||||
window.relearn.relBasePath='{{ partial "_relearn/relBasePath.gotmpl" . | safeJS }}';
|
||||
window.relearn.relBaseUri='{{ partial "_relearn/relBaseUri.gotmpl" . | safeJS }}';
|
||||
window.relearn.absBaseUri='{{ replaceRE "/*$" "" .Site.BaseURL | safeJS }}';
|
||||
|
@ -108,6 +126,9 @@
|
|||
{{- if $searchIndexUrl }}
|
||||
window.relearn.index_js_url={{ (printf "%s%s" $searchIndexUrl $assetBusting) | relURL }};
|
||||
{{- end }}
|
||||
{{- if $versionIndexUrl }}
|
||||
window.relearn.version_js_url={{ (printf "%s%s" $versionIndexUrl $assetBusting) | relURL }};
|
||||
{{- end }}
|
||||
window.relearn.disableAnchorCopy={{ printf "%t" (eq .Site.Params.disableAnchorCopy true) | safeJS }};
|
||||
window.relearn.disableAnchorScrolling={{ printf "%t" (eq .Site.Params.disableAnchorScrolling true) | safeJS }};
|
||||
window.relearn.disableInlineCopyToClipboard={{ printf "%t" (eq $disableInlineCopyToClipboard true) | safeJS }};
|
||||
|
|
|
@ -1 +1 @@
|
|||
7.5.0+b89d1e3fb63c72c28f83bda3ef08bdca7723066c
|
||||
7.5.0+bc0011fc05abbd9f079145b753dab4fa6b823077
|
Loading…
Add table
Reference in a new issue