astro-accelerator-utils 0.3.10 → 0.3.12
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/lib/v1/authors.mjs +4 -1
- package/lib/v1/markdown.d.mts +2 -0
- package/lib/v1/markdown.mjs +25 -0
- package/package.json +1 -1
package/lib/v1/authors.mjs
CHANGED
|
@@ -65,7 +65,10 @@ export class Authors {
|
|
|
65
65
|
info (slug) {
|
|
66
66
|
const author = this.posts.all()
|
|
67
67
|
.filter(PostFiltering.isAuthor)
|
|
68
|
-
.filter(x =>
|
|
68
|
+
.filter(x => {
|
|
69
|
+
const urlParts = x.url?.split('/');
|
|
70
|
+
return urlParts[urlParts.length -1] == slug;
|
|
71
|
+
})[0];
|
|
69
72
|
|
|
70
73
|
return author;
|
|
71
74
|
}
|
package/lib/v1/markdown.d.mts
CHANGED
package/lib/v1/markdown.mjs
CHANGED
|
@@ -43,4 +43,29 @@ export class Markdown {
|
|
|
43
43
|
async getTextFrom(markdown) {
|
|
44
44
|
return markdown.replace(/[\\*>~]/g, '').trim();
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
hasUpperCase(input) {
|
|
48
|
+
for (var c of input) {
|
|
49
|
+
if (c.toUpperCase() === c) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
titleCase(input) {
|
|
57
|
+
var words = input.split(' ');
|
|
58
|
+
var newWords = [];
|
|
59
|
+
|
|
60
|
+
for (var word of words) {
|
|
61
|
+
if (this.hasUpperCase(word)) {
|
|
62
|
+
newWords.push(word);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
newWords.push(word.replace(word[0], word[0].toUpperCase()));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return newWords.join(' ');
|
|
70
|
+
}
|
|
46
71
|
}
|