vitepress
Advanced tools
Comparing version 1.0.0-alpha.1 to 1.0.0-alpha.2
@@ -1,2 +0,2 @@ | ||
import { createApp as createClientApp, createSSRApp, defineAsyncComponent, h, onMounted, watch } from 'vue'; | ||
import { createApp as createClientApp, createSSRApp, h, onMounted, watch } from 'vue'; | ||
import Theme from '/@theme/index'; | ||
@@ -31,3 +31,2 @@ import { inBrowser, pathToFile } from './utils'; | ||
const router = newRouter(); | ||
handleHMR(router); | ||
const app = newApp(); | ||
@@ -40,5 +39,2 @@ app.provide(RouterSymbol, router); | ||
app.component('ClientOnly', ClientOnly); | ||
app.component('Debug', import.meta.env.PROD | ||
? () => null | ||
: defineAsyncComponent(() => import('./components/Debug.vue'))); | ||
// expose $frontmatter | ||
@@ -57,2 +53,6 @@ Object.defineProperty(app.config.globalProperties, '$frontmatter', { | ||
} | ||
// setup devtools in dev mode | ||
if (import.meta.env.DEV || __VUE_PROD_DEVTOOLS__) { | ||
import('./devtools').then(({ setupDevtools }) => setupDevtools(app, router, data)); | ||
} | ||
return { app, router, data }; | ||
@@ -85,18 +85,2 @@ } | ||
} | ||
function handleHMR(router) { | ||
// update route.data on HMR updates of active page | ||
if (import.meta.hot) { | ||
// hot reload pageData | ||
import.meta.hot.on('vitepress:pageData', (payload) => { | ||
if (shouldHotReload(payload)) { | ||
router.route.data = payload.pageData; | ||
} | ||
}); | ||
} | ||
} | ||
function shouldHotReload(payload) { | ||
const payloadPath = payload.path.replace(/(\bindex)?\.md$/, ''); | ||
const locationPath = location.pathname.replace(/(\bindex)?\.html$/, ''); | ||
return payloadPath === locationPath; | ||
} | ||
if (inBrowser) { | ||
@@ -103,0 +87,0 @@ const { app, router, data } = createApp(); |
import { reactive, inject, markRaw, nextTick, readonly } from 'vue'; | ||
import { notFoundPageData } from '../shared'; | ||
import { inBrowser, withBase } from './utils'; | ||
@@ -8,10 +9,2 @@ import { siteDataRef } from './data'; | ||
const fakeHost = `http://a.com`; | ||
const notFoundPageData = { | ||
relativePath: '', | ||
title: '404', | ||
description: 'Not Found', | ||
headers: [], | ||
frontmatter: {}, | ||
lastUpdated: 0 | ||
}; | ||
const getDefaultRoute = () => ({ | ||
@@ -58,4 +51,4 @@ path: '/', | ||
route.data = import.meta.env.PROD | ||
? markRaw(JSON.parse(__pageData)) | ||
: readonly(JSON.parse(__pageData)); | ||
? markRaw(__pageData) | ||
: readonly(__pageData); | ||
if (inBrowser) { | ||
@@ -82,3 +75,3 @@ nextTick(() => { | ||
catch (err) { | ||
if (!err.message.match(/fetch/)) { | ||
if (!err.message.match(/fetch/) && !href.match(/^[\\/]404\.html$/)) { | ||
console.error(err); | ||
@@ -146,2 +139,3 @@ } | ||
} | ||
handleHMR(route); | ||
return { | ||
@@ -197,1 +191,17 @@ route, | ||
} | ||
function handleHMR(route) { | ||
// update route.data on HMR updates of active page | ||
if (import.meta.hot) { | ||
// hot reload pageData | ||
import.meta.hot.on('vitepress:pageData', (payload) => { | ||
if (shouldHotReload(payload)) { | ||
route.data = payload.pageData; | ||
} | ||
}); | ||
} | ||
} | ||
function shouldHotReload(payload) { | ||
const payloadPath = payload.path.replace(/(\bindex)?\.md$/, ''); | ||
const locationPath = location.pathname.replace(/(\bindex)?\.html$/, ''); | ||
return payloadPath === locationPath; | ||
} |
@@ -121,4 +121,2 @@ import * as vue from 'vue'; | ||
declare const Debug: vue.ComponentOptions<{}, any, any, any, any, any, any, any>; | ||
export { Content, Debug, EnhanceAppContext, HeadConfig, Header, LocaleConfig, PageData, Route, Router, SiteData, Theme, VitePressData, inBrowser, useData, useRoute, useRouter, withBase }; | ||
export { Content, EnhanceAppContext, HeadConfig, Header, LocaleConfig, PageData, Route, Router, SiteData, Theme, VitePressData, inBrowser, useData, useRoute, useRouter, withBase }; |
@@ -10,3 +10,1 @@ // exports in this file are exposed to themes and md files via 'vitepress' | ||
export { Content } from './app/components/Content'; | ||
import _Debug from './app/components/Debug.vue'; | ||
export const Debug = _Debug; |
@@ -5,2 +5,10 @@ export const EXTERNAL_URL_RE = /^https?:/i; | ||
export const inBrowser = typeof window !== 'undefined'; | ||
export const notFoundPageData = { | ||
relativePath: '', | ||
title: '404', | ||
description: 'Not Found', | ||
headers: [], | ||
frontmatter: {}, | ||
lastUpdated: 0 | ||
}; | ||
function findMatchRoot(route, roots) { | ||
@@ -7,0 +15,0 @@ // first match to the routes with the most deep level. |
@@ -6,18 +6,7 @@ import { computed } from 'vue'; | ||
return computed(() => { | ||
const url = [ | ||
'https://github.com', | ||
theme.value.editLink?.repo || '???', | ||
'edit', | ||
theme.value.editLink?.branch || 'main', | ||
theme.value.editLink?.dir || null, | ||
page.value.relativePath | ||
] | ||
.filter((v) => v) | ||
.join('/'); | ||
const text = theme.value.editLink?.text ?? 'Edit this page'; | ||
return { | ||
url, | ||
text | ||
}; | ||
const { text = 'Edit this page', pattern } = theme.value.editLink || {}; | ||
const { relativePath } = page.value; | ||
const url = pattern.replace(/:path/g, relativePath); | ||
return { url, text }; | ||
}); | ||
} |
@@ -1,2 +0,2 @@ | ||
import { h as c, e as createServer, g as build, s as serve } from './serve-e8d58be3.js'; | ||
import { h as c, e as createServer, g as build, s as serve } from './serve-42a92e2f.js'; | ||
import 'shiki'; | ||
@@ -269,3 +269,3 @@ import 'fs'; | ||
var version = "1.0.0-alpha.1"; | ||
var version = "1.0.0-alpha.2"; | ||
@@ -272,0 +272,0 @@ const argv = minimist(process.argv.slice(2)); |
@@ -24,2 +24,9 @@ import * as vite from 'vite'; | ||
/** | ||
* Custom outline title in the aside component. | ||
* | ||
* @default 'On this page' | ||
*/ | ||
outlineTitle?: string | ||
/** | ||
* The nav items. | ||
@@ -90,3 +97,3 @@ */ | ||
export interface NavItemWithChildren { | ||
export type NavItemChildren = { | ||
text?: string | ||
@@ -96,2 +103,7 @@ items: NavItemWithLink[] | ||
export interface NavItemWithChildren { | ||
text?: string | ||
items: (NavItemChildren | NavItemWithLink)[] | ||
} | ||
// sidebar ------------------------------------------------------------------- | ||
@@ -106,3 +118,3 @@ | ||
export interface SidebarGroup { | ||
text: string | ||
text?: string | ||
items: SidebarItem[] | ||
@@ -134,23 +146,9 @@ | ||
/** | ||
* Repo of the site. | ||
* Pattern for edit link. | ||
* | ||
* @example 'vuejs/docs' | ||
* @example 'https://github.com/vuejs/vitepress/edit/main/docs/:path' | ||
*/ | ||
repo: string | ||
pattern: string | ||
/** | ||
* Branch of the repo. | ||
* | ||
* @default 'main' | ||
*/ | ||
branch?: string | ||
/** | ||
* If your docs are not at the root of the repo. | ||
* | ||
* @example 'docs' | ||
*/ | ||
dir?: string | ||
/** | ||
* Custom text for edit link. | ||
@@ -320,3 +318,3 @@ * | ||
declare const createMarkdownRenderer: (srcDir: string, options: MarkdownOptions | undefined, base: string) => Promise<MarkdownRenderer>; | ||
declare const createMarkdownRenderer: (srcDir: string, options?: MarkdownOptions, base?: string) => Promise<MarkdownRenderer>; | ||
@@ -323,0 +321,0 @@ interface UserConfig<ThemeConfig = any> { |
@@ -1,2 +0,2 @@ | ||
export { g as build, f as createMarkdownRenderer, e as createServer, d as defineConfig, a as defineConfigWithTheme, r as resolveConfig, b as resolveSiteData, c as resolveSiteDataByRoute, s as serve } from './serve-e8d58be3.js'; | ||
export { g as build, f as createMarkdownRenderer, e as createServer, d as defineConfig, a as defineConfigWithTheme, r as resolveConfig, b as resolveSiteData, c as resolveSiteDataByRoute, s as serve } from './serve-42a92e2f.js'; | ||
import 'vite'; | ||
@@ -3,0 +3,0 @@ import 'path'; |
{ | ||
"name": "vitepress", | ||
"version": "1.0.0-alpha.1", | ||
"version": "1.0.0-alpha.2", | ||
"description": "Vite & Vue powered static site generator", | ||
@@ -49,2 +49,3 @@ "type": "module", | ||
"@vitejs/plugin-vue": "^2.3.2", | ||
"@vue/devtools-api": "^6.1.4", | ||
"@vueuse/core": "^8.5.0", | ||
@@ -114,3 +115,3 @@ "body-scroll-lock": "^4.0.0-beta.0", | ||
"typescript": "^4.7.2", | ||
"vitest": "^0.10.4" | ||
"vitest": "^0.14.2" | ||
}, | ||
@@ -117,0 +118,0 @@ "simple-git-hooks": { |
@@ -17,2 +17,9 @@ export namespace DefaultTheme { | ||
/** | ||
* Custom outline title in the aside component. | ||
* | ||
* @default 'On this page' | ||
*/ | ||
outlineTitle?: string | ||
/** | ||
* The nav items. | ||
@@ -83,3 +90,3 @@ */ | ||
export interface NavItemWithChildren { | ||
export type NavItemChildren = { | ||
text?: string | ||
@@ -89,2 +96,7 @@ items: NavItemWithLink[] | ||
export interface NavItemWithChildren { | ||
text?: string | ||
items: (NavItemChildren | NavItemWithLink)[] | ||
} | ||
// sidebar ------------------------------------------------------------------- | ||
@@ -99,3 +111,3 @@ | ||
export interface SidebarGroup { | ||
text: string | ||
text?: string | ||
items: SidebarItem[] | ||
@@ -127,23 +139,9 @@ | ||
/** | ||
* Repo of the site. | ||
* Pattern for edit link. | ||
* | ||
* @example 'vuejs/docs' | ||
* @example 'https://github.com/vuejs/vitepress/edit/main/docs/:path' | ||
*/ | ||
repo: string | ||
pattern: string | ||
/** | ||
* Branch of the repo. | ||
* | ||
* @default 'main' | ||
*/ | ||
branch?: string | ||
/** | ||
* If your docs are not at the root of the repo. | ||
* | ||
* @example 'docs' | ||
*/ | ||
dir?: string | ||
/** | ||
* Custom text for edit link. | ||
@@ -150,0 +148,0 @@ * |
@@ -75,1 +75,6 @@ // types shared between server and client | ||
} | ||
export interface PageDataPayload { | ||
path: string | ||
pageData: PageData | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3312784
145
122383
9
+ Added@vue/devtools-api@^6.1.4
+ Added@vue/devtools-api@6.6.4(transitive)