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

scriptype / writ-cms / 18128625706

30 Sep 2025 11:38AM UTC coverage: 73.078% (-2.4%) from 75.488%
18128625706

push

github

scriptype
Facets wip5

Handle permalinking from entries to collection facets through its faceted fields. Every facet field becomes an object: { value, facetPermalink }. If the field is a link to another entry (already object), then the facetPermalink property is added on top of existing entry object.

490 of 795 branches covered (61.64%)

Branch coverage included in aggregate %.

8 of 25 new or added lines in 4 files covered. (32.0%)

118 existing lines in 9 files now uncovered.

2276 of 2990 relevant lines covered (76.12%)

313.31 hits per line

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

87.1
/src/compiler/contentModel2/helpers.js
1
const marked = require('marked')
9✔
2

3
const templateExtensions = [
9✔
4
  '.hbs',
5
  '.handlebars',
6
  '.md',
7
  '.markdown',
8
  '.txt',
9
  '.text',
10
  '.html'
11
]
12

13
const isTemplateFile = (node) => {
9✔
14
  return new RegExp(templateExtensions.join('|'), 'i').test(node.extension)
468✔
15
}
16

17
const removeExtension = (fileName) => {
9✔
18
  if (fileName.lastIndexOf('.') > 0) {
72✔
19
    return fileName.replace(/(\.[^.]+)?$/, '')
63✔
20
  }
21
  return fileName
9✔
22
}
23

24
const parseArray = (array = []) => {
9!
25
  return typeof array === 'string' ?
72✔
26
    array.split(',').map(t => t.trim()) :
162✔
27
    array
28
}
29

30
const makePermalink = (...parts) => {
9✔
31
  if (parts[0] === '/') {
135!
32
    return parts[0] + parts.slice(1).join('/')
×
33
  }
34
  return parts.join('/')
135✔
35
}
36

37
const makeDateSlug = (date) => {
9✔
NEW
38
  return date.toISOString().split('T')[0]
×
39
}
40

41
const Markdown = {
9✔
42
  parse(text) {
43
    return Markdown.unescapeHandlebarsExpressions(
54✔
44
      marked.parse(
45
        text.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, '')
46
      )
47
    )
48
  },
49

50
  unescapeHandlebarsExpressions(html) {
51
    // partial greater sign
52
    html = html.replace(/{{>/g, '{{>')
54✔
53
    // helpers
54
    html = html.replace(/{{(.+)(?:"|')(.+)(?:"|')(.*)}}/g, '{{\$1"\$2"\$3}}')
54✔
55
    // partials
56
    html = html.replace(/{{>(.+)(?:"|')(.+)(?:"|').*}}/g, '{{>\$1"\$2"\$3}}')
54✔
57
    return html
54✔
58
  },
59
}
60

61
module.exports = {
9✔
62
  templateExtensions,
63
  isTemplateFile,
64
  removeExtension,
65
  parseArray,
66
  makePermalink,
67
  makeDateSlug,
68
  Markdown
69
}
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