mirror of
https://github.com/imfing/hextra.git
synced 2025-07-02 16:07:57 -04:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
14036ffea6 | |||
a1232ecf9f | |||
a933f464f5 |
@ -195,8 +195,19 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
*/
|
*/
|
||||||
async function preloadIndex() {
|
async function preloadIndex() {
|
||||||
const tokenize = '{{- site.Params.search.flexsearch.tokenize | default "forward" -}}';
|
const tokenize = '{{- site.Params.search.flexsearch.tokenize | default "forward" -}}';
|
||||||
|
|
||||||
|
const isCJK = () => {
|
||||||
|
const lang = document.documentElement.lang || "en";
|
||||||
|
return lang.startsWith("zh") || lang.startsWith("ja") || lang.startsWith("ko");
|
||||||
|
}
|
||||||
|
|
||||||
|
const encodeCJK = (str) => str.replace(/[\x00-\x7F]/g, "").split("");
|
||||||
|
const encodeDefault = (str) => (""+str).toLocaleLowerCase().split(/[\p{Z}\p{S}\p{P}\p{C}]+/u);
|
||||||
|
const encodeFunction = isCJK() ? encodeCJK : encodeDefault;
|
||||||
|
|
||||||
window.pageIndex = new FlexSearch.Document({
|
window.pageIndex = new FlexSearch.Document({
|
||||||
tokenize,
|
tokenize,
|
||||||
|
encode: encodeFunction,
|
||||||
cache: 100,
|
cache: 100,
|
||||||
document: {
|
document: {
|
||||||
id: 'id',
|
id: 'id',
|
||||||
@ -207,6 +218,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
|
|
||||||
window.sectionIndex = new FlexSearch.Document({
|
window.sectionIndex = new FlexSearch.Document({
|
||||||
tokenize,
|
tokenize,
|
||||||
|
encode: encodeFunction,
|
||||||
cache: 100,
|
cache: 100,
|
||||||
document: {
|
document: {
|
||||||
id: 'id',
|
id: 'id',
|
||||||
|
@ -195,7 +195,7 @@ You can add extra section in the footer by creating a file `layouts/partials/cus
|
|||||||
The added section will be added before the copyright section in the footer.
|
The added section will be added before the copyright section in the footer.
|
||||||
You can use [HTML](https://developer.mozilla.org/en-US/docs/Web/HTML) and [Hugo template syntax](https://gohugo.io/templates/) to add your own content.
|
You can use [HTML](https://developer.mozilla.org/en-US/docs/Web/HTML) and [Hugo template syntax](https://gohugo.io/templates/) to add your own content.
|
||||||
|
|
||||||
Hugo variables available in the footer section are: `.switchesVisible` and `.copyrightVisible`.
|
Hugo variables available in the footer section are: `.switchesVisible` and `.displayCopyright`.
|
||||||
|
|
||||||
## Custom Layouts
|
## Custom Layouts
|
||||||
|
|
||||||
|
@ -15,16 +15,21 @@
|
|||||||
{{- $options := .Get "options" | default "800x webp q80" -}}
|
{{- $options := .Get "options" | default "800x webp q80" -}}
|
||||||
{{- $process := .Get "process" | default (printf "%s %s" $method $options) -}}
|
{{- $process := .Get "process" | default (printf "%s %s" $method $options) -}}
|
||||||
|
|
||||||
{{- with or (.Page.Resources.Get $image) (resources.Get $image) -}}
|
{{- if and $image (not (urls.Parse $image).Scheme) -}}
|
||||||
{{/* Retrieve the $image resource from local or global resources */}}
|
{{- with or (.Page.Resources.Get $image) (resources.Get $image) -}}
|
||||||
{{- $processed := .Process $process -}}
|
{{/* .Process does not work on svgs */}}
|
||||||
{{- $width = $processed.Width -}}
|
{{- if (not (eq .MediaType.SubType "svg")) -}}
|
||||||
{{- $height = $processed.Height -}}
|
{{/* Retrieve the $image resource from local or global resources */}}
|
||||||
{{- $image = $processed.RelPermalink -}}
|
{{- $processed := .Process $process -}}
|
||||||
{{ else }}
|
{{- $width = $processed.Width -}}
|
||||||
{{/* Otherwise, use relative link of the image */}}
|
{{- $height = $processed.Height -}}
|
||||||
{{- if hasPrefix $image "/" -}}
|
{{- $image = $processed.RelPermalink -}}
|
||||||
{{- $image = relURL (strings.TrimPrefix "/" $image) -}}
|
{{- end -}}
|
||||||
|
{{ else }}
|
||||||
|
{{/* Otherwise, use relative link of the image */}}
|
||||||
|
{{- if hasPrefix $image "/" -}}
|
||||||
|
{{- $image = relURL (strings.TrimPrefix "/" $image) -}}
|
||||||
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user