Files
reference/themes/coo/scripts/seo.js
T
Fechin 172342c8a3 feat: modernize development toolchain
- Add comprehensive development tooling:
  * ESLint configuration with modern JavaScript rules
  * Prettier for consistent code formatting
  * Husky for Git hooks automation
  * lint-staged for pre-commit checks
  * Conventional Commits with commitlint
  * Stylelint for CSS code quality

- Fix CSS issues:
  * Resolve duplicate selectors in layout_note.css
  * Merge duplicate selectors in layout_list.css
  * Ensure stylelint compliance

- Apply consistent code formatting:
  * Format all JavaScript, CSS, and Markdown files
  * Standardize code style across the project
  * Fix console statement warnings in main.js

- Update project documentation:
  * Enhance README with modern development practices
  * Update package.json with new scripts and dependencies

This modernization establishes a robust development environment with
automated code quality checks, consistent formatting~
2025-06-18 14:09:17 +08:00

71 lines
2.2 KiB
JavaScript

const fs = require('fs');
const path = require('path');
hexo.extend.helper.register('page_title', function () {
let title = '';
if (this.is_home()) {
title = `${this.config.title} - ${this.config.subtitle}`;
} else if (this.page.layout === 'note') {
title = `${this.page.title} - ${this.config.title}`;
} else if (this.is_page()) {
title = `${this.page.title} - ${this.config.title}`;
} else if (this.is_post()) {
title = this.page.title;
const hasCommand = this.page.categories.findOne({ name: 'Linux Command' });
if (hasCommand) {
title += ' Command';
}
title = `${title} Cheat Sheet & Quick Reference`;
} else if (this.page._isNotePagination) {
title = `Page ${this.page.current} of Notes - ${this.config.title}`;
}
return title;
});
hexo.extend.helper.register('page_description', function () {
let description;
if (this.is_home()) {
description = this.config.description;
} else if (this.page && this.page.intro && this.page.intro.trim()) {
description = this.strip_html(this.markdown(this.page.intro)).substring(0, 110);
} else if (this.page && this.page.content) {
description = this.strip_html(this.page.content).substring(0, 130);
} else {
description = this.config.description || '';
}
description = description.replace(/[\r\n\s\s+]+/g, ' ');
return description;
});
hexo.extend.helper.register('page_keywords', function () {
let keywords = this.config.keywords;
if (this.page.tags && this.page.tags.each) {
this.page.tags.each((tag) => {
keywords += `,${tag.name}`;
});
}
return keywords;
});
hexo.extend.helper.register('page_image', function () {
const homePng = 'preview.png';
let postPng = '';
if (this.is_post()) {
postPng = `${this.page.slug}-preview.png`;
}
const version = (Math.random() + 1).toString(36).substring(7);
let imageURL;
// Check file exists
const postPath = path.resolve('./', 'source/assets/image/', postPng);
if (fs.existsSync(postPath)) {
// Generate image url
imageURL = `${this.config.url}/assets/image/${postPng}?v=${version}`;
} else {
// console.warn(`Warning: ${postPath} not Found!`);
imageURL = `${this.config.url}/assets/image/${homePng}?v=${version}`;
}
return imageURL;
});