front-matter icon indicating copy to clipboard operation
front-matter copied to clipboard

Attributes is empty

Open bsde1234 opened this issue 3 years ago • 3 comments

When I tried to get contents of a yml file, attributes is empty, but body have contents

bsde1234 avatar Feb 17 '23 23:02 bsde1234

Could you provide an example set of content that yeilds the same result? I can use it to debug and maybe set up a regression test if there is a bug.

jxson avatar Feb 21 '23 18:02 jxson

title: "xxxxxx xxx"
url: "https://xxxxx.com/xx"
email: "[email protected]"
markdown: kramdown
mobile: "xxxxxxx"
country: "xxxx"
currency_code: "xx"
  style: compressed
defaults:
  - scope:
      type: posts
    values:
      layout: product
  - scope:
      type: products
    values:
      layout: post
encoding: UTF-8
favicon: "logo.png"

var fs = require('fs')
  , fm = require('front-matter')


fs.readFile('../xxxx/xx/_config.yml', 'utf8', function(err, data2){

  if (err) throw err

  var content2 = fm(data2)

  console.log(content2)

})


bsde1234 avatar Feb 22 '23 14:02 bsde1234

Hello, any updates? I get like below

{
  attributes: {},
  body: 'title: "xxxx xxxx"\n' +
    'url: "https://xxxxx.com/crr"\n' +
    'email: "[email protected]"\n' +
    'markdown: xxxx\n' +
    'mobile: "xxxxx"\n' +
    'country: "xxxx"\n' +
    'currency_code: "xxxx"\n' +
    'location: "xxxxxx"\n' +
    'sass:\n' +
    '  sass_dir: _sass\n' +
    '  style: compressed\n' +
    'collections:\n' +
    '  products:\n' +
    '    output: true\n' +
    'defaults:\n' +
    '  - scope:\n' +
    '      type: posts\n' +
    '    values:\n' +
    '      layout: product\n' +
    '  - scope:\n' +
    '      type: products\n' +
    '    values:\n' +
    '      layout: post\n' +
    'encoding: UTF-8\n' +
    'paginate: 10\n' +
    "paginate_path: 'page/:num/'\n" +
    'favicon: "https://xxxxx.com/crr/xxxx.png"\n' +

    'adsense: ',
  bodyBegin: 1
}

How to get body->url from above code?

bsde1234 avatar Feb 27 '23 15:02 bsde1234