# Technical Documentation: hexojs/hexo

> ℹ️ **Provenance:** In-Tree Documentation (20 Chapters) · [CodeWiki Reference](https://codewiki.google/github.com/hexojs/hexo) · Recency: Active (< 180 days)

## File: README.md

# Hexo

> A fast, simple & powerful blog framework, powered by [Node.js](https://nodejs.org).

[Website](https://hexo.io) |
[Documentation](https://hexo.io/docs/) |
[Installation Guide](https://hexo.io/docs/#Installation) |
[Contribution Guide](https://hexo.io/docs/contributing) |
[Code of Conduct](CODE_OF_CONDUCT.md) |
[API](https://hexo.io/api/) |
[Twitter](https://twitter.com/hexojs)

[](https://www.npmjs.com/package/hexo)

[](https://github.com/hexojs/hexo/actions?query=workflow%3ATester)
[](https://libraries.io/npm/hexo)
[](https://coveralls.io/r/hexojs/hexo?branch=master)
[](https://gitter.im/hexojs/hexo)
[](https://discord.gg/teM2Anj)
[](https://t.me/hexojs)
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fhexojs%2Fhexo?ref=badge_shield)
[](CODE_OF_CONDUCT.md)

## Features

- Blazing fast generating
- Support for GitHub Flavored Markdown and most Octopress plugins
- One-command deploy to GitHub Pages, Heroku, etc.
- Powerful API for limitless extensibility
- Hundreds of [themes](https://hexo.io/themes/) & [plugins](https://hexo.io/plugins/)

## Quick Start

**Install Hexo**

``` bash
$ npm install hexo-cli -g
```

Install with [brew](https://brew.sh/) on macOS and Linux:

```bash
$ brew install hexo
```

**Setup your blog**

``` bash
$ hexo init blog
$ cd blog
```

**Start the server**

``` bash
$ hexo server
```

**Create a new post**

``` bash
$ hexo new "Hello Hexo"
```

**Generate static files**

``` bash
$ hexo generate
```

## More Information

- Read the [documentation](https://hexo.io/)
- Visit the [Awesome Hexo](https://github.com/hexojs/awesome-hexo) list
- Find solutions in [troubleshooting](https://hexo.io/docs/troubleshooting.html)
- Join discussion on [Google Group](https://groups.google.com/group/hexo), [Discord](https://discord.gg/teM2Anj), [Gitter](https://gitter.im/hexojs/hexo) or [Telegram](https://t.me/hexojs)
- See the [plugin list](https://hexo.io/plugins/) and the [theme list](https://hexo.io/themes/) on wiki
- Follow [@hexojs](https://twitter.com/hexojs) for latest news

## Contributing

We welcome you to join the development of Hexo. Please see [contributing document](https://hexo.io/docs/contributing). 🤗

Also, we welcome PR or issue to [official-plugins](https://github.com/hexojs).

## Contributors

[](https://github.com/hexojs/hexo/graphs/contributors)

## Backers

[](https://opencollective.com/hexo)

## Sponsors

[](https://opencollective.com/hexo)

## License

[](https://app.fossa.com/projects/git%2Bgithub.com%2Fhexojs%2Fhexo?ref=badge_large)

---

## File: CODE_OF_CONDUCT.md

# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
  advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
  address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
  professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at report@hexo.io. All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of actions.

**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior,  harassment of an individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the project community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.

---

## File: package.json

{
  "name": "hexo",
  "version": "8.1.2",
  "description": "A fast, simple & powerful blog framework, powered by Node.js.",
  "main": "dist/hexo",
  "bin": {
    "hexo": "./bin/hexo"
  },
  "scripts": {
    "prepublishOnly": "npm install && npm run clean && npm run build",
    "build": "tsc -b",
    "clean": "tsc -b --clean",
    "eslint": "eslint lib test",
    "test": "mocha test/scripts/**/*.ts --require ts-node/register",
    "test-cov": "c8 --reporter=lcovonly npm test -- --no-parallel",
    "prepare": "husky"
  },
  "files": [
    "dist/",
    "bin/"
  ],
  "types": "./dist/hexo/index.d.ts",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/hexojs/hexo.git"
  },
  "homepage": "https://hexo.io/",
  "funding": {
    "type": "opencollective",
    "url": "https://opencollective.com/hexo"
  },
  "keywords": [
    "website",
    "blog",
    "cms",
    "framework",
    "hexo"
  ],
  "author": "Tommy Chen <tommy351@gmail.com> (https://zespia.tw)",
  "maintainers": [
    "Abner Chou <hi@abnerchou.me> (https://abnerchou.me)"
  ],
  "license": "MIT",
  "dependencies": {
    "abbrev": "^5.0.0",
    "bluebird": "^3.7.2",
    "fast-archy": "^1.0.0",
    "fast-text-table": "^1.0.1",
    "hexo-cli": "^4.3.2",
    "hexo-front-matter": "^4.2.1",
    "hexo-fs": "^5.0.0",
    "hexo-i18n": "^2.0.0",
    "hexo-log": "^4.1.0",
    "hexo-util": "^4.0.0",
    "js-yaml": "^4.1.0",
    "js-yaml-js-types": "^1.0.1",
    "micromatch": "^4.0.8",
    "moize": "^6.1.6",
    "moment": "^2.30.1",
    "moment-timezone": "^0.6.2",
    "nunjucks": "^3.2.4",
    "picocolors": "^1.1.1",
    "pretty-hrtime": "^1.0.3",
    "strip-ansi": "^7.1.0",
    "tildify": "^3.0.0",
    "titlecase": "^1.1.3",
    "warehouse": "^6.0.0"
  },
  "devDependencies": {
    "@types/abbrev": "^1.1.3",
    "@types/bluebird": "^3.5.37",
    "@types/chai": "^4.3.11",
    "@types/graceful-fs": "^4.1.9",
    "@types/js-yaml": "^4.0.9",
    "@types/micromatch": "^4.0.7",
    "@types/mocha": "^10.0.9",
    "@types/node": "^20.17.6",
    "@types/nunjucks": "^3.2.2",
    "@types/sinon": "^17.0.3",
    "0x": "^6.0.0",
    "c8": "^9.0.0",
    "chai": "^4.3.6",
    "cheerio": "1.0.0",
    "decache": "^4.6.1",
    "eslint": "^9.17.0",
    "eslint-config-hexo": "^6.0.0",
    "hexo-renderer-marked": "^6.0.0",
    "husky": "^9.1.7",
    "lint-staged": "^15.3.0",
    "mocha": "^10.0.0",
    "sinon": "^17.0.1",
    "ts-node": "^10.9.1",
    "typescript": "^5.3.2"
  },
  "engines": {
    "node": ">=20.19.0"
  }
}

---

## File: tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es2020",
    "sourceMap": true,
    "outDir": "dist",
    "declaration": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "types": [
      "node",
      "mocha"
    ]
  },
  "include": [
    "lib/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ]
}

---

## File: .lintstagedrc.json

{
  "*.js": "eslint --fix",
  "*.ts": "eslint --fix"
}

---

## File: .mocharc.yml

color: true
reporter: spec
ui: bdd
full-trace: true
exit: true

---

## File: test/fixtures/_config.json

{
	"author": "waldo",
	"favorites": {
		"food": "ice cream"
	}
}

---

## File: .github/CONTRIBUTING.md

# Contributing

## Style Guide

We use [ESLint] to maintain the code style. You can install linter plugins on your editor or check the status with the following commands:

``` bash
$ npm run eslint

# You can append `--fix` option to these commands to fix the code style automatically
$ npm run eslint -- --fix
```

## Pull Requests

1. Fork [hexojs/hexo](https://github.com/hexojs/hexo).
2. Clone the repository to your computer and install dependencies.

    ``` bash
    $ git clone https://github.com/<username>/hexo.git
    $ cd hexo
    $ npm install
    ```
    
3. Create a feature branch.

    ``` bash
    $ git checkout -b new_feature
    ```
    
4. Start hacking.
5. Push the branch.

    ``` bash
    $ git push origin new_feature
    ```
    
6. Create a pull request and describe the change.

## Testing

Before you submitting the pull request. Please make sure your code is coveraged and passes the tests. Otherwise your pull request won't be merged.

``` bash
$ npm test
```

## Updating Documentation

The Hexo documentation is open source and you can find the source code on [hexojs/site]. 

### Workflow

1. Fork [hexojs/site](https://github.com/hexojs/site).
2. Clone the repository to your computer and install dependencies.

    ``` bash
    $ git clone https://github.com/<username>/site.git
    $ cd site
    $ npm install
    ```
    
3. Start editing the documentation. You can start the server for live previewing.

    ``` bash
    $ hexo server
    ```
    
4. Push the branch.
5. Create a pull request and describe the change.

### Translating

1. Add a new language folder in `source` folder. (all in lower case)
2. Copy Markdown and template files in `source` folder to the new language folder.
3. Add the new language to `source/_data/language.yml`.
4. Copy `en.yml` in `themes/navy/languages` and rename to the language name (all in lower case).

## Reporting Issues

When you encounter some problems when using Hexo, you can find the solutions in [Troubleshooting](https://hexo.io/docs/troubleshooting.html) or ask me on [GitHub](https://github.com/hexojs/hexo/issues) or [Google Group](https://groups.google.com/group/hexo). If you can't find the answer, please report it on GitHub.

1. Represent the problem in [debug mode](https://hexo.io/docs/commands.html#Debug_mode).
2. Run `hexo version` and check the version info.    
3. Post both debug message and version info on GitHub.

[ESLint]: https://eslint.org/

---

## File: .github/dependabot.yml

version: 2
updates:
- package-ecosystem: npm
  directory: "/"
  schedule:
    interval: daily
- package-ecosystem: github-actions
  directory: "/"
  schedule:
    interval: daily

---

## File: .github/FUNDING.yml

open_collective: hexo

---

## File: .github/PULL_REQUEST_TEMPLATE.md

## What does it do?



## Screenshots



## Pull request tasks

- [ ] Add test cases for the changes.
- [ ] Passed the CI test.

---

## File: .github/ISSUE_TEMPLATE/bug_report.yml

name: Bug report
# title: ""
# labels: []
# assignees: []

body:
  - type: markdown
    attributes:
      value: |
        ## Tips

        - 给简体中文用户的提示:

          - 在提交 issue 时请按照下面的模板提供相关信息，这将有助于我们发现问题。
          - 请尽量使用英语描述你遇到的问题，这可以让更多的人帮助到你。

        - A good bug report should have your configuration and build environment information, which are essential for us to investigate the problem. We've provided the following steps on how to attach the necessary information.

        - If you find that markdown files are not rendered as expected, please go to https://marked.js.org/demo/ to see if it can be reproduced there. If it can be reproduced, please file a bug to https://github.com/markedjs/marked.

        - If you want help on your bug, please also send us the git repository (GitHub, GitLab, Bitbucket, etc.) where your hexo code is stored. It would greatly help. If you prefer not to have your hexo code out in public, please upload to a private GitHub repository and grant read-only access to `hexojs/core`.

        - Please take extra precaution not to attach any secret or personal information. (likes personal privacy, password, GitHub Personal Access Token, etc.)

        ------

  - type: checkboxes
    validations:
      required: true
    attributes:
      label: Check List
      options:
        - label: I have already read [Docs page](https://hexo.io/docs/) & [Troubleshooting page](https://hexo.io/docs/troubleshooting).
        - label: I have already searched existing issues and they are not help to me.
        - label: I examined error or warning messages and it's difficult to solve.
        - label: I am using the [latest](https://github.com/hexojs/hexo/releases) version of Hexo. (run `hexo version` to check)
        - label: My Node.js is matched [the required version](https://hexo.io/docs/#Required-Node-js-version).

  - type: textarea
    validations:
      required: true
    attributes:
      label: Expected behavior
      # description:
      placeholder: Descripe what you expected to happen.
      # value:
      # render:

  - type: textarea
    validations:
      required: true
    attributes:
      label: Actual behavior
      # description:
      placeholder: Descripe what actually happen.
      # value:
      # render:

  - type: textarea
    validations:
      required: true
    attributes:
      label: How to reproduce?
      placeholder: |
        1. Step1
        2. Step2
        3. etc.
        ...
      # value:
      # render:

  - type: input
    validations:
      required: true
    attributes:
      label: Is the problem still there under `Safe mode`?
        https://hexo.io/docs/commands#Safe-mode

        "Safe mode" will disable all the plugins and scripts.
        If your problem disappear under "Safe mode" means the problem is probably at your newly installed plugins, not at hexo.
      # placeholder:
      # value: |
      # render:

  - type: markdown
    attributes:
      value: |
        ------

        ## Environment & Settings

  - type: textarea
    validations:
      required: false
    attributes:
      label: Your Node.js & npm version
        Please run `node -v && npm -v` 
        and paste the output here.
      placeholder: node -v && npm -v
      # value: |
      render: text

  - type: textarea
    validations:
      required: false
    attributes:
      label: Your Hexo and Plugin version
        Please run `npm ls --depth 0` 
        and paste the output here.
      placeholder: npm ls --depth 0
      # value:
      render: text

  - type: textarea
    validations:
      required: false
    attributes:
      label: Your `package.json`
      placeholder: package.json
      # value:
      render: json

  - type: textarea
    validations:
      required: false
    attributes:
      label: Your site's `_config.yml` (Optional)
      placeholder: _config.yml
      # value: |
      render: yaml

  - type: textarea
    validations:
      required: false
    attributes:
      label: Others
      # placeholder:
      # value:
      # render:

---

## File: .github/ISSUE_TEMPLATE/config.yml

blank_issues_enabled: false
contact_links:
  - name: Ask a Question, Help, Discuss
    url: https://github.com/hexojs/hexo/discussions
    about: I have a question, help for hexo (e.g. Customize)

---

## File: .github/ISSUE_TEMPLATE/feature-request-improvement.yml

name: Feature request / Improvement
# title: ""
# labels: []
# assignees: []

body:
  - type: checkboxes
    validations:
      required: true
    attributes:
      label: Check List
      options:
        - label: I have already read [Docs page](https://hexo.io/docs/).
        - label: I have already searched existing issues.

  - type: textarea
    validations:
      required: true
    attributes:
      label: Feature Request
      # placeholder:
      # value:
      # render:

  - type: textarea
    validations:
      required: false
    attributes:
      label: Others
      # placeholder:
      # value:
      # render:

---

## File: .github/workflows/benchmark.yml

name: Benchmark

on:
  workflow_dispatch:
  push:
    branches:
      - "master"
    paths:
      - "lib/**"
      - ".github/workflows/benchmark.yml"
  pull_request:
    branches:
      - "master"
    paths:
      - "lib/**"
      - ".github/workflows/benchmark.yml"

jobs:
  benchmark:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest]
        node-version: ["20", "22", "24"]
      fail-fast: false
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #6.0.2
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e #6.4.0
        with:
          node-version: ${{ matrix.node-version }}
      - name: Install dependencies
        run: npm install --silent
      - name: Running benchmark
        run: node test/benchmark.js --benchmark

  profiling:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest]
        node-version: ["20", "22", "24"]
      fail-fast: false
    env:
      comment_file: "tmp-comment-flamegraph-node${{ matrix.node-version }}.md"
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #6.0.2
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e #6.4.0
        with:
          node-version: ${{ matrix.node-version }}
      - name: Install dependencies
        run: npm install --silent
      - name: Running profiling
        run: node test/benchmark.js --profiling
      - name: Publish flamegraph to https://${{ github.sha }}-${{ matrix.node-version }}-hexo.surge.sh/flamegraph.html
        uses: dswistowski/surge-sh-action@2ef23bb28f7240e4922a44df1807022af43782bf #1.1.0
        with:
          domain: ${{ github.sha }}-${{ matrix.node-version }}-hexo.surge.sh
          project: ./.tmp-hexo-theme-unit-test/0x/
          login: ${{ secrets.SURGE_LOGIN }}
          token: ${{ secrets.SURGE_TOKEN }}

      - name: save comment to file
        if: ${{github.event_name == 'pull_request' }}
        run: |
          echo "https://${{ github.sha }}-${{ matrix.node-version }}-hexo.surge.sh/flamegraph.html" > ${{env.comment_file}}

      - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a #7.0.1
        if: ${{github.event_name == 'pull_request' }}
        with:
          retention-days: 1
          name: comment-node${{ matrix.node-version }}
          path: ${{env.comment_file}}

  number:
    runs-on: ubuntu-latest
    if: ${{github.event_name == 'pull_request' }}
    env:
      pr_number_file: tmp-comment-pr_number
    steps:
      - name: save PR number to file
        run: |
          echo -n "${{ github.event.number }}" > ${{env.pr_number_file}}
      - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a #7.0.1
        with:
          retention-days: 1
          name: comment-pr_number
          path: ${{env.pr_number_file}}

---

## File: .github/workflows/commenter.yml

name: Commenter

on:
  pull_request_target:

  workflow_run:
    workflows: ["Benchmark"]
    types:
      - completed

permissions:
  contents: read

jobs:
  comment-test:
    name: How to test
    permissions:
      pull-requests: write # for marocchino/sticky-pull-request-comment to create or update PR comment
    runs-on: ubuntu-latest
    if: ${{github.event_name == 'pull_request_target'}}
    steps:
      - name: Comment PR - How to test
        uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 #3.0.4
        with:
          header: How to test
          message: |
            ## How to test

            ```sh
            git clone -b ${{ github.head_ref }} https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
            cd hexo
            npm install
            npm test
            ```

  comment-flamegraph:
    name: Flamegraph
    permissions:
      pull-requests: write # for marocchino/sticky-pull-request-comment to create or update PR comment
      actions: read # get artifact
    runs-on: ubuntu-latest
    if: ${{github.event_name == 'workflow_run' && github.event.workflow_run.conclusion=='success'}}
    env:
      comment_result: "tmp-comment-flamegraph.md"
    steps:
      - name: download artifact
        uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c #8.0.1
        with:
          github-token: ${{secrets.GITHUB_TOKEN}}
          run-id: ${{toJSON(github.event.workflow_run.id)}}
          pattern: "comment-*"
          merge-multiple: true

      - name: get PR number
        run: |
          echo "pr_number=$(cat tmp-comment-pr_number)" >> "$GITHUB_ENV"

      - name: combime comment
        if: ${{env.pr_number!=''}}
        run: |
          echo "## Flamegraph" > ${{env.comment_result}}
          echo "" >> ${{env.comment_result}}
          cat tmp-comment-flamegraph-*.md >> ${{env.comment_result}}

      - name: Comment PR - flamegraph
        if: ${{env.pr_number!=''}}
        uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 #3.0.4
        with:
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
          number: ${{env.pr_number}}
          header: Flamegraph
          path: ${{env.comment_result}}

---

## File: .github/workflows/dependencies-review.yml

name: 'Dependencies Review'
on:
  pull_request:
    paths:
      - 'package.json'
      - 'package-lock.json'
  workflow_dispatch:

permissions:
  contents: read
  pull-requests: write

jobs:
  dependency-review:
    runs-on: ubuntu-latest
    steps:
      - name: 'Checkout Repository'
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #6.0.2
      - name: 'Dependencies Review'
        uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 #5.0.0
        with:
          vulnerability-check: true
          fail-on-severity: high
          comment-summary-in-pr: always

---

## File: .github/workflows/linter.yml

name: Linter

on:
  push:
    branches:
      - "master"
    paths:
      - "lib/**"
      - "test/**"
      - ".github/workflows/linter.yml"
  pull_request:
    paths:
      - "lib/**"
      - "test/**"
      - ".github/workflows/linter.yml"

permissions:
  contents: read

jobs:
  linter:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #6.0.2
      - name: Use Node.js 22
        uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e #6.4.0
        with:
          node-version: "22"
      - name: Install Dependencies
        run: npm install
      - name: Lint
        run: |
          npm run eslint
        env:
          CI: true

---

## File: .github/workflows/publish.yml

name: Publish Package
on:
  push:
    tags:
      - 'v*.*.*'

permissions:
  id-token: write
  contents: read

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #6.0.2

      - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e #6.4.0
        with:
          node-version: '24'
          registry-url: 'https://registry.npmjs.org'

      - name: Verify tag version
        run: |
          TAG_VERSION=${GITHUB_REF#refs/tags/v}
          PKG_VERSION=$(node -p "require('./package.json').version")
          if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
            echo "Error: Tag version (v$TAG_VERSION) does not match package.json version ($PKG_VERSION)"
            exit 1
          fi
          echo "Version matched: $PKG_VERSION"

      - run: npm ci
      - run: npm run build --if-present
      - run: npm publish

---

## File: .github/workflows/tester.yml

name: Tester

on:
  push:
    branches:
      - "master"
    paths:
      - "lib/**"
      - "test/**"
      - "package.json"
      - "tsconfig.json"
      - ".github/workflows/tester.yml"
  pull_request:
    paths:
      - "lib/**"
      - "test/**"
      - "package.json"
      - "tsconfig.json"
      - ".github/workflows/tester.yml"

permissions:
  contents: read

jobs:
  tester:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        node-version: ["20", "22", "24"]
      fail-fast: false
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #6.0.2
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e #6.4.0
        with:
          node-version: ${{ matrix.node-version }}
      - name: Install Dependencies
        run: npm install
      - name: Test
        run: npm test -- --no-parallel
        env:
          CI: true
  coverage:
    permissions:
      checks: write # for coverallsapp/github-action to create new checks
      contents: read # for actions/checkout to fetch code
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest]
        node-version: ["22"]
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #6.0.2
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e #6.4.0
        with:
          node-version: ${{ matrix.node-version }}
      - name: Install Dependencies
        run: npm install
      - name: Coverage
        run: npm run test-cov
        env:
          CI: true
      - name: Coveralls
        uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b #2.3.6
        with:
          github-token: ${{ secrets.github_token }}

--- METRICS ---
- Files Extracted: 20
- Estimated Token Budget: ~7750 tokens
- Recency Window: Active (< 180 days)
- Canonical Reference: https://codewiki.google/github.com/hexojs/hexo
