mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 00:27:21 +02:00
feat(v2): meta description (#1447)
* feat(v2): meta description * add description for blog as well * fix non-descriptive text link * remove font awesome * switch front-matter -> gray-matter
This commit is contained in:
parent
34195e4c30
commit
6136fbe1d2
21 changed files with 82 additions and 58 deletions
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
const path = require('path');
|
||||
const fm = require('front-matter');
|
||||
const matter = require('gray-matter');
|
||||
const {createHash} = require('crypto');
|
||||
|
||||
const _ = require(`lodash`);
|
||||
|
@ -163,15 +163,19 @@ function getSubFolder(file, refDir) {
|
|||
|
||||
/**
|
||||
* @param {string} fileString
|
||||
* @returns {*}
|
||||
* @returns {Object}
|
||||
*/
|
||||
function parse(fileString) {
|
||||
if (!fm.test(fileString)) {
|
||||
return {metadata: null, content: fileString};
|
||||
}
|
||||
const {attributes: metadata, body: content} = fm(fileString);
|
||||
|
||||
return {metadata, content};
|
||||
const {data: metadata, content, excerpt} = matter(fileString, {
|
||||
excerpt(file) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
file.excerpt = file.content
|
||||
.trim()
|
||||
.split('\n', 1)
|
||||
.shift();
|
||||
},
|
||||
});
|
||||
return {metadata, content, excerpt};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue