🎨 Code cleanup

pull/762/head
James Panther 2023-12-26 11:22:55 +11:00
parent 4c8e536b64
commit 6415614513
No known key found for this signature in database
GPG Key ID: D36F789E45745D17
33 changed files with 154 additions and 102 deletions

View File

@ -1,7 +1,7 @@
i18n:
- changed-files:
- changed-files:
- any-glob-to-any-file: i18n/*
documentation:
- changed-files:
- any-glob-to-any-file: '**/*.md'
- changed-files:
- any-glob-to-any-file: "**/*.md"

8
.prettierignore 100644
View File

@ -0,0 +1,8 @@
/assets/css/compiled/
/assets/lib/
/layouts/_default/_markup/*.html
/layouts/shortcodes/figure.html
/layouts/shortcodes/screenshot.html
/exampleSite/content/docs/version-2/lighthouse.html

View File

@ -9,7 +9,7 @@
"trailingComma": "es5",
"overrides": [
{
"files": ["*.html"],
"files": ["*.html", "layouts/_default/*.json"],
"options": {
"parser": "go-template"
}

View File

@ -2,5 +2,5 @@
Closes the hamburger menu when a link is clicked.
*/
function close_menu() {
document.getElementById('menu-controller').checked=false
document.getElementById("menu-controller").checked = false;
}

View File

@ -1,4 +1,3 @@
window.addEventListener("load", () => {
quicklink.listen();
});

View File

@ -133,6 +133,7 @@ function executeQuery(term) {
let resultsHTML = "";
if (results.length > 0) {
// prettier-ignore
resultsHTML = results.map(function (value, key) {
return `<li class="mb-2">
<a class="flex items-center px-3 py-2 rounded-md appearance-none bg-neutral-100 dark:bg-neutral-700 focus:bg-primary-100 hover:bg-primary-100 dark:hover:bg-primary-900 dark:focus:bg-primary-900 focus:outline-dotted focus:outline-transparent focus:outline-2" href="${value.item.permalink}" tabindex="0">

View File

@ -46,7 +46,7 @@
},
"weibo": {
"icon": "weibo",
"title":"sharing.weibo",
"title": "sharing.weibo",
"url": "https://service.weibo.com/share/share.php?url=%s&appkey=&title=%s&pic=&ralateUid=&lang"
}
}

View File

@ -18,7 +18,7 @@ tags: ["content", "example"]
## ブランチページ
Hugoのブランチページバンドルは、ホームページ、セクションリスト、Taxonomyページのような項目をカバーしています。ブランチバンドルについて覚えておくべき重要なことは、このコンテンツタイプのファイル名は **_index.md`** であるということです。
Hugoのブランチページバンドルは、ホームページ、セクションリスト、Taxonomyページのような項目をカバーしています。ブランチバンドルについて覚えておくべき重要なことは、このコンテンツタイプのファイル名は **`_index.md`** であるということです。
Congoはブランチページで指定されたフロントマターを尊重し、デフォルト設定を上書きします。例えば、ブランチページで `title` パラメーターを設定すると、ページタイトルを上書きすることができます。

View File

@ -100,7 +100,7 @@ Congoは、テーマ全体で使用される3色のパレットを定義して
## コンテンツの整理
Congoは特定のコンテンツタイプを強制しません。そのため、自由にコンテンツを定義することができます。静的なサイトには_pages_、ブログには_posts_、ポートフォリオには_projects_がいいかもしれません。
Congoは特定のコンテンツタイプを強制しません。そのため、自由にコンテンツを定義することができます。静的なサイトには*pages*、ブログには*posts*、ポートフォリオには*projects*がいいかもしれません。
### ディレクトリ構造

View File

@ -195,5 +195,4 @@ Congo 2.0では `figure` ショートコードの振る舞いが変わります
エラーに遭遇した場合は、設定が正しいことを確認し、[ドキュメント]({{<ref "docs" >}})を参照してください。テーマに同梱されている設定ファイルの例には、デフォルトのパラメーターがすべて含まれており、出発点として最適です。
🙋‍♀️ それでもまだ助けが必要な場合は、[GitHub Discussions](https://github.com/jpanther/congo/discussions)で遠慮なく質問してください。

View File

@ -67,7 +67,7 @@ Tabellen sind nicht Teil der Markdown-Kernspezifikation, aber Hugo unterstützt
### Code-Block mit backticks
```html
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />

View File

@ -59,7 +59,7 @@ Las tablas no forman parte de la especificación principal de Markdown, pero Hug
### Markdown dentro de las tablas
| Cursiva | Negritas | Código |
| --------- | ---------- | -------- |
| --------- | ----------- | -------- |
| _Cursiva_ | **Negrita** | `Código` |
## Bloques de código
@ -67,7 +67,7 @@ Las tablas no forman parte de la especificación principal de Markdown, pero Hug
### Bloque de código con acentos graves
```html
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />

View File

@ -52,7 +52,7 @@ Itatur? Quiatae cullecum rem ent aut odis in re eossequodi nonsequ idebis ne sap
表はMarkdownのコア仕様には含まれていませんが、Hugoはサポートしています。
| 名前 | 年齢 |
| ----- | --- |
| ----- | ---- |
| Bob | 27 |
| Alice | 23 |
@ -67,7 +67,7 @@ Itatur? Quiatae cullecum rem ent aut odis in re eossequodi nonsequ idebis ne sap
### Code block with backticks
```html
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />

View File

@ -67,7 +67,7 @@ Tables aren't part of the core Markdown spec, but Hugo supports supports them ou
### Code block with backticks
```html
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />

View File

@ -5,4 +5,9 @@
<div id="profile" class="hidden h-full">
{{ partial "partials/home/profile.html" . }}
</div>
<script defer type="text/javascript" src="{{ $jsHome.RelPermalink }}" integrity="{{ $jsHome.Data.Integrity }}"></script>
<script
defer
type="text/javascript"
src="{{ $jsHome.RelPermalink }}"
integrity="{{ $jsHome.Data.Integrity }}"
></script>

View File

@ -53,7 +53,7 @@ sharing:
twitter: "Tweet na Twitter"
telegram: "Sdílejte na Telegram"
line: "Sdílejte na LINE"
line: "Sdílejte na Weibo"
weibo: "Sdílejte na Weibo"
shortcode:
recent_articles: "Nedávné"

View File

@ -22,7 +22,7 @@
{{- with $img -}}
{{ partial "picture.html" (dict "img" . "alt" $altText "class" $class "x2" $x2) }}
{{- else -}}
<img src="{{ .Destination | safeURL }}" alt="{{ $altText }}" class="{{ $class }}"/>
<img src="{{ .Destination | safeURL }}" alt="{{ $altText }}" class="{{ $class }}" />
{{- end -}}
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
</figure>

View File

@ -14,4 +14,5 @@
{{ end -}}
{{ end -}}
{{ end -}}
<!-- prettier-ignore -->
<a href="{{ $link | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}{{ if $isRemote }} target="_blank" rel="noreferrer"{{ end }}>{{- .Text | safeHTML -}}</a>

View File

@ -1,6 +1,6 @@
{{- partial "partials/functions/warnings.html" .Site -}}
{{- partial "partials/functions/init.html" . -}}
<!DOCTYPE html>
<!doctype html>
<html
lang="{{- site.Language.LanguageCode | default "" -}}"
dir="{{- site.Language.LanguageDirection | default "ltr" -}}"

View File

@ -9,6 +9,7 @@
"summary" (.Summary | emojify | safeJS)
"content" (.Plain | emojify | safeJS)
"permalink" .RelPermalink
) -}}
)
-}}
{{- end -}}
{{- $index | jsonify -}}

View File

@ -3,10 +3,12 @@
<script defer src="https://cdn.usefathom.com/script.js" data-site="{{ . }}"></script>
{{ end }}
{{ with site.Params.plausibleAnalytics.domain }}
<script defer
<script
defer
data-domain="{{ . }}"
data-api="{{ default "https://plausible.io/api/event" site.Params.plausibleAnalytics.event }}"
src="{{ default "https://plausible.io/js/script.js" site.Params.plausibleAnalytics.script }}"></script>
src="{{ default "https://plausible.io/js/script.js" site.Params.plausibleAnalytics.script }}"
></script>
{{ end }}
{{ template "_internal/google_analytics.html" . }}
{{ end }}

View File

@ -1,4 +1,4 @@
<article class="mt-6 flex max-w-prose flex-row">
<article class="flex flex-row mt-6 max-w-prose">
{{- $images := $.Resources.ByType "image" }}
{{- $thumbnail := $images.GetMatch (.Params.thumbnail | default "*thumb*") }}
{{- $feature := $images.GetMatch (.Params.feature | default "*feature*") | default $thumbnail }}
@ -21,9 +21,7 @@
class="w-24 rounded-md sm:w-40" srcset="
{{- (.Fill "160x120 smart").RelPermalink }}
160w, {{- (.Fill "320x240 smart").RelPermalink }} 2x"
src="{{ (.Fill "160x120 smart").RelPermalink }}"
width="160"
height="120"
src="{{ (.Fill "160x120 smart").RelPermalink }}" width="160" height="120"
{{ end }}
{{ if $.Site.Params.enableImageLazyLoading | default true }}
loading="lazy"
@ -44,7 +42,7 @@
>{{ $.Title | emojify }}</a
>
<span
class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500"
class="text-xs align-top cursor-default text-neutral-400 dark:text-neutral-500"
title="{{ i18n "list.externalurl_title" }}"
>
<span class="rtl:hidden">&#8599;</span>
@ -71,7 +69,7 @@
{{ partial "article-meta.html" . }}
</div>
{{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }}
<div class="prose py-1 dark:prose-invert">
<div class="py-1 prose dark:prose-invert">
{{ .Summary | emojify }}
</div>
{{ end }}

View File

@ -50,7 +50,7 @@
(and (ne $scope "single") (.Params.showTaxonomies | default (.Site.Params.list.showTaxonomies | default (.Site.Params.article.showTaxonomies | default false))))
(and (eq $scope "single") (.Params.showTaxonomies | default (.Site.Params.article.showTaxonomies | default false)))
}}
<div class="flex flex-wrap my-1 text-xs leading-relaxed text-neutral-500 dark:text-neutral-400 ">
<div class="flex flex-wrap my-1 text-xs leading-relaxed text-neutral-500 dark:text-neutral-400">
{{ range $taxonomy, $terms := .Site.Taxonomies }}
{{ if (gt (len ($context.GetTerms $taxonomy)) 0) }}
{{ range $context.GetTerms $taxonomy }}

View File

@ -7,7 +7,8 @@
src="{{ $logo.RelPermalink }}"
width="{{ div $logo.Width 2 }}"
height="{{ div $logo.Height 2 }}"
class="max-h-[10rem] max-w-[10rem] object-scale-down object-left{{ if $logo_dark }} hidden dark:flex{{ end }}"
class="max-h-[10rem] max-w-[10rem] object-scale-down object-left
{{ if $logo_dark }}hidden dark:flex{{ end }}"
alt="{{ .Site.Title }}"
/>
{{- if $logo_dark }}
@ -18,7 +19,7 @@
class="max-h-[10rem] max-w-[10rem] object-scale-down object-left dark:hidden"
alt="{{ .Site.Title }}"
/>
{{- end}}
{{- end }}
</a>
{{- end }}
{{- end }}

View File

@ -4,7 +4,6 @@
{{- if gt .TotalPages 1 }}
{{- $start := math.Max 1 (sub .PageNumber $width) }}
{{- $end := math.Min .TotalPages (add $start (mul $width 2)) }}
<ul class="flex flex-row mt-8">
{{- with .Prev }}
<li>
@ -18,7 +17,6 @@
</a>
</li>
{{- end }}
{{- with .First }}
{{- if gt $currentPageNumber (add 1 $width) }}
<li class="mx-1 min-w-[1.8rem] text-center">
@ -35,7 +33,6 @@
{{- end }}
{{- end }}
{{- end }}
{{- range $i := seq $start $end }}
<li class="mx-1 min-w-[1.8rem] text-center">
{{- if eq $.Paginator.PageNumber $i }}
@ -57,7 +54,6 @@
{{- end }}
</li>
{{- end }}
{{- with .Last }}
{{- if and (lt $currentPageNumber (sub .TotalPages $width)) (lt $end .TotalPages) }}
{{- if lt $currentPageNumber (sub .TotalPages (add $width 1)) }}
@ -74,7 +70,6 @@
</li>
{{- end }}
{{- end }}
{{- with .Next }}
<li>
<a

View File

@ -8,8 +8,8 @@
{{ with $img }}
{{ if (eq .MediaType.SubType "svg") }}
{{ $width := ""}}
{{ $height := ""}}
{{ $width := "" }}
{{ $height := "" }}
{{ $svgContent := .Content }}
{{ range (findRESubmatch `<svg[^>]*width=["']([.0-9]*)["'a-zA-Z]` $svgContent 1) }}
{{ $width = index . 1 }}
@ -28,19 +28,20 @@
{{/* do not use lazy without dimensions */}}
{{ $lazy = false }}
{{ end }}
<!-- prettier-ignore -->
<picture {{ with $class }} class="{{ . }}" {{ end }}>
<img
src="{{ .RelPermalink }}"
{{ with $width }} width="{{ . }}" {{ end }}
{{ with $height }} height="{{ . }}" {{ end }}
{{ with $class }} class="{{ . }}" {{ end }}
{{ with $alt }} alt="{{ . }}" {{ end }}
{{ with $lazy }} loading="lazy" decoding="async" {{ end }}
>
{{ with $width }}width="{{ . }}"{{ end }}
{{ with $height }}height="{{ . }}"{{ end }}
{{ with $class }}class="{{ . }}"{{ end }}
{{ with $alt }}alt="{{ . }}"{{ end }}
{{ with $lazy }}loading="lazy" decoding="async"{{ end }}
/>
</picture>
{{ else }}
<picture
{{ with $class }} class="{{ . }}" {{ end }}
{{ with $class }}class="{{ . }}"{{ end }}
{{ if $lqip }}
{{ $bg := (.Resize "20x webp q20").Content | base64Encode }}
style="background-image:url(data:image/webp;base64,{{ $bg }});background-size:cover"
@ -59,8 +60,7 @@
src="{{ .RelPermalink }}"
{{ end }}
{{ else }}
srcset="
{{- (.Resize "330x webp").RelPermalink }} 330w,
srcset=" {{- (.Resize "330x webp").RelPermalink }} 330w,
{{- (.Resize "660x webp").RelPermalink }} 660w
{{ if gt .Width 1024 }}
,{{ (.Resize "1024x webp").RelPermalink }} 1024w
@ -85,15 +85,15 @@
src="{{ .RelPermalink }}"
width="{{ $width }}"
height="{{ $height }}"
{{ with $class }} class="{{ . }}" {{ end }}
{{ with $alt }} alt="{{ . }}" {{ end }}
{{ with $lazy }} loading="lazy" decoding="async" {{ end }}
{{ with $class }}class="{{ . }}"{{ end }}
{{ with $alt }}alt="{{ . }}"{{ end }}
{{ with $lazy }}loading="lazy" decoding="async"{{ end }}
{{ if lt .Width 660 }}
src="{{ .RelPermalink }}"
{{ else }}
srcset="
{{- (.Resize "330x").RelPermalink }} 330w,
{{- (.Resize "660x").RelPermalink }} 660w
srcset=" {{- (.Resize "330x").RelPermalink }} 330w,
{{- (.Resize "660x").RelPermalink }}
660w
{{ if gt .Width 1024 }}
,{{ (.Resize "1024x").RelPermalink }} 1024w
{{ else }}
@ -106,7 +106,7 @@
{{ end }}"
src="{{ (.Resize "660x").RelPermalink }}"
{{ end }}
>
/>
</picture>
{{ end }}
{{ end }}

View File

@ -4,7 +4,12 @@
{{ $mermaidConfig := resources.Get "js/mermaid.js" }}
{{ $mermaidConfig := $mermaidConfig | resources.Minify }}
{{ $mermaidJS := slice $mermaidLib $mermaidConfig | resources.Concat "js/mermaid.bundle.js" | resources.Fingerprint "sha512" }}
<script defer type="text/javascript" src="{{ $mermaidJS.RelPermalink }}" integrity="{{ $mermaidJS.Data.Integrity }}"></script>
<script
defer
type="text/javascript"
src="{{ $mermaidJS.RelPermalink }}"
integrity="{{ $mermaidJS.Data.Integrity }}"
></script>
{{ end }}
{{/* Chart */}}
{{ if .Page.HasShortcode "chart" }}
@ -12,23 +17,38 @@
{{ $chartConfig := resources.Get "js/chart.js" }}
{{ $chartConfig := $chartConfig | resources.Minify }}
{{ $chartJS := slice $chartLib $chartConfig | resources.Concat "js/chart.bundle.js" | resources.Fingerprint "sha512" }}
<script defer type="text/javascript" src="{{ $chartJS.RelPermalink }}" integrity="{{ $chartJS.Data.Integrity }}"></script>
<script
defer
type="text/javascript"
src="{{ $chartJS.RelPermalink }}"
integrity="{{ $chartJS.Data.Integrity }}"
></script>
{{ end }}
{{/* Katex */}}
{{ if .Page.HasShortcode "katex" }}
{{ $katexCSS := resources.Get "lib/katex/katex.min.css" }}
{{ $katexCSS := $katexCSS | resources.Fingerprint "sha512" }}
<link
type="text/css" rel="stylesheet"
type="text/css"
rel="stylesheet"
href="{{ $katexCSS.RelPermalink }}"
integrity="{{ $katexCSS.Data.Integrity }}"
/>
{{ $katexJS := resources.Get "lib/katex/katex.min.js" }}
{{ $katexJS := $katexJS | resources.Fingerprint "sha512" }}
<script defer src="{{ $katexJS.RelPermalink }}" integrity="{{ $katexJS.Data.Integrity }}"></script>
<script
defer
src="{{ $katexJS.RelPermalink }}"
integrity="{{ $katexJS.Data.Integrity }}"
></script>
{{ $katexRenderJS := resources.Get "lib/katex/auto-render.min.js" }}
{{ $katexRenderJS := $katexRenderJS | resources.Fingerprint "sha512" }}
<script defer src="{{ $katexRenderJS.RelPermalink }}" integrity="{{ $katexRenderJS.Data.Integrity }}" onload="renderMathInElement(document.body);"></script>
<script
defer
src="{{ $katexRenderJS.RelPermalink }}"
integrity="{{ $katexRenderJS.Data.Integrity }}"
onload="renderMathInElement(document.body);"
></script>
{{ $katexFonts := resources.Match "lib/katex/fonts/*" }}
{{ range $katexFonts }}
{{ .Publish }}

View File

@ -14,6 +14,7 @@
{{ $img = resources.Get $path }}
{{ end -}}
<!-- prettier-ignore -->
<figure{{ with $class }} class="{{ . }}"{{ end }}>
{{ with $href }}<a href="{{ . }}">{{ end }}

View File

@ -1,5 +1,6 @@
{{ if .Get "src" }}
{{ $image := .Page.Resources.GetMatch (printf "*%s*" (.Get "src")) }}
<!-- prettier-ignore -->
<figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
{{- if .Get "href" -}}
<a href="{{ .Get "href" }}">

View File

@ -1 +1,21 @@
{"name":"Congo","short_name":"Congo","icons":[{"src": "/android-chrome-192x192.png","sizes": "192x192","type": "image/png","purpose": "any maskable"},{"src": "/android-chrome-512x512.png","sizes": "512x512","type": "image/png","purpose": "any maskable"}],"theme_color":"#ffffff","background_color":"#7c3aed","display":"standalone"}
{
"name": "Congo",
"short_name": "Congo",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any maskable"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any maskable"
}
],
"theme_color": "#ffffff",
"background_color": "#7c3aed",
"display": "standalone"
}