• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

scriptype / writ-cms / 19316730697

13 Nov 2025 12:49AM UTC coverage: 19.323% (+0.7%) from 18.626%
19316730697

push

github

scriptype
Introduce ContentModelNode

A ContentModelNode class is implemented by abstracting out the most
basic model: attachment.

So far models that extend ContentModelNode are: attachment, asset,
homepage, subpage.

_baseEntry's main functionality is extracted into small helpers in a new
helper module called parseTextEntry

ContentModel's helpers are duplicated into lib/ContentModelHelpers with
the idea of eventually nothing in contentModel needing to use those
helpers or something like that.

Next: post, category, collection, contentModel index

146 of 3405 branches covered (4.29%)

Branch coverage included in aggregate %.

119 of 189 new or added lines in 10 files covered. (62.96%)

10 existing lines in 2 files now uncovered.

916 of 2091 relevant lines covered (43.81%)

101.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.66
/src/lib/parseTextEntry.js
1
const _ = require('lodash')
9✔
2
const frontMatter = require('front-matter')
9✔
3
const slug = require('slug')
9✔
4
const { removeExtension, Markdown } = require('./contentModelHelpers')
9✔
5

6
const parseContent = (node, content) => {
9✔
7
  if (node.extension.match(/(html|htm|hbs|handlebars)/i)) {
144!
NEW
8
    return content
×
9
  }
10
  return Markdown.parse(content)
144✔
11
}
12

13
const normalizeEntryName = (fsNode, indexNode) => {
9✔
14
  const hasIndex = fsNode !== indexNode
144✔
15
  const entryName = hasIndex ? fsNode.name : removeExtension(indexNode.name)
144!
16
  return {
144✔
17
    hasIndex,
18
    entryName
19
  }
20
}
21

22
const parseTextEntry = (fsNode, indexNode) => {
9✔
23
  const { attributes, body } = frontMatter(indexNode.content)
144✔
24
  const { hasIndex, entryName } = normalizeEntryName(fsNode, indexNode)
144✔
25
  const contentRaw = body || ''
144✔
26
  const content = parseContent(indexNode, contentRaw)
144✔
27

28
  return {
144✔
29
    ..._.omit(fsNode, 'children'),
30
    ...attributes,
31
    hasIndex,
32
    title: attributes.title || entryName,
288✔
33
    slug: attributes.slug || slug(entryName),
288✔
34
    contentRaw,
35
    content
36
  }
37
}
38

39
module.exports = {
9✔
40
  parseContent,
41
  normalizeEntryName,
42
  parseTextEntry
43
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc