markedpage
Advanced tools
Comparing version 0.1.13-next.4 to 0.1.13-next.5
@@ -1,2 +0,2 @@ | ||
const CONTENT_UPDATE_EVENT = 'markedpage:content-update'; | ||
import { C as CONTENT_UPDATE_EVENT } from './common-48ec8bf3.js'; | ||
@@ -3,0 +3,0 @@ const onContentUpdate = (callback) => { |
@@ -1,80 +0,176 @@ | ||
import { Plugin } from 'vite'; | ||
declare module "markedpage" { | ||
export const onContentUpdate: (callback: (payload: Record<string, any>) => void) => void; | ||
} | ||
interface SourcePage extends Record<string, any> { | ||
frontMatter: Record<string, any>; | ||
sourcePath: string; | ||
indexPath: string; | ||
headings: Array<HeadingItem>; | ||
render: (() => Promise<string>) | any; | ||
raw: () => Promise<string>; | ||
slugKey: string; | ||
declare module "markedpage/helper" { | ||
export { onContentUpdate } from "markedpage"; | ||
} | ||
interface PageMapCollection { | ||
pathMap: Record<string, SourcePage>; | ||
slugMap: Record<string, Array<SourcePage>>; | ||
declare module "markedpage" { | ||
export interface SourcePage extends Record<string, any> { | ||
frontMatter: Record<string, any>; | ||
sourcePath: string; | ||
indexPath: string; | ||
headings: Array<HeadingItem>; | ||
render: (() => Promise<string>) | any; | ||
raw: () => Promise<string>; | ||
slugKey: string; | ||
} | ||
export interface PageMapCollection { | ||
pathMap: Record<string, SourcePage>; | ||
slugMap: Record<string, Array<SourcePage>>; | ||
} | ||
export interface SiteConfigDefault extends Record<string, any> { | ||
extendPageData?: (pages: SourcePage) => Promise<void>; | ||
marked?: MarkedConfig; | ||
classifier?: Array<ClassifierOptions>; | ||
} | ||
export interface SourceParams extends Record<string, any> { | ||
sourcePath: string; | ||
indexPath: string; | ||
fullPath: string; | ||
} | ||
export interface MarkedConfig { | ||
options: Record<string, any>; | ||
extensions: Array<any>; | ||
} | ||
export interface HeadingItem extends Record<string, any> { | ||
depth: number; | ||
text: string; | ||
raw: string; | ||
id: string; | ||
} | ||
export interface ClassifierOptions<Locals = Record<string, any>> { | ||
id: string; | ||
type: ClassifierType; | ||
params: Locals; | ||
} | ||
export interface ClassifierHandle<Locals = Record<string, any>, Result = Record<string, any>> { | ||
(input: { | ||
options: ClassifierOptions<Locals>; | ||
pages: Array<SourcePage> | any; | ||
}): Promise<Result>; | ||
} | ||
export type ClassifierType = 'directory' | 'frontmatter' | ClassifierHandle; | ||
} | ||
interface HeadingItem extends Record<string, any> { | ||
depth: number; | ||
text: string; | ||
raw: string; | ||
id: string; | ||
declare module "markedpage" { | ||
export const isDev: () => boolean; | ||
export const getAbsoultPath: (relativePath: string) => string; | ||
export const getRelativePath: (absoultPath: string) => string; | ||
export const getSlugParams: (indexPath: string) => { | ||
slugKey: string; | ||
slugDate: Date; | ||
}; | ||
export const getPageAttribute: (body: string) => Promise<{ | ||
metadata: Record<string, any>; | ||
headings: HeadingItem[]; | ||
}>; | ||
export const extractBody: (body: string) => Promise<string>; | ||
export const extractExcerpt: (body: string) => { | ||
excerpt: string; | ||
body: string; | ||
}; | ||
export const extractHeading: (body: string) => Array<HeadingItem>; | ||
} | ||
interface ClassifierOptions<Locals = Record<string, any>> { | ||
id: string; | ||
type: ClassifierType; | ||
params: Locals; | ||
declare module "markedpage" { | ||
export const logger: { | ||
debug: (message: any, ...options: any[]) => void; | ||
warn: (message: any, ...options: any[]) => void; | ||
error: (message: any, ...options: any[]) => void; | ||
info: (message: any, ...options: any[]) => void; | ||
}; | ||
} | ||
interface ClassifierHandle<Locals = Record<string, any>, Result = Record<string, any>> { | ||
(input: { | ||
options: ClassifierOptions<Locals>; | ||
pages: Array<SourcePage> | any; | ||
}): Promise<Result>; | ||
declare module "markedpage" { | ||
export const getConfig: (configPath?: string) => Promise<Record<string, any>>; | ||
export const setConfig: (config: Record<string, any>) => void; | ||
export const initConfigDefault: (configPath?: string) => Promise<SiteConfigDefault>; | ||
export const getPageMap: (config: SiteConfigDefault, sourceDir?: string) => Promise<PageMapCollection>; | ||
export const initPageMap: (config: SiteConfigDefault, sourceDir?: string) => Promise<void>; | ||
export const reloadSourcePage: (config: SiteConfigDefault, sourcePath: string, content: string) => Promise<{ | ||
frontMatter: Record<string, any>; | ||
sourcePath: string; | ||
indexPath: any; | ||
headings: import("types").HeadingItem[]; | ||
render: () => Promise<string>; | ||
raw: () => Promise<string>; | ||
slugKey: string; | ||
}>; | ||
} | ||
declare type ClassifierType = 'directory' | 'frontmatter' | ClassifierHandle; | ||
/** | ||
* Get siteConfig | ||
* | ||
* @async | ||
* @return {Promise<Record<string, any>>} custom config. | ||
*/ | ||
declare const siteConfig: () => Promise<Record<string, any>>; | ||
/** | ||
* Get All source page, index by indexPath | ||
* | ||
* @async | ||
* @return {Promise<Record<string, SourcePage>>} key: IndexPath value: SourcePage | ||
*/ | ||
declare const pathMap: () => Promise<Record<string, SourcePage>>; | ||
/** | ||
* Get All source page, index by slugName | ||
* | ||
* @async | ||
* @return {Promise<Record<string, Array<SourcePage>>>} | ||
*/ | ||
declare const slugMap: () => Promise<Record<string, Array<SourcePage>>>; | ||
/** | ||
* Get classified pages set. | ||
* | ||
* @async | ||
* @param {string} classifierId | ||
* @return {Promise<Record<string,any>>} | ||
*/ | ||
declare const classifiedSet: (classifierId: string) => Promise<any>; | ||
/** | ||
* Get page by key. | ||
* @param indexKey SlugKey | indexPath | ||
* @param slugMatchFunc | ||
* @returns | ||
*/ | ||
declare const getPage: (indexKey: string, slugMatchFunc?: (page: SourcePage) => boolean) => Promise<SourcePage>; | ||
declare module "markedpage" { | ||
interface DirectoryClassifierParams { | ||
path: string; | ||
} | ||
export interface DirectoryClassifierResult { | ||
pages: Array<SourcePage>; | ||
} | ||
export const DirectoryClassifierHandle: ClassifierHandle<DirectoryClassifierParams, DirectoryClassifierResult>; | ||
} | ||
declare const markedpageVitePlugin: (siteConfig?: Record<string, any>) => Plugin; | ||
declare module "markedpage" { | ||
interface FrontMatterClassifierParams { | ||
keys: Array<string>; | ||
} | ||
export type FrontMatterClassifierResult = Record<string, Array<SourcePage>>; | ||
export const FrontMatterClassifierHandle: ClassifierHandle<FrontMatterClassifierParams, FrontMatterClassifierResult>; | ||
} | ||
interface DirectoryClassifierResult { | ||
pages: Array<SourcePage>; | ||
declare module "markedpage" { | ||
interface ClassifierObject { | ||
(pages: Array<SourcePage>): Promise<Record<string, any>>; | ||
} | ||
interface ClassiferMapHandler { | ||
(classifierList: Array<ClassifierOptions>): Promise<Record<string, ClassifierObject>>; | ||
} | ||
export let isInitial: boolean; | ||
export const getClassifiedResult: (classifierId: string, pages: Array<SourcePage>) => Promise<any>; | ||
export const initClassifierMap: ClassiferMapHandler; | ||
} | ||
declare type FrontMatterClassifierResult = Record<string, Array<SourcePage>>; | ||
declare module "markedpage" { | ||
/** | ||
* Get siteConfig | ||
* | ||
* @async | ||
* @return {Promise<Record<string, any>>} custom config. | ||
*/ | ||
export const siteConfig: () => Promise<Record<string, any>>; | ||
/** | ||
* Get All source page, index by indexPath | ||
* | ||
* @async | ||
* @return {Promise<Record<string, SourcePage>>} key: IndexPath value: SourcePage | ||
*/ | ||
export const pathMap: () => Promise<Record<string, SourcePage>>; | ||
/** | ||
* Get All source page, index by slugName | ||
* | ||
* @async | ||
* @return {Promise<Record<string, Array<SourcePage>>>} | ||
*/ | ||
export const slugMap: () => Promise<Record<string, Array<SourcePage>>>; | ||
/** | ||
* Get classified pages set. | ||
* | ||
* @async | ||
* @param {string} classifierId | ||
* @return {Promise<Record<string,any>>} | ||
*/ | ||
export const classifiedSet: (classifierId: string) => Promise<any>; | ||
/** | ||
* Get page by key. | ||
* @param indexKey SlugKey | indexPath | ||
* @param slugMatchFunc | ||
* @returns | ||
*/ | ||
export const getPage: (indexKey: string, slugMatchFunc?: (page: SourcePage) => boolean) => Promise<SourcePage>; | ||
export const pageMap: () => Promise<import("types").PageMapCollection>; | ||
} | ||
export { ClassifierHandle, ClassifierOptions, DirectoryClassifierResult, FrontMatterClassifierResult, PageMapCollection, SourcePage, classifiedSet, getPage, markedpageVitePlugin, pathMap, siteConfig, slugMap }; | ||
declare module "markedpage" { | ||
import type { Plugin } from "vite"; | ||
export const markedpageVitePlugin: (siteConfig?: Record<string, any>) => Plugin; | ||
} |
@@ -7,2 +7,3 @@ import fs from 'fs'; | ||
import { green, cyan } from 'kleur/colors'; | ||
import { C as CONTENT_UPDATE_EVENT } from './common-48ec8bf3.js'; | ||
@@ -530,4 +531,2 @@ const isDev = () => process.env.NODE_ENV == 'development'; | ||
const CONTENT_UPDATE_EVENT = 'markedpage:content-update'; | ||
const markedpageVitePlugin = (siteConfig) => { | ||
@@ -534,0 +533,0 @@ return { |
{ | ||
"version": "0.1.13-next.4", | ||
"version": "0.1.13-next.5", | ||
"name": "markedpage", | ||
@@ -29,3 +29,3 @@ "type": "module", | ||
"@types/marked": "^4.0.5", | ||
"@types/node": "^18.7.6", | ||
"@types/node": "^18.7.8", | ||
"@types/remove-markdown": "^0.3.1", | ||
@@ -39,5 +39,5 @@ "@typescript-eslint/eslint-plugin": "^4.33.0", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.78.0", | ||
"rollup-plugin-dts": "^4.2.2", | ||
"rollup": "^2.78.1", | ||
"rollup-plugin-exclude-dependencies-from-bundle": "^1.1.22", | ||
"rollup-plugin-flat-dts": "^1.6.1", | ||
"tslib": "^2.4.0", | ||
@@ -47,3 +47,3 @@ "tsm": "^2.2.2", | ||
"uvu": "^0.5.6", | ||
"vite": "^3.0.8" | ||
"vite": "^3.0.9" | ||
}, | ||
@@ -50,0 +50,0 @@ "repository": { |
31433
649