@inovus-medical/docs 0.2.0 → 0.2.1
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/package.json +1 -1
- package/src/build.js +10 -1
- package/src/markdown.js +13 -1
package/package.json
CHANGED
package/src/build.js
CHANGED
|
@@ -117,7 +117,16 @@ export async function build({ root = process.cwd(), inDir, outDir = 'dist' } = {
|
|
|
117
117
|
const routeSegments = isIndex ? dirSegments : rawSegments
|
|
118
118
|
const route = toRoute(routeSegments)
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
let rendered
|
|
121
|
+
try {
|
|
122
|
+
rendered = renderer.render(content)
|
|
123
|
+
} catch (err) {
|
|
124
|
+
const rel = path.relative(contentRoot, file)
|
|
125
|
+
console.warn(`⚠ Could not fully render ${rel}: ${err.message} — falling back to plain text.`)
|
|
126
|
+
const escaped = content.replace(/[&<>]/g, (c) => ({ '&': '&', '<': '<', '>': '>' }[c]))
|
|
127
|
+
rendered = { html: `<pre>${escaped}</pre>`, headings: [], text: content.slice(0, 2000), title: null }
|
|
128
|
+
}
|
|
129
|
+
const { html, headings, text, title } = rendered
|
|
121
130
|
const pageTitle = data.title || title || (isIndex ? titleCase(dirSegments[dirSegments.length - 1] || config.title) : titleCase(leaf))
|
|
122
131
|
|
|
123
132
|
const page = {
|
package/src/markdown.js
CHANGED
|
@@ -42,7 +42,19 @@ export async function createRenderer() {
|
|
|
42
42
|
md.use(
|
|
43
43
|
await Shiki({
|
|
44
44
|
themes: { light: 'github-light', dark: 'github-dark' },
|
|
45
|
-
defaultColor: false
|
|
45
|
+
defaultColor: false,
|
|
46
|
+
// Real repos use fence languages Shiki doesn't ship (env, console, ...).
|
|
47
|
+
// Map the common ones, and fall back to plain text instead of crashing the build.
|
|
48
|
+
fallbackLanguage: 'text',
|
|
49
|
+
langAlias: {
|
|
50
|
+
env: 'ini',
|
|
51
|
+
dotenv: 'ini',
|
|
52
|
+
conf: 'ini',
|
|
53
|
+
console: 'bash',
|
|
54
|
+
shell: 'bash',
|
|
55
|
+
cmd: 'bat',
|
|
56
|
+
vue: 'html'
|
|
57
|
+
}
|
|
46
58
|
})
|
|
47
59
|
)
|
|
48
60
|
|