|
|
@ -61,8 +61,15 @@ export function processIncludes(
|
|
|
|
|
|
|
|
|
|
|
|
if (title) {
|
|
|
|
if (title) {
|
|
|
|
const titleName = title[0].slice(1, -1).trim()
|
|
|
|
const titleName = title[0].slice(1, -1).trim()
|
|
|
|
const lines = content.split(/\r?\n/)
|
|
|
|
const lines = content.split(/\r?\n/).map((line) => line.trim())
|
|
|
|
const start = lines.findIndex((line) => line === titleName)
|
|
|
|
const start = lines.findIndex((line) => line === titleName)
|
|
|
|
|
|
|
|
if (start === -1) {
|
|
|
|
|
|
|
|
console.log(c.yellow(`\nTitle (${titleName}) not found in ${includePath}`))
|
|
|
|
|
|
|
|
content = ''
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (lines.slice(start + 1).includes(titleName)) {
|
|
|
|
|
|
|
|
console.log(c.yellow(`\nMultiple identical titles (${titleName}) found in ${includePath}`))
|
|
|
|
|
|
|
|
}
|
|
|
|
const prefixLength = titleName.match(/^#+/)?.[0].length || 0
|
|
|
|
const prefixLength = titleName.match(/^#+/)?.[0].length || 0
|
|
|
|
const end = lines.findIndex(
|
|
|
|
const end = lines.findIndex(
|
|
|
|
(line, index) =>
|
|
|
|
(line, index) =>
|
|
|
@ -74,6 +81,7 @@ export function processIncludes(
|
|
|
|
content = lines.slice(start, end).join('\n')
|
|
|
|
content = lines.slice(start, end).join('\n')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!hasMeta && path.extname(includePath) === '.md') {
|
|
|
|
if (!hasMeta && path.extname(includePath) === '.md') {
|
|
|
|
content = matter(content).content
|
|
|
|
content = matter(content).content
|
|
|
|