當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript front-matter.default函數代碼示例

本文整理匯總了TypeScript中front-matter.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

    it('should pass tags without code clean through', function () {
        var data = fs.readFileSync('./test/test_content/without_code_blocks.md', 'utf8');

        var orig_cont = fm(data);
        var meta = '---\ntitle: ' + orig_cont.attributes.title + '\ndescription: ' + orig_cont.attributes.description + '\n---\n';
        var processed_content = processBodyContent(meta, orig_cont.body);
        //expect(processed_content.trim().split('')).toEqual(data.trim().split(''));
        expect(true).toBe(true);
    });
開發者ID:georgeedwards,項目名稱:hexo-converter,代碼行數:9,代碼來源:processingSpec.ts

示例2: generateLicenseMetadata

function generateLicenseMetadata(outRoot: string) {
  const chooseALicense = path.join(outRoot, 'static', 'choosealicense.com')
  const licensesDir = path.join(chooseALicense, '_licenses')

  const files = fs.readdirSync(licensesDir)

  const licenses = new Array<ILicense>()
  for (const file of files) {
    const fullPath = path.join(licensesDir, file)
    const contents = fs.readFileSync(fullPath, 'utf8')
    const result = frontMatter<IChooseALicense>(contents)
    const license: ILicense = {
      name: result.attributes.nickname || result.attributes.title,
      featured: result.attributes.featured || false,
      hidden:
        result.attributes.hidden === undefined || result.attributes.hidden,
      body: result.body.trim(),
    }

    if (!license.hidden) {
      licenses.push(license)
    }
  }

  const licensePayload = path.join(outRoot, 'static', 'available-licenses.json')
  const text = JSON.stringify(licenses)
  fs.writeFileSync(licensePayload, text, 'utf8')

  // embed the license alongside the generated license payload
  const chooseALicenseLicense = path.join(chooseALicense, 'LICENSE.md')
  const licenseDestination = path.join(
    outRoot,
    'static',
    'LICENSE.choosealicense.md'
  )

  const licenseText = fs.readFileSync(chooseALicenseLicense, 'utf8')
  const licenseWithHeader = `GitHub Desktop uses licensing information provided by choosealicense.com.

The bundle in available-licenses.json has been generated from a source list provided at https://github.com/github/choosealicense.com, which is made available under the below license:

------------

${licenseText}`

  fs.writeFileSync(licenseDestination, licenseWithHeader, 'utf8')

  // sweep up the choosealicense directory as the important bits have been bundled in the app
  fs.removeSync(chooseALicense)
}
開發者ID:soslanashkhotov,項目名稱:desktop,代碼行數:50,代碼來源:build.ts

示例3: function

    fs.readFile(path, 'utf8', function (err, data) {
        if (err) { throw err; }

        var orig_cont = fm(data);

        console.log(path);
        //console.log(content.attributes.title);

        var substring = '/content';
        var fileName = path.substring(9); //extract the file name from root ./content
        var meta = '---\ntitle: ' + orig_cont.attributes.title + '\ndescription: ' + orig_cont.attributes.description + '\n---\n';
        var processed_content = processBodyContent(meta, orig_cont.body);
        writeFile(processed_content, fileName);
    });
開發者ID:georgeedwards,項目名稱:hexo-converter,代碼行數:14,代碼來源:index.ts

示例4: pageModuleTemplate

module.exports = function bookLoader(content: string): string {
  this.cacheable(true);
  const query = loaderUtils.parseQuery(this.query);
  const {toc} = query;

  const {attributes, body} = fm<{[key: string]: any}>(content);

  if (query.markdown === false || attributes.markdown === false) {
    content = jsTemplate(body);
  } else {
    const {bookLoaderOptions = {}} = this;
    const md = markdownIt({
      html: true,
      ...bookLoaderOptions.markdownOptions,
    }).use(markdownJsTemplate);
    if (bookLoaderOptions.markdownPlugins) {
      bookLoaderOptions.markdownPlugins.forEach(md.use.bind(md));
    }
    content = md.render(body);
  }

  const context = query.context || this.options.context;

  const url = attributes.hasOwnProperty('url')
    ? attributes.url
    : loaderUtils.interpolateName(this, query.name || '[path][name].html', {
        context,
        content: content,
        regExp: query.regExp,
      });

  const template = attributes.hasOwnProperty('template')
    ? attributes.template
    : query.template;

  const emit = !![attributes.emit, query.emit, url].find(
    (o) => typeof o !== 'undefined',
  );

  return pageModuleTemplate({
    url,
    template,
    toc,
    attributes,
    emit,
    filename: path.relative(context, this.resourcePath),
    renderFunctionBody: content,
  });
};
開發者ID:also,項目名稱:book-loader,代碼行數:49,代碼來源:index.ts

示例5: async

      Fs.readdir(root, async (err, files) => {
        if (err) {
          reject(err)
        } else {
          const licenses = new Array<ILicense>()
          for (const file of files) {
            const fullPath = Path.join(root, file)
            const contents = await readFileAsync(fullPath)
            const result = frontMatter<IChooseALicense>(contents)
            const license: ILicense = {
              name: result.attributes.nickname || result.attributes.title,
              featured: result.attributes.featured || false,
              hidden:
                result.attributes.hidden === undefined ||
                result.attributes.hidden,
              body: result.body.trim(),
            }

            if (!license.hidden) {
              licenses.push(license)
            }
          }

          cachedLicenses = licenses.sort((a, b) => {
            if (a.featured) {
              return -1
            }
            if (b.featured) {
              return 1
            }
            return a.name.localeCompare(b.name)
          })

          resolve(cachedLicenses)
        }
      })
開發者ID:Ahskys,項目名稱:desktop,代碼行數:36,代碼來源:licenses.ts


注:本文中的front-matter.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。