本文整理汇总了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);
});
示例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)
}
示例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);
});
示例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,
});
};
示例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)
}
})