@tenjuu99/blog 0.2.44 → 0.2.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/pageData.js +18 -16
- package/package.json +1 -1
package/lib/pageData.js
CHANGED
|
@@ -57,27 +57,29 @@ const parseMetaData = (data) => {
|
|
|
57
57
|
let isStringContinue = false
|
|
58
58
|
let key, value
|
|
59
59
|
for (const line of data.split('\n')) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
value
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
if (!isStringContinue) {
|
|
61
|
+
const match = line.match(/^([a-zA-Z_]+):/)
|
|
62
|
+
if (match) {
|
|
63
|
+
key = match[1]
|
|
64
|
+
value = line.slice(line.indexOf(':') + 1).trim()
|
|
65
|
+
if (value === 'true' || value === 'false') {
|
|
66
|
+
value = JSON.parse(value)
|
|
67
|
+
} else {
|
|
68
|
+
if (value.startsWith('config.')) {
|
|
69
|
+
const envName = value.split('.').pop()
|
|
70
|
+
eval(`value = config.${envName}`)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
metaData[key] = value
|
|
74
|
+
if (typeof value === 'string' && value.indexOf('"') === 0) {
|
|
75
|
+
isStringContinue = true
|
|
70
76
|
}
|
|
71
77
|
}
|
|
72
|
-
|
|
73
|
-
if (typeof value === 'string' && value.indexOf('"') === 0) {
|
|
74
|
-
isStringContinue = true
|
|
75
|
-
}
|
|
76
|
-
} else if (key && isStringContinue) {
|
|
78
|
+
} else if (key) {
|
|
77
79
|
metaData[key] = `${metaData[key]}\n${line}`
|
|
78
80
|
if (line.trim().match(/"$/)) {
|
|
79
81
|
isStringContinue = false
|
|
80
|
-
metaData[key] = metaData[key].replace(
|
|
82
|
+
metaData[key] = metaData[key].trim().replace(/^"([^"]+)"$/i, '$1')
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
}
|