我通常喜欢将 Prettier 与 Visual Code 一起使用。但是,Prettier 在为 Hugo 编辑 HTML 模板时让我发疯,因为它不会保留对读者友好的格式:
{{ with .Site.Params.author }}<meta name="author" content="{{ . }}">{{ end }}
{{ hugo.Generator }}
{{ "<!-- plugins -->" | safeHTML }}
{{ range .Site.Params.plugins.css }}
<link rel="stylesheet" href="{{ .URL | absURL }} ">
{{ end }}
{{ "<!-- Main Stylesheet -->" | safeHTML }}
{{ $styles := resources.Get "scss/style.scss" | toCSS | minify | fingerprint }}
<link rel="stylesheet" href="{{ $styles.Permalink }}" integrity="{{ $styles.Data.Integrity }}" media="screen">
Run Code Online (Sandbox Code Playgroud)
相反,它被转换为:
{{ with .Site.Params.author }} …Run Code Online (Sandbox Code Playgroud)