• 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

92.31
/src/lib/contentModelHelpers.js
1
const _ = require('lodash')
9✔
2
const marked = require('marked')
9✔
3
const frontMatter = require('front-matter')
9✔
4
const slug = require('slug')
9✔
5

6
const templateExtensions = [
9✔
7
  '.hbs',
8
  '.handlebars',
9
  '.md',
10
  '.markdown',
11
  '.txt',
12
  '.text',
13
  '.html'
14
]
15

16
const isTemplateFile = (node) => {
9✔
17
  return new RegExp(templateExtensions.join('|'), 'i').test(node.extension)
36✔
18
}
19

20
const makePermalink = (...parts) => {
9✔
21
  if (parts[0] === '/') {
36!
22
    return parts[0] + parts.slice(1).join('/')
36✔
23
  }
NEW
24
  return parts.filter(Boolean).join('/')
×
25
}
26

27
const removeExtension = (fileName) => {
9✔
28
  if (fileName.lastIndexOf('.') > 0) {
144✔
29
    return fileName.replace(/(\.[^.]+)?$/, '')
18✔
30
  }
31
  return fileName
126✔
32
}
33

34
const Markdown = {
9✔
35
  parse(text) {
36
    return Markdown.unescapeHandlebarsExpressions(
144✔
37
      marked.parse(
38
        text.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, '')
39
      )
40
    )
41
  },
42

43
  unescapeHandlebarsExpressions(html) {
44
    // partial greater sign
45
    html = html.replace(/{{>/g, '{{>')
144✔
46
    // helpers
47
    html = html.replace(/{{(.+)(?:"|')(.+)(?:"|')(.*)}}/g, '{{\$1"\$2"\$3}}')
144✔
48
    // partials
49
    html = html.replace(/{{>(.+)(?:"|')(.+)(?:"|').*}}/g, '{{>\$1"\$2"\$3}}')
144✔
50
    return html
144✔
51
  },
52
}
53

54
module.exports = {
9✔
55
  templateExtensions,
56
  isTemplateFile,
57
  makePermalink,
58
  removeExtension,
59
  Markdown
60
}
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