Skip to content

Commit

Permalink
Rename repository to hexo-filter-mourning
Browse files Browse the repository at this point in the history
  • Loading branch information
zkqiang committed Jan 25, 2024
1 parent 7fda945 commit 088edf0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $ npm i hexo-filter-mourning --save
In your site's `_config.yml`:

```yaml
memorial_day:
mourning:
# It's recommended to disable it when not in use
enable: true
# Specify the date(s) to be greyed out. You can set dates in the format yyyy-MM-dd or MM-dd
Expand Down
17 changes: 8 additions & 9 deletions lib/filter.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module.exports = function (html, data) {
const config = this.config;

if (!config.memorial_day || !config.memorial_day.enable || html.search('<html') === -1 || html.search('grayscale(100%)') > -1) {
if (!config.mourning || !config.mourning.enable || html.search('<html') === -1 || html.search('grayscale(100%)') > -1) {
return html;
}

let { day: days } = config.memorial_day;
let { day: days } = config.mourning;
if (days.length === 0) {
this.log.error('hexo-memorial-day: The day value is empty or not an array');
this.log.error('hexo-filter-mourning: The day value is empty or not an array');
return html;
}
if (!Array.isArray(days)) {
Expand All @@ -18,17 +18,17 @@ module.exports = function (html, data) {
if (day instanceof Date) {
// yyyy-MM-dd format is converted to Date type by Hexo
if (isNaN(day.getTime()) || day.getTime() <= 0) {
this.log.error(`hexo-memorial-day: The day ${day} is invalid`);
this.log.error(`hexo-filter-mourning: The day ${day} is invalid`);
return;
}
days[i] = dateToString(day);
} else if (typeof day === 'string') {
if (!/^\d{4}[/-]\d{1,2}[/-]\d{1,2}$/.test(day) && !/^\d{1,2}[/-]\d{1,2}$/.test(day)) {
this.log.error(`hexo-memorial-day: The day ${day} is invalid`);
this.log.error(`hexo-filter-mourning: The day ${day} is invalid`);
return;
}
} else {
this.log.error(`hexo-memorial-day: The day ${day} is invalid`);
this.log.error(`hexo-filter-mourning: The day ${day} is invalid`);
return;
}
}
Expand All @@ -53,10 +53,9 @@ module.exports = function (html, data) {
if (!/^\\d{4}\\/\\d{1,2}\\/\\d{1,2}$/.test(dayStr)) {
dayStr = \`\${now.getFullYear()}/\${dayStr}\`;
}
const memorialDay = new Date(dayStr);
const isMemorialDay = now.toDateString() === memorialDay.toDateString();
const isMourningDay = now.toDateString() === new Date(dayStr).toDateString();
if (isMemorialDay) {
if (isMourningDay) {
const style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = \`${css}\`;
Expand Down
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
{
"name": "hexo-memorial-day",
"version": "0.3.0",
"description": "Grey your hexo site on the memorial day.",
"name": "hexo-filter-mourning",
"version": "1.0.0",
"description": "Grey your hexo site on the mourning day",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/fluid-dev/hexo-memorial-day.git"
"url": "git+https://github.com/fluid-dev/hexo-filter-mourning.git"
},
"bugs": {
"url": "https://github.com/fluid-dev/hexo-memorial-day/issues"
"url": "https://github.com/fluid-dev/hexo-filter-mourning/issues"
},
"homepage": "https://github.com/fluid-dev/hexo-memorial-day",
"homepage": "https://github.com/fluid-dev/hexo-filter-mourning",
"keywords": [
"hexo",
"memorial",
"day",
"plugin",
"grey"
],
"directories": {
Expand Down

0 comments on commit 088edf0

Please sign in to comment.