mirror of
https://github.com/pockethost/pockethost.git
synced 2025-03-30 15:08:30 +00:00
59 lines
2.3 KiB
Diff
59 lines
2.3 KiB
Diff
diff --git a/node_modules/@dansvel/vite-plugin-markdown/dist/cjs/index.d.ts b/node_modules/@dansvel/vite-plugin-markdown/dist/cjs/index.d.ts
|
|
index a5f9715..d84ae89 100644
|
|
--- a/node_modules/@dansvel/vite-plugin-markdown/dist/cjs/index.d.ts
|
|
+++ b/node_modules/@dansvel/vite-plugin-markdown/dist/cjs/index.d.ts
|
|
@@ -4,8 +4,8 @@ export interface PluginOptions {
|
|
markedOptions?: marked.options;
|
|
withOrigin?: boolean;
|
|
}
|
|
-export interface Metadata {
|
|
- attributes: {};
|
|
+export interface Metadata<TAttributes extends {} = {}> {
|
|
+ attributes: TAttributes;
|
|
body: string;
|
|
}
|
|
export interface Result extends Metadata {
|
|
diff --git a/node_modules/@dansvel/vite-plugin-markdown/dist/mjs/index.js b/node_modules/@dansvel/vite-plugin-markdown/dist/mjs/index.js
|
|
index f405f8c..8beee2e 100644
|
|
--- a/node_modules/@dansvel/vite-plugin-markdown/dist/mjs/index.js
|
|
+++ b/node_modules/@dansvel/vite-plugin-markdown/dist/mjs/index.js
|
|
@@ -1,5 +1,8 @@
|
|
import frontMatter from 'front-matter';
|
|
import { marked } from 'marked';
|
|
+import { parse } from 'node-html-parser';
|
|
+import {reduce} from '@s-libs/micro-dash'
|
|
+
|
|
class Content {
|
|
variables = [];
|
|
#contextCode = '';
|
|
@@ -29,6 +32,29 @@ export default (options) => {
|
|
attributes,
|
|
body: marked.parse(body)
|
|
};
|
|
+ let outline = []
|
|
+ let currentOutline = undefined
|
|
+ let currentElements = []
|
|
+ parse(result.body).childNodes.forEach( (v)=>{
|
|
+ if(v.rawTagName==='h2') {
|
|
+ if(currentOutline) {
|
|
+ currentOutline.body = currentElements.map(e=>e.outerHTML).join(`\n`)
|
|
+ outline.push(currentOutline)
|
|
+ }
|
|
+ currentOutline =
|
|
+ {
|
|
+ title: v.text,
|
|
+ }
|
|
+ currentElements = []
|
|
+ return
|
|
+ }
|
|
+ currentElements.push(v)
|
|
+ })
|
|
+ if(currentOutline) {
|
|
+ currentOutline.body = currentElements.map(e=>e.outerHTML).join(`\n`)
|
|
+ outline.push(currentOutline)
|
|
+ }
|
|
+ result.outline = outline
|
|
if (options.withOrigin) {
|
|
result = {
|
|
...result,
|