How to use the @vuepress/shared-utils.path.resolve function in @vuepress/shared-utils

To help you get started, we’ve selected a few @vuepress/shared-utils 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 greper / d2-crud-plus / docspress / .vuepress / config.js View on Github external
]
})

// function getApiSidebar () {
//   return [
//     'cli',
//     'node'
//   ]
// }

const componentDocs = fs
  .readdirSync(path.resolve(__dirname, '../guide/components'))
  .map(filename => '/guide/components/' + filename.slice(0, -3))
  .sort()
const extendsDocs = fs
  .readdirSync(path.resolve(__dirname, '../guide/extends'))
  .map(filename => '/guide/extends/' + filename.slice(0, -3))
  .sort()
console.log('----------------')
console.log(componentDocs)
console.log('----------------')
function getGuideSidebar (groupA, groupB,groupC) {
  return [
    {
      title: groupA,
      collapsable: false,
      sidebarDepth: 3,
      children: [
        '',
        'quickstart',
      ]
    },
github vuejs / vuepress / packages / @vuepress / core / lib / node / build / index.js View on Github external
async function workaroundEmptyStyleChunk (stats, outDir) {
  const styleChunk = stats.children[0].assets.find(a => {
    return /styles\.\w{8}\.js$/.test(a.name)
  })
  if (!styleChunk) return
  const styleChunkPath = path.resolve(outDir, styleChunk.name)
  const styleChunkContent = await fs.readFile(styleChunkPath, 'utf-8')
  await fs.remove(styleChunkPath)
  // prepend it to app.js.
  // this is necessary for the webpack runtime to work properly.
  const appChunk = stats.children[0].assets.find(a => {
    return /app\.\w{8}\.js$/.test(a.name)
  })
  const appChunkPath = path.resolve(outDir, appChunk.name)
  const appChunkContent = await fs.readFile(appChunkPath, 'utf-8')
  await fs.writeFile(appChunkPath, styleChunkContent + appChunkContent)
}
github vuejs / vuepress / packages / @vuepress / core / lib / node / loadConfig.js View on Github external
module.exports = function loadConfig (vuepressDir, bustCache = true) {
  const configPath = path.resolve(vuepressDir, 'config.js')
  const configYmlPath = path.resolve(vuepressDir, 'config.yml')
  const configTomlPath = path.resolve(vuepressDir, 'config.toml')

  if (bustCache) {
    delete require.cache[configPath]
  }

  // resolve siteConfig
  let siteConfig = {}
  if (fs.existsSync(configYmlPath)) {
    siteConfig = parseConfig(configYmlPath)
  } else if (fs.existsSync(configTomlPath)) {
    siteConfig = parseConfig(configTomlPath)
  } else if (fs.existsSync(configPath)) {
    siteConfig = require(configPath)
  }
github webmasterish / vuepress-plugin-feed / lib / Generator.js View on Github external
continue;
				}

				// ---------------------------------------------------------------------
				
				const feed = feeds[ key ];
				
				if ( ! feed.enable || ! feed.file_name )
				{
					continue;
				}

				// ---------------------------------------------------------------------
				
				const content		= this.feed_generator[ key ]();
				const file			= PATH.resolve( outDir, feed.file_name );
				const relative	= PATH.relative( cwd, file );
				
				await FSE.outputFile( file, content );
				
				LIB.LOG.success(`${key} feed file generated and saved to ${CHALK.cyan( relative )}`);

				// ---------------------------------------------------------------------
				
				out.push( file );
			}
		
			// -----------------------------------------------------------------------
			
			return out;
			
		} catch ( err ) {
github vuejs / vuepress / packages / @vuepress / core / lib / node / __tests__ / prepare / App.spec.js View on Github external
const docsModes = docsModeNames.map(name => {
  const docsPath = path.resolve(docsBaseDir, name)
  const docsTempPath = path.resolve(docsPath, '.vuepress/.temp')
  return { name, docsPath, docsTempPath }
})
github vuejs / vuepress / packages / @vuepress / markdown / lib / snippet.js View on Github external
if (silent) {
      return true
    }

    const start = pos + 3
    const end = state.skipSpacesBack(max, pos)
    const rawPath = state.src.slice(start, end).trim().replace(/^@/, root)
    const filename = rawPath.split(/{/).shift().trim()
    const meta = rawPath.replace(filename, '')

    state.line = startLine + 1

    const token = state.push('fence', 'code', 0)
    token.info = filename.split('.').pop() + meta
    token.src = path.resolve(filename)
    token.markup = '```'
    token.map = [startLine, startLine + 1]

    return true
  }
github vuejs / vuepress / packages / @vuepress / plugin-pagination / index.js View on Github external
module.exports = (options, ctx) => ({
  enhanceAppFiles: [
    path.resolve(__dirname, 'enhanceAppFile.js')
  ],

  ready () {
    let { postsFilter, postsSorter } = options
    postsFilter = postsFilter || (({ type }) => type === 'post')
    postsSorter = postsSorter || ((prev, next) => {
      const prevTime = new Date(prev.frontmatter.date).getTime()
      const nextTime = new Date(next.frontmatter.date).getTime()
      return prevTime - nextTime > 0 ? -1 : 1
    })

    const { pages } = ctx
    const posts = pages.filter(postsFilter)
    const {
      perPagePosts = 10,
      paginationDir = 'page',
github vuejs / vuepress / packages / @vuepress / core / lib / node / App.js View on Github external
resolveThemeAgreementFile (filepath) {
    const current = path.resolve(this.themeAPI.theme.path, filepath)
    if (fs.existsSync(current)) {
      return current
    }
    if (this.themeAPI.existsParentTheme) {
      const parent = path.resolve(this.themeAPI.parentTheme.path, filepath)
      if (fs.existsSync(parent)) {
        return parent
      }
    }
  }
github vuejs / vuepress / packages / vuepress / lib / handleUnknownCommand.js View on Github external
async function inferUserDocsDirectory (cwd) {
  const paths = await globby([
    '**/.vuepress/config.js',
    '!node_modules'
  ], {
    cwd,
    dot: true
  })
  const siteConfigPath = paths && paths[0]
  if (siteConfigPath) {
    return path.resolve(
      cwd,
      siteConfigPath.replace('.vuepress/config.js', '')
    )
  }
  return null
}