Skip to content

Latest commit

 

History

History
65 lines (47 loc) · 1.58 KB

README.md

File metadata and controls

65 lines (47 loc) · 1.58 KB

HugoMods Prettier Config

This is a Prettier config for Hugo to format HTML templates, Markdown files, data files, i18n files and so on.

License Version Downloads

Installation

npm i -D @hugomods/prettier-config

Configuration

Configure the following settings on package.json.

{
  "prettier": "@hugomods/prettier-config",
  "scripts": {
    "lint:prettier": "prettier **/*.html i18n/* data/* **/*.md --check",
    "lint:prettier:fix": "prettier **/*.html i18n/* data/* **/*.md -w",
  }
}

Tweak **/*.html i18n/* data/* **/*.md to match files that need to formated.

Scripts

Check If Files Is Formatted Correctly

npm run lint:prettier

Format Files In Place

npm run lint:prettier:fix

GitHub Actions

To check if files are formatted correctly via GitHub Actions, you can create a workflow as follows, takes .github/workflows/lint.yml as an example.

name: lint

on:
  push:

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm run lint:prettier