first commit

This commit is contained in:
Missdrop
2025-07-16 16:30:56 +00:00
commit 7ee33927cb
11326 changed files with 1230901 additions and 0 deletions

61
node_modules/hexo-front-matter/README.md generated vendored Normal file
View File

@@ -0,0 +1,61 @@
# hexo-front-matter
[![Build Status](https://github.com/hexojs/hexo-front-matter/workflows/Tester/badge.svg)](https://github.com/hexojs/hexo-front-matter/actions?query=workflow%3ATester)
[![NPM version](https://badge.fury.io/js/hexo-front-matter.svg)](https://www.npmjs.com/package/hexo-front-matter)
[![Coverage Status](https://coveralls.io/repos/hexojs/hexo-front-matter/badge.svg?branch=master)](https://coveralls.io/r/hexojs/hexo-front-matter?branch=master)
Front-matter parser.
## What is Front-matter?
Front-matter allows you to specify data at the top of a file. Here are two formats:
**YAML front-matter**
```
---
layout: false
title: "Hello world"
---
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
```
**JSON front-matter**
```
;;;
"layout": false,
"title": "Hello world"
;;;
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
```
Prefixing separators are optional.
## API
### parse(str, [options])
Parses front-matter.
### stringify(obj, [options])
Converts an object to a front-matter string.
Option | Description | Default
--- | --- | ---
`mode` | The mode can be either `json` or `yaml`. | `yaml`
`separator` | Separator | `---`
`prefixSeparator` | Add prefixing separator. | `false`
### split(str)
Splits a YAML front-matter string.
### escape(str)
Converts hard tabs to soft tabs.
## License
MIT

21
node_modules/hexo-front-matter/dist/front_matter.d.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import yaml from 'js-yaml';
declare function split(str: string): {
data: string;
content: string;
separator: string;
prefixSeparator: boolean;
} | {
content: string;
data?: undefined;
separator?: undefined;
prefixSeparator?: undefined;
};
declare function parse(str: string, options?: yaml.LoadOptions): any;
declare function escapeYAML(str: string): string;
interface Options {
mode?: 'json' | '';
prefixSeparator?: boolean;
separator?: string;
}
declare function stringify(obj: any, options?: Options): any;
export { parse, split, escapeYAML as escape, stringify };

158
node_modules/hexo-front-matter/dist/front_matter.js generated vendored Normal file
View File

@@ -0,0 +1,158 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.stringify = exports.escape = exports.split = exports.parse = void 0;
const js_yaml_1 = __importDefault(require("js-yaml"));
const rPrefixSep = /^(-{3,}|;{3,})/;
const rFrontMatter = /^(-{3,}|;{3,})\n([\s\S]+?)\n\1\n?([\s\S]*)/;
const rFrontMatterNew = /^([\s\S]+?)\n(-{3,}|;{3,})\n?([\s\S]*)/;
function split(str) {
if (typeof str !== 'string')
throw new TypeError('str is required!');
const matchOld = str.match(rFrontMatter);
if (matchOld) {
return {
data: matchOld[2],
content: matchOld[3] || '',
separator: matchOld[1],
prefixSeparator: true
};
}
if (rPrefixSep.test(str))
return { content: str };
const matchNew = str.match(rFrontMatterNew);
if (matchNew) {
return {
data: matchNew[1],
content: matchNew[3] || '',
separator: matchNew[2],
prefixSeparator: false
};
}
return { content: str };
}
exports.split = split;
function parse(str, options) {
if (typeof str !== 'string')
throw new TypeError('str is required!');
const splitData = split(str);
const raw = splitData.data;
if (!raw)
return { _content: str };
let data;
if (splitData.separator.startsWith(';')) {
data = parseJSON(raw);
}
else {
data = parseYAML(raw, options);
}
if (!data)
return { _content: str };
// Convert timezone
Object.keys(data).forEach(key => {
const item = data[key];
if (item instanceof Date) {
data[key] = new Date(item.getTime() + (item.getTimezoneOffset() * 60 * 1000));
}
});
data._content = splitData.content;
return data;
}
exports.parse = parse;
function parseYAML(str, options) {
const result = js_yaml_1.default.load(escapeYAML(str), options);
if (typeof result !== 'object')
return;
return result;
}
function parseJSON(str) {
try {
return JSON.parse(`{${str}}`);
}
catch (err) {
return; // eslint-disable-line
}
}
function escapeYAML(str) {
if (typeof str !== 'string')
throw new TypeError('str is required!');
return str.replace(/\n(\t+)/g, (match, tabs) => {
let result = '\n';
for (let i = 0, len = tabs.length; i < len; i++) {
result += ' ';
}
return result;
});
}
exports.escape = escapeYAML;
function stringify(obj, options = {}) {
if (!obj)
throw new TypeError('obj is required!');
const { _content: content = '' } = obj;
delete obj._content;
if (!Object.keys(obj).length)
return content;
const { mode, prefixSeparator } = options;
const separator = options.separator || (mode === 'json' ? ';;;' : '---');
let result = '';
if (prefixSeparator)
result += `${separator}\n`;
if (mode === 'json') {
result += stringifyJSON(obj);
}
else {
result += stringifyYAML(obj, options);
}
result += `${separator}\n${content}`;
return result;
}
exports.stringify = stringify;
function stringifyYAML(obj, options) {
const keys = Object.keys(obj);
const data = {};
const nullKeys = [];
const dateKeys = [];
let key, value, i, len;
for (i = 0, len = keys.length; i < len; i++) {
key = keys[i];
value = obj[key];
if (value == null) {
nullKeys.push(key);
}
else if (value instanceof Date) {
dateKeys.push(key);
}
else {
data[key] = value;
}
}
let result = js_yaml_1.default.dump(data, options);
if (dateKeys.length) {
for (i = 0, len = dateKeys.length; i < len; i++) {
key = dateKeys[i];
result += `${key}: ${formatDate(obj[key])}\n`;
}
}
if (nullKeys.length) {
for (i = 0, len = nullKeys.length; i < len; i++) {
result += `${nullKeys[i]}:\n`;
}
}
return result;
}
function stringifyJSON(obj) {
return JSON.stringify(obj, null, ' ')
// Remove indention
.replace(/\n {2}/g, () => '\n')
// Remove prefixing and trailing braces
.replace(/^{\n|}$/g, '');
}
function doubleDigit(num) {
return num.toString().padStart(2, '0');
}
function formatDate(date) {
return `${date.getFullYear()}-${doubleDigit(date.getMonth() + 1)}-${doubleDigit(date.getDate())} ${doubleDigit(date.getHours())}:${doubleDigit(date.getMinutes())}:${doubleDigit(date.getSeconds())}`;
}
//# sourceMappingURL=front_matter.js.map

File diff suppressed because one or more lines are too long

49
node_modules/hexo-front-matter/package.json generated vendored Normal file
View File

@@ -0,0 +1,49 @@
{
"name": "hexo-front-matter",
"version": "4.2.1",
"description": "Front-matter parser.",
"main": "dist/front_matter",
"scripts": {
"prepublish ": "npm run clean && npm run build",
"build": "tsc -b",
"clean": "tsc -b --clean",
"eslint": "eslint .",
"pretest": "npm run clean && npm run build",
"test": "mocha test/index.js --require ts-node/register",
"test-cov": "c8 --reporter=lcovonly npm run test"
},
"files": [
"dist/**"
],
"types": "./dist/front_matter.d.ts",
"repository": "hexojs/hexo-front-matter",
"keywords": [
"front-matter",
"front matter",
"yaml",
"yml",
"hexo",
"json"
],
"author": "Tommy Chen <tommy351@gmail.com> (http://zespia.tw)",
"license": "MIT",
"dependencies": {
"js-yaml": "^4.1.0"
},
"devDependencies": {
"@types/js-yaml": "^4.0.5",
"@types/node": "^18.11.7",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
"c8": "^8.0.0",
"chai": "^4.3.6",
"eslint": "^8.23.1",
"eslint-config-hexo": "^5.0.0",
"mocha": "^10.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
},
"engines": {
"node": ">=14"
}
}