How to use @vuepress/core - 10 common examples

To help you get started, we’ve selected a few @vuepress/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vuejs / vuepress / packages / @vuepress / test-utils / createLocalVue.js View on Github external
export default function () {
  const localVue = createLocalVue()
  localVue.use(Router)

  // register global component
  localVue.component('OutboundLink', mockComponent('outbound-link'))
  localVue.component(siteData.pages[0].key, mockComponent('page-component'))
  localVue.mixin(dataMixin(I18n, siteData))
  return localVue
}
github appcelerator / titanium-docs / docs / .vuepress / app / clientEntry.js View on Github external
/* global VUEPRESS_VERSION, LAST_COMMIT_HASH*/

import { createApp } from '@vuepress/core/lib/app/app.js'
import { sync } from 'vuex-router-sync';

const { app, router } = createApp(false /* isServer */)

const store = app.$options.store
if (window.__INITIAL_STATE__) {
  store.replaceState(window.__INITIAL_STATE__);
}
sync(store, router);

window.__VUEPRESS_VERSION__ = {
  version: VUEPRESS_VERSION,
  hash: LAST_COMMIT_HASH
}

router.onReady(() => {
  if (!window.__INITIAL_STATE__) {
    fetchMetadata(router.currentRoute);
  }
github appcelerator / docs-devkit / packages / vuepress / vuepress-plugin-apidocs / lib / webpack / clientEntry.js View on Github external
/* global VUEPRESS_VERSION, LAST_COMMIT_HASH*/

import { createApp } from '@vuepress/core/lib/client/app.js'
import { sync } from 'vuex-router-sync'

const { app, router } = createApp(false /* isServer */)

const store = app.$options.store
if (window.__INITIAL_STATE__) {
  store.replaceState(window.__INITIAL_STATE__)
}
sync(store, router)

window.__VUEPRESS_VERSION__ = {
  version: VUEPRESS_VERSION,
  hash: LAST_COMMIT_HASH
}

router.onReady(() => {
  if (!window.__INITIAL_STATE__) {
    fetchMetadata(router.currentRoute)
  }
github vuepress / vuepress-plugin-dehydrate / __tests__ / index.spec.js View on Github external
describe('dehydation', () => {
  const app = createApp({
    sourceDir: resolve(__dirname, 'docs'),
  })

  beforeAll(async () => {
    await app.process()
    await app.build()
  }, 60000)

  function testForFile (name, file = name) {
    test(name, () => {
      const html = readFileSync(resolve(app.outDir, file), 'utf8')
      expect(html).toMatchSnapshot()
    })
  }

  testForFile('404.html')
github vuejs / vuepress / packages / @vuepress / plugin-public-files / __tests__ / index.spec.js View on Github external
describe('plugin-public-files: source folder', () => {
  const app = createApp({
    sourceDir: resolve(__dirname, 'docs-1')
  })

  beforeAll(async () => {
    await app.process()
    await app.build()
  }, 60000)

  testForExistence(app, 'foo.txt')
  testForExistence(app, 'baz.txt')
  testForExistence(app, 'bar/foo.txt')
  testForExistence(app, 'bar/baz.txt')
  testForExistence(app, 'index.html')
  testForExistence(app, 'readme.md', false)
  testForExistence(app, '.dotfile', false)
  testForExistence(app, '.dotfolder', false)
github vuejs / vuepress / packages / @vuepress / cli / index.js View on Github external
const { chalk } = require('@vuepress/shared-utils')
const semver = require('semver')

try {
  require.resolve('@vuepress/core')
} catch (err) {
  console.log(chalk.red(
    `\n[vuepress] @vuepress/cli ` +
    `requires @vuepress/core to be installed.\n`
  ))
  process.exit(1)
}

const pkg = require('@vuepress/core/package.json')
const requiredVersion = pkg.engines.node

if (!semver.satisfies(process.version, requiredVersion)) {
  console.log(chalk.red(
    `\n[vuepress] minimum Node version not met:` +
    `\nYou are using Node ${process.version}, but VuePress ` +
    `requires Node ${requiredVersion}.\nPlease upgrade your Node version.\n`
  ))
  process.exit(1)
}

const cli = require('cac')()

exports.cli = cli
exports.bootstrap = function ({
  plugins,
  theme
github vuejs / vuepress / packages / vuepress / lib / handleUnknownCommand.js View on Github external
async beforeParse (subCli) {
        const app = createApp({
          sourceDir: sourceDir,
          ...options,
          ...commandoptions
        })
        await app.process()
        app.pluginAPI.applySyncOption('extendCli', subCli, app)
        console.log()
      },
      async afterParse (subCli) {
github appcelerator / titanium-docs / docs / .vuepress / app / serverEntry.js View on Github external
export default context => new Promise((resolve, reject) => {
  originalServerEntry(context).then(app => {
    const router = app.$options.router;
    const store = app.$options.store;

    sync(store, router);

    router.onReady(() => {
      const matchedComponents = router.getMatchedComponents();
      if (!matchedComponents.length) {
        return reject({ code: 404 })
      }

      const apiRoutePattern = /^\/api\//;
      const currentRoutePath = router.currentRoute.path;
      if (!apiRoutePattern.test(currentRoutePath)) {
        return resolve(app);
      }
github appcelerator / docs-devkit / packages / vuepress / vuepress-plugin-apidocs / lib / webpack / serverEntry.js View on Github external
export default context => new Promise((resolve, reject) => {
  originalServerEntry(context).then(app => {
    const router = app.$options.router
    const store = app.$options.store

    sync(store, router)

    router.onReady(() => {
      const matchedComponents = router.getMatchedComponents()
      if (!matchedComponents.length) {
        return reject({ code: 404 })
      }

      const apiRoutePattern = /^\/api\//
      const currentRoutePath = router.currentRoute.path
      if (!apiRoutePattern.test(currentRoutePath)) {
        return resolve(app)
      }
github vuejs / vuepress / packages / vuepress / lib / handleUnknownCommand.js View on Github external
logger.developer('needPrepareBeforeLaunchCLI', needPrepareBeforeLaunchCLI)

  if (needPrepareBeforeLaunchCLI) {
    let app
    let [, sourceDir] = argv

    if (!sourceDir || sourceDir.startsWith('-')) {
      sourceDir = inferredUserDocsDirectory
    } else {
      sourceDir = pwd
    }

    logger.setOptions({ logLevel: 1 })

    if (sourceDir) {
      app = createApp({ sourceDir, ...options })
      await app.process()
      app.pluginAPI.applySyncOption('extendCli', cli, app)
    }

    logger.setOptions({ logLevel: 3 })
  }
}