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

scriptype / writ-cms / 19413285754

16 Nov 2025 10:50PM UTC coverage: 19.536% (+0.04%) from 19.495%
19413285754

push

github

scriptype
Extend models/category from ContentModelEntryNode

152 of 3408 branches covered (4.46%)

Branch coverage included in aggregate %.

8 of 134 new or added lines in 5 files covered. (5.97%)

55 existing lines in 4 files now uncovered.

925 of 2105 relevant lines covered (43.94%)

102.0 hits per line

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

65.85
/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] === '/') {
18!
22
    return parts[0] + parts.slice(1).join('/')
18✔
23
  }
24
  return parts.filter(Boolean).join('/')
×
25
}
26

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

34
const Markdown = {
9✔
35
  parse(text) {
36
    return Markdown.unescapeHandlebarsExpressions(
351✔
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, '{{>')
351✔
46
    // helpers
47
    html = html.replace(/{{(.+)(?:"|')(.+)(?:"|')(.*)}}/g, '{{\$1"\$2"\$3}}')
351✔
48
    // partials
49
    html = html.replace(/{{>(.+)(?:"|')(.+)(?:"|').*}}/g, '{{>\$1"\$2"\$3}}')
351✔
50
    return html
351✔
51
  },
52
}
53

54
const makeDateSlug = (date) => {
9✔
NEW
55
  return date.toISOString().split('T')[0]
×
56
}
57

58
const _sortableValue = (value) => {
9✔
NEW
59
  return typeof value === 'string' ? value.toLowerCase().charCodeAt(0) : value
×
60
}
61

62
const sort = (items, sortBy, sortOrder) => {
9✔
NEW
63
  items.sort((a, b) => {
×
NEW
64
    const sortableA = _sortableValue(a[sortBy])
×
NEW
65
    const sortableB = _sortableValue(b[sortBy])
×
NEW
66
    if (sortOrder === -1) {
×
NEW
67
      return sortableB - sortableA
×
68
    }
NEW
69
    return sortableA - sortableB
×
70
  })
71
}
72

73
module.exports = {
9✔
74
  templateExtensions,
75
  isTemplateFile,
76
  makePermalink,
77
  removeExtension,
78
  Markdown,
79
  makeDateSlug,
80
  sort
81
}
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