mirror of
https://github.com/imfing/hextra.git
synced 2025-07-02 00:07:16 -04:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
14036ffea6 | |||
a1232ecf9f | |||
a933f464f5 |
@ -195,8 +195,19 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
*/
|
||||
async function preloadIndex() {
|
||||
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({
|
||||
tokenize,
|
||||
encode: encodeFunction,
|
||||
cache: 100,
|
||||
document: {
|
||||
id: 'id',
|
||||
@ -207,6 +218,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
window.sectionIndex = new FlexSearch.Document({
|
||||
tokenize,
|
||||
encode: encodeFunction,
|
||||
cache: 100,
|
||||
document: {
|
||||
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.
|
||||
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
|
||||
|
||||
|
@ -15,16 +15,21 @@
|
||||
{{- $options := .Get "options" | default "800x webp q80" -}}
|
||||
{{- $process := .Get "process" | default (printf "%s %s" $method $options) -}}
|
||||
|
||||
{{- with or (.Page.Resources.Get $image) (resources.Get $image) -}}
|
||||
{{/* Retrieve the $image resource from local or global resources */}}
|
||||
{{- $processed := .Process $process -}}
|
||||
{{- $width = $processed.Width -}}
|
||||
{{- $height = $processed.Height -}}
|
||||
{{- $image = $processed.RelPermalink -}}
|
||||
{{ else }}
|
||||
{{/* Otherwise, use relative link of the image */}}
|
||||
{{- if hasPrefix $image "/" -}}
|
||||
{{- $image = relURL (strings.TrimPrefix "/" $image) -}}
|
||||
{{- if and $image (not (urls.Parse $image).Scheme) -}}
|
||||
{{- with or (.Page.Resources.Get $image) (resources.Get $image) -}}
|
||||
{{/* .Process does not work on svgs */}}
|
||||
{{- if (not (eq .MediaType.SubType "svg")) -}}
|
||||
{{/* Retrieve the $image resource from local or global resources */}}
|
||||
{{- $processed := .Process $process -}}
|
||||
{{- $width = $processed.Width -}}
|
||||
{{- $height = $processed.Height -}}
|
||||
{{- $image = $processed.RelPermalink -}}
|
||||
{{- end -}}
|
||||
{{ else }}
|
||||
{{/* Otherwise, use relative link of the image */}}
|
||||
{{- if hasPrefix $image "/" -}}
|
||||
{{- $image = relURL (strings.TrimPrefix "/" $image) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
Reference in New Issue
Block a user