Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

read-file-contents.js 644 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  1. const readFileAsync = require('./readfile-async')
  2. const encodeBracketedParentheses = require('./encode-bracketed-parentheses')
  3. const fm = require('./frontmatter')
  4. /**
  5. * Read only the frontmatter from file
  6. */
  7. module.exports = async function fmfromf (filepath, languageCode) {
  8. let fileContent = await readFileAsync(filepath, 'utf8')
  9. fileContent = encodeBracketedParentheses(fileContent)
  10. // TODO remove this when crowdin-support issue 66 has been resolved
  11. if (languageCode !== 'en' && fileContent.includes(': verdadero')) {
  12. fileContent = fileContent.replace(': verdadero', ': true')
  13. }
  14. return fm(fileContent, { filepath })
  15. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...