How to use the markdown-magic.globby function in markdown-magic

To help you get started, we’ve selected a few markdown-magic 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 serverless / blog / validate.js View on Github external
"name": "David Wells",
  "github": "davidwells",
  "avatar": "https://avatars2.githubusercontent.com/u/532272?v=3&s=60",
  "bio": {
    "short": "David Wells is a developer at Serverless, Inc.",
    "long": "David is a Full Stack JavaScript Developer, entrepreneur, past life marketer. Developer @ http://serverless.com "
  }
}

const authorArray = fs.readdirSync(authorDirectory).map((author) =>{
  return author.replace('.json', '')
})


// test author directory
globby(['*', '!node_modules'], {
  cwd: authorDirectory
}).then(paths => {
    paths.forEach((file) => {
      const fp = path.join(authorDirectory, file)
      if (file.match(/\.json/)) {
        const author = fs.readFileSync(fp, 'utf8')
        const valid = hasSameProps(authorData, JSON.parse(author))
        if (!valid) {
          const msg = `${file} has missing value in author profile.
Author data must match (if no value applies use false):
${JSON.stringify(authorData, null, 2)}`
          throw new Error(msg)
        }
      } else {
        // not json throw error
        throw new Error(`${file} file type not allowed in authors directory ${file}`);
github DavidWells / davidwells-legacy-site / scripts / content / prepopulateTalks.js View on Github external
module.exports = function prepopulateTalks() {
  console.log('prepopulate Talk content')
  globby([`${talksContentPath}/*.md`]).then((files) => {
    const markdownContent = []
    files.forEach((f) => {
      const fileContent = fs.readFileSync(f, 'utf-8')
      const item = matter(fileContent).data
      const base = `${path.basename(path.dirname(f))}/${path.basename(f, '.md')}`
      const slug = base.replace(/[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])-/g, '')
      const data = {
        title: item.title,
        date: item.date,
        event: item.event,
        url: `https://davidwells.io/${slug}`
      }
      if (item.date) {
        markdownContent.push(data)
      }
    })
github DavidWells / davidwells-legacy-site / content / blog / transform.js View on Github external
const globby = require('markdown-magic').globby
const fs = require('fs-extra')
const path = require('path')
const matter = require('gray-matter')

globby('*.md').then((files) => {
  let count = 0
  const news = []
  files.forEach((f) => {
    const content = fs.readFileSync(f, 'utf-8')
    const item = matter(content).data

    if (item.external_post_url) {
      const url = item.external_post_url['0']
      const data = {
        title: item.title,
        date: item.date,
        url: url
      }
      //console.log(data)
      news.push(data)
      count++
github DavidWells / davidwells-legacy-site / scripts / content / prepopulateBlog.js View on Github external
module.exports = function prepopulateBlog() {
  console.log('prepopulate blog content')
  const externalContent = fs.readFileSync(externalContentPath, 'utf-8')
  const externalPosts = JSON.parse(externalContent)
  globby([`${blogContentPath}/*.md`, `${snippetsContentPath}/*.md`]).then((files) => {
    const markdownContent = []
    files.forEach((f) => {
      const fileContent = fs.readFileSync(f, 'utf-8')
      const item = matter(fileContent).data
      const base = `${path.basename(path.dirname(f))}/${path.basename(f, '.md')}`
      const slug = base.replace(/[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])-/g, '')
      const data = {
        title: item.title,
        date: item.date,
        url: `https://davidwells.io/${slug}`
      }
      if (item.date) {
        markdownContent.push(data)
      }
    })
github DavidWells / analytics / site / sync.js View on Github external
async function getFiles() {
  const topLevelPackages = [`${PACKAGE_PATH}/*/package.json`]
  const files = await globby(topLevelPackages)
  const collectInfo = files.map(async (file) => {
    const pkg = require(file)
    const slug = pkg.name.replace(/^@analytics\//, '')
    const directory = path.dirname(file)
    const docFilePath = path.join(PLUGIN_DOC_PATH, `${slug}.md`)
    const exists = await fileExists(docFilePath)
    return {
      pkg: pkg,
      dir: directory,
      exists: exists,
      repoMdPath: path.resolve(directory, 'README.md'),
      docPath: CUSTOM_MAPPING[pkg.name] || docFilePath
    }
  })

  const fileData = await Promise.all(collectInfo)

markdown-magic

Automatically update markdown files with content from external sources

MIT
Latest version published 3 months ago

Package Health Score

68 / 100
Full package analysis

Similar packages