feature: vor und nachteile

This commit is contained in:
Hikyu
2026-05-31 13:54:31 +02:00
parent 552a947a1c
commit e3dad17446
23270 changed files with 3024794 additions and 200 deletions
+32
View File
@@ -0,0 +1,32 @@
'use strict';
const grayMatter = require('gray-matter');
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
const grayMatter__default = /*#__PURE__*/_interopDefaultCompat(grayMatter);
const frontmatterPlugin = (md, { grayMatterOptions, renderExcerpt = true } = {}) => {
const parse = md.parse.bind(md);
md.parse = (src, env = {}) => {
const { data, content, excerpt = "" } = grayMatter__default(src, grayMatterOptions);
env.content = content;
env.frontmatter = {
// allow providing default value
...env.frontmatter,
...data
};
env.excerpt = renderExcerpt && excerpt ? (
// render the excerpt with original markdown-it render method.
// here we spread `env` to avoid mutating the original object.
// using deep clone might be a safer choice.
md.render(excerpt, { ...env })
) : (
// use the raw excerpt directly
excerpt
);
return parse(content, env);
};
};
exports.frontmatterPlugin = frontmatterPlugin;
@@ -0,0 +1,50 @@
import { PluginWithOptions } from 'markdown-it';
import matter from 'gray-matter';
type GrayMatterOptions = matter.GrayMatterOption<string, GrayMatterOptions>;
/**
* Options of @mdit-vue/plugin-frontmatter
*/
interface FrontmatterPluginOptions {
/**
* Options of gray-matter
*
* @see https://github.com/jonschlinkert/gray-matter#options
*/
grayMatterOptions?: GrayMatterOptions;
/**
* Render the excerpt or not
*
* @default true
*/
renderExcerpt?: boolean;
}
declare module '@mdit-vue/types' {
interface MarkdownItEnv {
/**
* The raw Markdown content without frontmatter
*/
content?: string;
/**
* The excerpt that extracted by `@mdit-vue/plugin-frontmatter`
*
* - Would be the rendered HTML when `renderExcerpt` is enabled
* - Would be the raw Markdown when `renderExcerpt` is disabled
*/
excerpt?: string;
/**
* The frontmatter that extracted by `@mdit-vue/plugin-frontmatter`
*/
frontmatter?: Record<string, unknown>;
}
}
/**
* Get markdown frontmatter and excerpt
*
* Extract them into env
*/
declare const frontmatterPlugin: PluginWithOptions<FrontmatterPluginOptions>;
export { frontmatterPlugin };
export type { FrontmatterPluginOptions };
@@ -0,0 +1,50 @@
import { PluginWithOptions } from 'markdown-it';
import matter from 'gray-matter';
type GrayMatterOptions = matter.GrayMatterOption<string, GrayMatterOptions>;
/**
* Options of @mdit-vue/plugin-frontmatter
*/
interface FrontmatterPluginOptions {
/**
* Options of gray-matter
*
* @see https://github.com/jonschlinkert/gray-matter#options
*/
grayMatterOptions?: GrayMatterOptions;
/**
* Render the excerpt or not
*
* @default true
*/
renderExcerpt?: boolean;
}
declare module '@mdit-vue/types' {
interface MarkdownItEnv {
/**
* The raw Markdown content without frontmatter
*/
content?: string;
/**
* The excerpt that extracted by `@mdit-vue/plugin-frontmatter`
*
* - Would be the rendered HTML when `renderExcerpt` is enabled
* - Would be the raw Markdown when `renderExcerpt` is disabled
*/
excerpt?: string;
/**
* The frontmatter that extracted by `@mdit-vue/plugin-frontmatter`
*/
frontmatter?: Record<string, unknown>;
}
}
/**
* Get markdown frontmatter and excerpt
*
* Extract them into env
*/
declare const frontmatterPlugin: PluginWithOptions<FrontmatterPluginOptions>;
export { frontmatterPlugin };
export type { FrontmatterPluginOptions };
@@ -0,0 +1,50 @@
import { PluginWithOptions } from 'markdown-it';
import matter from 'gray-matter';
type GrayMatterOptions = matter.GrayMatterOption<string, GrayMatterOptions>;
/**
* Options of @mdit-vue/plugin-frontmatter
*/
interface FrontmatterPluginOptions {
/**
* Options of gray-matter
*
* @see https://github.com/jonschlinkert/gray-matter#options
*/
grayMatterOptions?: GrayMatterOptions;
/**
* Render the excerpt or not
*
* @default true
*/
renderExcerpt?: boolean;
}
declare module '@mdit-vue/types' {
interface MarkdownItEnv {
/**
* The raw Markdown content without frontmatter
*/
content?: string;
/**
* The excerpt that extracted by `@mdit-vue/plugin-frontmatter`
*
* - Would be the rendered HTML when `renderExcerpt` is enabled
* - Would be the raw Markdown when `renderExcerpt` is disabled
*/
excerpt?: string;
/**
* The frontmatter that extracted by `@mdit-vue/plugin-frontmatter`
*/
frontmatter?: Record<string, unknown>;
}
}
/**
* Get markdown frontmatter and excerpt
*
* Extract them into env
*/
declare const frontmatterPlugin: PluginWithOptions<FrontmatterPluginOptions>;
export { frontmatterPlugin };
export type { FrontmatterPluginOptions };
+26
View File
@@ -0,0 +1,26 @@
import grayMatter from 'gray-matter';
const frontmatterPlugin = (md, { grayMatterOptions, renderExcerpt = true } = {}) => {
const parse = md.parse.bind(md);
md.parse = (src, env = {}) => {
const { data, content, excerpt = "" } = grayMatter(src, grayMatterOptions);
env.content = content;
env.frontmatter = {
// allow providing default value
...env.frontmatter,
...data
};
env.excerpt = renderExcerpt && excerpt ? (
// render the excerpt with original markdown-it render method.
// here we spread `env` to avoid mutating the original object.
// using deep clone might be a safer choice.
md.render(excerpt, { ...env })
) : (
// use the raw excerpt directly
excerpt
);
return parse(content, env);
};
};
export { frontmatterPlugin };