本文最后更新于 127 天前 ,文中信息可能已经过时。如有问题请在评论区留言。

IntelliJ IDEA 2024.1

File Template

配置路径:File > New > Edit File Templates...,会打开 File and Code Templates 窗口。

Hugo Note

快速生成 Hugo 文章文件及元信息,替代 hugo new 命令。

Files 界面,插入新的模板:

Name: Hugo Note
Extension: md
File name: ${YEAR}-${MONTH}-${DAY}-${NAME}

velocity
---
title: "${NAME}"
date: ${YEAR}-${MONTH}-${DAY}T${HOUR}:${MINUTE}:${SECOND}+08:00
slug: ""
description: ""
summary: ""
tags: 
  - 
series:
  - 
keywords:
  -
##weight: 1
shotTop: true
draft: true
---

以上内容按个人需求更改。

使用方式:File > New > Hugo Note

输入文件名,如 TestNote,则会创建文件 2024-05-10-TestNote.md (日期为创建文件日期)

配置说明

作者优先使用文件名中的日期作为文章日期,hugo 配置如下:

yml
config.yml
1
2
3
4
frontmatter:
  date:
    - :filename
    - :default

如果你不需要,上述模板中 File name 请留空。

Live Template

使用 Live Template 配合 ShortCode 可以快速实现期望样式。

配置路径:File > Settings > Editor > Live Templates,添加 Live Template

ShortCode

通用,快速生成 Hugo ShortCode 结构。

Abbreviation: shortcode
Description: Hugo ShortCode
Template text:

hugo
{{<$1$>}}
$END$
{{</$1$>}}

Applicable contexts Define: Other

admonition

Abbreviation: admonition
Description: Hugo ShortCode admonition
Template text:

hugo
 {{<admonition type=$1$ title=$2$ open=true>}}
 $END$
 {{</admonition>}}

Applicable contexts Define: Other

hl

Abbreviation: hl
Description: Hugo ShortCode text highlight
Template text:

hugo
{{<hl>}}$END${{</hl>}}

Applicable contexts Define: Other

最后

你可以基于你的使用场景,将高频内容配置为 File Template 或 Live Template,提高文章编写效率。