11const assert = require ( 'assert' )
2- const fs = require ( 'fs' )
32const path = require ( 'path' )
43const cheerio = require ( 'cheerio' )
54const patterns = require ( './patterns' )
65const getMapTopicContent = require ( './get-map-topic-content' )
76const getApplicableVersions = require ( './get-applicable-versions' )
8- const encodeBracketedParentheses = require ( './encode-bracketed-parentheses' )
97const generateRedirectsForPermalinks = require ( './redirects/permalinks' )
108const getEnglishHeadings = require ( './get-english-headings' )
119const getTocItems = require ( './get-toc-items' )
@@ -14,11 +12,10 @@ const Permalink = require('./permalink')
1412const languages = require ( './languages' )
1513const renderContent = require ( './render-content' )
1614const { renderReact } = require ( './react/engine' )
17- const frontmatter = require ( './frontmatter' )
1815const products = require ( './all-products' )
1916const slash = require ( 'slash' )
2017const statsd = require ( './statsd' )
21- const fmfromf = require ( './read-frontmatter ' )
18+ const readFileContents = require ( './read-file-contents ' )
2219const getLinkData = require ( './get-link-data' )
2320const union = require ( 'lodash/union' )
2421
@@ -40,7 +37,7 @@ class Page {
4037 // Per https://nodejs.org/api/fs.html#fs_fs_exists_path_callback
4138 // its better to read and handle errors than to check access/stats first
4239 try {
43- const { data, content, errors : frontmatterErrors } = await fmfromf ( fullPath , opts . languageCode )
40+ const { data, content, errors : frontmatterErrors } = await readFileContents ( fullPath , opts . languageCode )
4441
4542 return {
4643 ...opts ,
@@ -138,20 +135,7 @@ class Page {
138135 : this . renderProp ( 'title' , context , opts )
139136 }
140137
141- async getMarkdown ( ) {
142- const raw = fs . readFileSync ( this . fullPath , 'utf8' )
143- const { content } = frontmatter ( raw , { filepath : this . fullPath } )
144- // prevent `[foo] (bar)` strings with a space between from being interpreted as markdown links
145- const encodedMarkdown = encodeBracketedParentheses ( content )
146- return encodedMarkdown
147- }
148-
149138 async _render ( context ) {
150- // Get the raw markdown if we need to
151- if ( ! this . markdown ) {
152- this . markdown = await this . getMarkdown ( )
153- }
154-
155139 // use English IDs/anchors for translated headings, so links don't break (see #8572)
156140 if ( this . languageCode !== 'en' ) {
157141 const englishHeadings = getEnglishHeadings ( this , context . pages )
0 commit comments