mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +02:00
refactor(v2): blog data revamp (#1450)
* refactor(v2): blog data revamp * fix(v2): fix incorrect blog total count * misc: remove console.log * feat(v2): export frontMatter as an object within MDX file (#1451) * refactor. Don't confuse metadata & frontmatter * export frontMatter in content itself * nits * nits name * dont truncate first four lines in blog
This commit is contained in:
parent
070723697f
commit
23b50f17a1
18 changed files with 258 additions and 119 deletions
|
@ -5,7 +5,6 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const matter = require('gray-matter');
|
||||
const {getOptions} = require('loader-utils');
|
||||
const {resolve} = require('url');
|
||||
|
||||
|
@ -16,9 +15,6 @@ module.exports = async function(fileString) {
|
|||
});
|
||||
const {docsDir, sourceToPermalink} = options;
|
||||
|
||||
// Extract content of markdown (without frontmatter).
|
||||
let {content} = matter(fileString);
|
||||
|
||||
// Determine the source dir. e.g: /docs, /website/versioned_docs/version-1.0.0
|
||||
let sourceDir;
|
||||
const thisSource = this.resourcePath;
|
||||
|
@ -26,6 +22,8 @@ module.exports = async function(fileString) {
|
|||
sourceDir = docsDir;
|
||||
}
|
||||
|
||||
let content = fileString;
|
||||
|
||||
// Replace internal markdown linking (except in fenced blocks).
|
||||
if (sourceDir) {
|
||||
let fencedBlock = false;
|
||||
|
|
|
@ -18,7 +18,7 @@ module.exports = async function processMetadata(
|
|||
) {
|
||||
const filepath = path.resolve(refDir, source);
|
||||
const fileString = await fs.readFile(filepath, 'utf-8');
|
||||
const {metadata = {}, excerpt} = parse(fileString);
|
||||
const {frontMatter: metadata = {}, excerpt} = parse(fileString);
|
||||
|
||||
// Default id is the file name.
|
||||
if (!metadata.id) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue