• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript front-matter.default函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript frost-component.MongoProvider类代码示例发布时间:2022-05-25
下一篇:
TypeScript state.updateWorkspaceStage函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap