From 8b95bbc722e5c77a7e8125441ed64d2ea3524ac0 Mon Sep 17 00:00:00 2001 From: Kagamigawa <35628460+KagamigawaMeguri@users.noreply.github.com> Date: Mon, 1 May 2023 22:30:53 +0800 Subject: [PATCH 01/10] fix(post-asset): strip extensions better on permalink (#5153) * compatible with hexo-abbrlink * strip extensions better on permalink --- lib/models/post_asset.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/models/post_asset.js b/lib/models/post_asset.js index 9c3c3778f8..656acdbac4 100644 --- a/lib/models/post_asset.js +++ b/lib/models/post_asset.js @@ -1,7 +1,7 @@ 'use strict'; const { Schema } = require('warehouse').default; -const { join } = require('path'); +const { join, dirname } = require('path'); module.exports = ctx => { const PostAsset = new Schema({ @@ -19,8 +19,8 @@ module.exports = ctx => { // PostAsset.path is file path relative to `public_dir` // no need to urlescape, #1562 - // strip /\.html?$/ extensions on permalink, #2134 - return join(post.path.replace(/\.html?$/, ''), this.slug); + // strip extensions better on permalink, #2134 + return join(dirname(post.path), post.slug, this.slug); }); PostAsset.virtual('source').get(function() { From 981560f51dcb6b480fd8c10e3554c3c1b1422076 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Jun 2023 19:36:42 +0900 Subject: [PATCH 02/10] chore: bump c8 from 7.14.0 to 8.0.0 (#5227) Bumps [c8](https://github.com/bcoe/c8) from 7.14.0 to 8.0.0. - [Release notes](https://github.com/bcoe/c8/releases) - [Changelog](https://github.com/bcoe/c8/blob/main/CHANGELOG.md) - [Commits](https://github.com/bcoe/c8/compare/v7.14.0...v8.0.0) --- updated-dependencies: - dependency-name: c8 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c8fc3c53da..22194c1ad8 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "devDependencies": { "@easyops/git-exec-and-restage": "^1.0.4", "0x": "^5.1.2", - "c8": "^7.12.0", + "c8": "^8.0.0", "chai": "^4.3.6", "cheerio": "0.22.0", "decache": "^4.6.1", From b267475d306b616ab9a3cd37e904d36524aad8be Mon Sep 17 00:00:00 2001 From: yoshinorin Date: Wed, 26 Jul 2023 00:17:19 +0900 Subject: [PATCH 03/10] chore(github): delete `other` issue template (#5248) --- .github/ISSUE_TEMPLATE/other.md | 58 --------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/other.md diff --git a/.github/ISSUE_TEMPLATE/other.md b/.github/ISSUE_TEMPLATE/other.md deleted file mode 100644 index 6d0d667285..0000000000 --- a/.github/ISSUE_TEMPLATE/other.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -name: Other -about: Not a question, feature-request, bug -title: '' -labels: '' -assignees: '' - ---- - - - -## Check List - -Please check followings before submitting a new issue. - -- [ ] I have already confirmed other issue template and they are not different my want -- [ ] Not a question, feature-request, bug - - Please submit to [discussion](https://github.com/hexojs/hexo/discussions) if your issue is a question. - -## Information - - - -## Environment & Settings - -**Node.js & npm version** - -``` -``` - -**Your site `_config.yml`** (Optional) - -``` -``` - -**Hexo and Plugin version(`npm ls --depth 0`)** - -``` -``` - -**Your package.json `package.json`** - -``` -``` - -## Others - - From d29d774c100e373b937d5329932506143a9cb8eb Mon Sep 17 00:00:00 2001 From: Uiolee <22849383+uiolee@users.noreply.github.com> Date: Fri, 1 Sep 2023 00:51:45 +0800 Subject: [PATCH 04/10] chore(lint-staged): remove `git-exec-and-restage` (#5281) --- .lintstagedrc | 3 --- .lintstagedrc.json | 4 ++++ package.json | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 .lintstagedrc create mode 100644 .lintstagedrc.json diff --git a/.lintstagedrc b/.lintstagedrc deleted file mode 100644 index 66886867d5..0000000000 --- a/.lintstagedrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "*.js": "git-exec-and-restage eslint --fix --" -} diff --git a/.lintstagedrc.json b/.lintstagedrc.json new file mode 100644 index 0000000000..6953073375 --- /dev/null +++ b/.lintstagedrc.json @@ -0,0 +1,4 @@ +{ + "*.js": "eslint --fix", + "*.ts": "eslint --fix" +} diff --git a/package.json b/package.json index 8080a1db88..cc7f6a65e9 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,6 @@ }, "devDependencies": { "0x": "^5.1.2", - "@easyops/git-exec-and-restage": "^1.0.4", "@types/bluebird": "^3.5.37", "@types/node": "^18.11.8", "@types/nunjucks": "^3.2.2", @@ -77,11 +76,11 @@ "chai": "^4.3.6", "cheerio": "0.22.0", "decache": "^4.6.1", - "eslint": "^8.8.0", + "eslint": "^8.48.0", "eslint-config-hexo": "^5.0.0", "hexo-renderer-marked": "^6.0.0", "husky": "^8.0.1", - "lint-staged": "^13.0.3", + "lint-staged": "^14.0.1", "mocha": "^10.0.0", "sinon": "^15.0.0", "ts-node": "^10.9.1", From 7b588e78aae57e756e4d18bcd78e63d9dc7d34cd Mon Sep 17 00:00:00 2001 From: Uiolee <22849383+uiolee@users.noreply.github.com> Date: Sat, 2 Sep 2023 02:25:37 +0800 Subject: [PATCH 05/10] ci: reduce the running of ci (#5282) --- .github/workflows/linter.yml | 17 +++++++++++++++-- .github/workflows/tester.yml | 25 ++++++++++++++++++++----- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index d3d9678043..8211d38999 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -1,6 +1,19 @@ name: Linter -on: [push, pull_request] +on: + push: + branches: + - "master" + - "v7.0.0" + paths: + - "lib/**" + - "test/**" + - ".github/workflows/linter.yml" + pull_request: + paths: + - "lib/**" + - "test/**" + - ".github/workflows/linter.yml" permissions: contents: read @@ -13,7 +26,7 @@ jobs: - name: Use Node.js 14.x uses: actions/setup-node@v3 with: - node-version: '14.x' + node-version: "14.x" - name: Install Dependencies run: npm install - name: Lint diff --git a/.github/workflows/tester.yml b/.github/workflows/tester.yml index a28cf0a77d..c245376116 100644 --- a/.github/workflows/tester.yml +++ b/.github/workflows/tester.yml @@ -1,6 +1,21 @@ name: Tester -on: [push, pull_request] +on: + push: + branches: + - "master" + - "v7.0.0" + paths: + - "lib/**" + - "test/**" + - "package.json" + - ".github/workflows/tester.yml" + pull_request: + paths: + - "lib/**" + - "test/**" + - "package.json" + - ".github/workflows/tester.yml" permissions: contents: read @@ -11,7 +26,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - node-version: ['14.x', '16.x', '18.x'] + node-version: ["14.x", "16.x", "18.x"] fail-fast: false steps: - uses: actions/checkout@v3 @@ -27,13 +42,13 @@ jobs: CI: true coverage: permissions: - checks: write # for coverallsapp/github-action to create new checks - contents: read # for actions/checkout to fetch code + 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: ['14.x'] + node-version: ["14.x"] steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} From 4707a2d33b93052d0e3e3781d8f4313febd2d5cb Mon Sep 17 00:00:00 2001 From: D-Sketon <2055272094@qq.com> Date: Mon, 9 Oct 2023 15:56:42 +0800 Subject: [PATCH 06/10] Revert "fix(post-asset): strip extensions better on permalink (#5153)" (#5308) This reverts commit 8b95bbc722e5c77a7e8125441ed64d2ea3524ac0. --- lib/models/post_asset.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/models/post_asset.js b/lib/models/post_asset.js index 656acdbac4..9c3c3778f8 100644 --- a/lib/models/post_asset.js +++ b/lib/models/post_asset.js @@ -1,7 +1,7 @@ 'use strict'; const { Schema } = require('warehouse').default; -const { join, dirname } = require('path'); +const { join } = require('path'); module.exports = ctx => { const PostAsset = new Schema({ @@ -19,8 +19,8 @@ module.exports = ctx => { // PostAsset.path is file path relative to `public_dir` // no need to urlescape, #1562 - // strip extensions better on permalink, #2134 - return join(dirname(post.path), post.slug, this.slug); + // strip /\.html?$/ extensions on permalink, #2134 + return join(post.path.replace(/\.html?$/, ''), this.slug); }); PostAsset.virtual('source').get(function() { From ad056527cee2c55fa961cc84a56f44ea55404c63 Mon Sep 17 00:00:00 2001 From: Uiolee <22849383+uiolee@users.noreply.github.com> Date: Mon, 9 Oct 2023 15:57:32 +0800 Subject: [PATCH 07/10] ci: reduce the running of ci (#5291) --- .github/workflows/linter.yml | 17 +++++++++++++++-- .github/workflows/tester.yml | 25 ++++++++++++++++++++----- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index d3d9678043..8211d38999 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -1,6 +1,19 @@ name: Linter -on: [push, pull_request] +on: + push: + branches: + - "master" + - "v7.0.0" + paths: + - "lib/**" + - "test/**" + - ".github/workflows/linter.yml" + pull_request: + paths: + - "lib/**" + - "test/**" + - ".github/workflows/linter.yml" permissions: contents: read @@ -13,7 +26,7 @@ jobs: - name: Use Node.js 14.x uses: actions/setup-node@v3 with: - node-version: '14.x' + node-version: "14.x" - name: Install Dependencies run: npm install - name: Lint diff --git a/.github/workflows/tester.yml b/.github/workflows/tester.yml index a28cf0a77d..c245376116 100644 --- a/.github/workflows/tester.yml +++ b/.github/workflows/tester.yml @@ -1,6 +1,21 @@ name: Tester -on: [push, pull_request] +on: + push: + branches: + - "master" + - "v7.0.0" + paths: + - "lib/**" + - "test/**" + - "package.json" + - ".github/workflows/tester.yml" + pull_request: + paths: + - "lib/**" + - "test/**" + - "package.json" + - ".github/workflows/tester.yml" permissions: contents: read @@ -11,7 +26,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - node-version: ['14.x', '16.x', '18.x'] + node-version: ["14.x", "16.x", "18.x"] fail-fast: false steps: - uses: actions/checkout@v3 @@ -27,13 +42,13 @@ jobs: CI: true coverage: permissions: - checks: write # for coverallsapp/github-action to create new checks - contents: read # for actions/checkout to fetch code + 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: ['14.x'] + node-version: ["14.x"] steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} From f173abcb7be7c3d0580fcacc66e7602490bdd42b Mon Sep 17 00:00:00 2001 From: Uiolee <22849383+uiolee@users.noreply.github.com> Date: Sun, 22 Oct 2023 01:47:43 +0800 Subject: [PATCH 08/10] chore(github): use github issue form (#5319) Co-authored-by: D-Sketon <2055272094@qq.com> --- .github/ISSUE_TEMPLATE/bug_report.md | 93 ----------- .github/ISSUE_TEMPLATE/bug_report.yml | 148 ++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 2 +- .../feature-request-improvement.md | 23 --- .../feature-request-improvement.yml | 36 +++++ 5 files changed, 185 insertions(+), 117 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature-request-improvement.md create mode 100644 .github/ISSUE_TEMPLATE/feature-request-improvement.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 353fae2aca..0000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -name: Bug report -about: Something isn't working as expected -title: '' -labels: '' -assignees: '' - ---- - - - -## Check List - -Please check followings before submitting a new issue. - -- [ ] I have already read [Docs page](https://hexo.io/docs/) & [Troubleshooting page](https://hexo.io/docs/troubleshooting) -- [ ] I have already searched existing issues and they are not help to me -- [ ] I examined error or warning messages and it's difficult to solve -- [ ] Using [the latest](https://github.com/hexojs/hexo/releases) version of Hexo (run `hexo version` to check) -- [ ] Node.js is higher than [minimum required version](https://hexo.io/docs/#Minimum-required-Node-js-version) - -## Expected behavior - -## Actual behavior - -## How to reproduce? - -* Step1 -* Step2 -* etc... - -## Is the problem still there under "Safe mode"? - - - -## Environment & Settings - -**Node.js & npm version(`node -v && npm -v`)** - - - -``` -``` - -**Your site `_config.yml`** (Optional) - - - -```yaml -``` - -**Hexo and Plugin version(`npm ls --depth 0`)** - - - -``` -``` - -**Your package.json `package.json`** - - - -``` -``` - -## Others - - diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000000..4c1e219d45 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,148 @@ +name: Bug report +description: Something isn't working as expected. +# 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 + description: Please check followings before submitting a new issue. + 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? + description: How do you trigger this bug? Please walk us through it step by step. + placeholder: | + 1. Step1 + 2. Step2 + 3. etc. + ... + # value: + # render: + + - type: input + validations: + required: true + attributes: + label: Is the problem still there under `Safe mode`? + description: | + 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 + description: | + 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 + description: | + 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` + description: Please paste the content of `package.json` here. + placeholder: package.json + # value: + render: json + + - type: textarea + validations: + required: false + attributes: + label: Your site's `_config.yml` (Optional) + description: Please paste the content of your `_config.yml` here. + placeholder: _config.yml + # value: | + render: yaml + + - type: textarea + validations: + required: false + attributes: + label: Others + description: If you have other information. Please write here. + # placeholder: + # value: + # render: diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 3c6bdca6bd..5548b4bc8c 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -2,4 +2,4 @@ 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) \ No newline at end of file + about: I have a question, help for hexo (e.g. Customize) diff --git a/.github/ISSUE_TEMPLATE/feature-request-improvement.md b/.github/ISSUE_TEMPLATE/feature-request-improvement.md deleted file mode 100644 index 46f8ad6691..0000000000 --- a/.github/ISSUE_TEMPLATE/feature-request-improvement.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -name: Feature request / Improvement -about: I have a feature request, suggestion, improvement etc... -title: '' -labels: '' -assignees: '' - ---- - -## Check List - -Please check followings before submitting a new feature request. - -- [ ] I have already read [Docs page](https://hexo.io/docs/) -- [ ] I have already searched existing issues - -## Feature Request - - - -## Others - - diff --git a/.github/ISSUE_TEMPLATE/feature-request-improvement.yml b/.github/ISSUE_TEMPLATE/feature-request-improvement.yml new file mode 100644 index 0000000000..32db67e4e2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request-improvement.yml @@ -0,0 +1,36 @@ +name: Feature request / Improvement +description: I have a feature request, suggestion, improvement etc... +# title: "" +# labels: [] +# assignees: [] + +body: + - type: checkboxes + validations: + required: true + attributes: + label: Check List + description: Please check followings before submitting a new feature request. + 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 + description: Descripe the feature and why it is needed. + # placeholder: + # value: + # render: + + - type: textarea + validations: + required: false + attributes: + label: Others + description: If you have other information. Please write here. + # placeholder: + # value: + # render: From 3059fa074a832a948ba5560798e094a503309541 Mon Sep 17 00:00:00 2001 From: Sukka Date: Sun, 22 Oct 2023 03:56:56 +0800 Subject: [PATCH 09/10] perf(post): cache tags getter (#5145) Co-authored-by: uiolee <22849383+uiolee@users.noreply.github.com> --- lib/models/post.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/models/post.ts b/lib/models/post.ts index 56e9f8cf6f..10b274d7ad 100644 --- a/lib/models/post.ts +++ b/lib/models/post.ts @@ -3,7 +3,7 @@ import moment from 'moment'; import { extname, join, sep } from 'path'; import Promise from 'bluebird'; import Moment from './types/moment'; -import { full_url_for } from 'hexo-util'; +import { full_url_for, Cache } from 'hexo-util'; function pickID(data) { return data._id; @@ -13,6 +13,8 @@ function removeEmptyTag(tags) { return tags.filter(tag => tag != null && tag !== '').map(tag => `${tag}`); } +const tagsGetterCache = new Cache(); + export = ctx => { const Post = new warehouse.Schema({ id: String, @@ -60,12 +62,14 @@ export = ctx => { }); Post.virtual('tags').get(function() { - const PostTag = ctx.model('PostTag'); - const Tag = ctx.model('Tag'); + return tagsGetterCache.apply(this._id, () => { + const PostTag = ctx.model('PostTag'); + const Tag = ctx.model('Tag'); - const ids = PostTag.find({post_id: this._id}, {lean: true}).map(item => item.tag_id); + const ids = PostTag.find({post_id: this._id}, {lean: true}).map(item => item.tag_id); - return Tag.find({_id: {$in: ids}}); + return Tag.find({_id: {$in: ids}}); + }); }); Post.method('notPublished', function() { @@ -79,6 +83,7 @@ export = ctx => { // If the post is unpublished then the tag needs to be removed, thus the function cannot be returned early here tags = []; } + tagsGetterCache.flush(); tags = removeEmptyTag(tags); const PostTag = ctx.model('PostTag'); From 2a2cc9a89f3f291d2ba93e3a4d7eeb3b8ba98bbe Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Mon, 23 Oct 2023 13:38:39 +0800 Subject: [PATCH 10/10] revert: Access data files from source folder (#1969) (#5325) --- lib/hexo/index.ts | 2 +- .../filter/before_generate/render_post.ts | 3 +-- test/scripts/filters/render_post.js | 16 ---------------- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/lib/hexo/index.ts b/lib/hexo/index.ts index 21c14183fb..2d347c7bde 100644 --- a/lib/hexo/index.ts +++ b/lib/hexo/index.ts @@ -555,7 +555,7 @@ class Hexo extends EventEmitter { this.emit('generateBefore'); // Run before_generate filters - return this.execFilter('before_generate', this.locals.get('data'), { context: this }) + return this.execFilter('before_generate', null, { context: this }) .then(() => this._routerRefresh(this._runGenerators(), useCache)).then(() => { this.emit('generateAfter'); diff --git a/lib/plugins/filter/before_generate/render_post.ts b/lib/plugins/filter/before_generate/render_post.ts index ae202e9477..539b5dadda 100644 --- a/lib/plugins/filter/before_generate/render_post.ts +++ b/lib/plugins/filter/before_generate/render_post.ts @@ -1,12 +1,11 @@ import Promise from 'bluebird'; -function renderPostFilter(data) { +function renderPostFilter() { const renderPosts = model => { const posts = model.toArray().filter(post => post.content == null); return Promise.map(posts, (post: any) => { post.content = post._content; - post.site = {data}; return this.post.render(post.full_source, post).then(() => post.save()); }); diff --git a/test/scripts/filters/render_post.js b/test/scripts/filters/render_post.js index ab82f405b3..e5540cc7e4 100644 --- a/test/scripts/filters/render_post.js +++ b/test/scripts/filters/render_post.js @@ -46,20 +46,4 @@ describe('Render post', () => { page.remove(); }); - it('use data variables', async () => { - let page = await Page.insert({ - source: 'foo.md', - path: 'foo.html', - _content: '

Hello {{site.data.foo.name}}

' - }); - - const id = page._id; - await renderPost({foo: {name: 'Hexo'}}); - - page = Page.findById(id); - page.content.trim().should.eql('

Hello Hexo

'); - - page.remove(); - }); - });