@hestia-earth/guide 0.0.1 → 0.0.2
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/CHANGELOG.md +2 -0
- package/content/hestia-101/content.json +3 -0
- package/content/hestia-101/content.md +1 -0
- package/content/index.json +84 -0
- package/content/models/content.json +3 -0
- package/content/models/content.md +1 -0
- package/content/models/contributing.json +8 -0
- package/content/models/contributing.md +2 -0
- package/content/models/documentation.json +11 -0
- package/content/models/documentation.md +3 -0
- package/content/models/faq.json +3 -0
- package/content/models/faq.md +1 -0
- package/content/models/introduction.json +8 -0
- package/content/models/introduction.md +2 -0
- package/package.json +1 -1
- package/envs/.dev.env +0 -2
- package/envs/.develop.env +0 -2
- package/envs/.master.env +0 -2
- package/scripts/build-content.js +0 -54
- package/scripts/build-index.js +0 -91
- package/scripts/build.js +0 -57
- package/scripts/check-content.js +0 -80
- package/scripts/template.css +0 -6
- package/scripts/template.html +0 -22
- package/scripts/template.js +0 -5
- package/scripts/utils.js +0 -117
- package/test.js +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,4 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.0.2](https://gitlab.com/hestia-earth/hestia-guide/compare/v0.0.1...v0.0.2) (2024-10-29)
|
|
6
|
+
|
|
5
7
|
### 0.0.1 (2024-10-29)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# HESTIA 101
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pages": {
|
|
3
|
+
"hestia-101": {
|
|
4
|
+
"content": {
|
|
5
|
+
"id": "hestia-101",
|
|
6
|
+
"mdPath": "hestia-101/content.md",
|
|
7
|
+
"jsonPath": "hestia-101/content.json",
|
|
8
|
+
"title": "HESTIA 101",
|
|
9
|
+
"createdAt": "2024-10-29T07:59:37.000Z",
|
|
10
|
+
"updatedAt": "2024-10-29T07:59:37.000Z"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"models": {
|
|
14
|
+
"content": {
|
|
15
|
+
"id": "models",
|
|
16
|
+
"mdPath": "models/content.md",
|
|
17
|
+
"jsonPath": "models/content.json",
|
|
18
|
+
"title": "Applying Models",
|
|
19
|
+
"createdAt": "2024-10-29T07:59:37.000Z",
|
|
20
|
+
"updatedAt": "2024-10-29T07:59:37.000Z"
|
|
21
|
+
},
|
|
22
|
+
"pages": {
|
|
23
|
+
"models-introduction": {
|
|
24
|
+
"content": {
|
|
25
|
+
"id": "models-introduction",
|
|
26
|
+
"mdPath": "models/introduction.md",
|
|
27
|
+
"jsonPath": "models/introduction.json",
|
|
28
|
+
"title": "Introduction",
|
|
29
|
+
"createdAt": "2024-10-29T07:59:37.000Z",
|
|
30
|
+
"updatedAt": "2024-10-29T07:59:37.000Z",
|
|
31
|
+
"tags": {
|
|
32
|
+
"next": [
|
|
33
|
+
"documentation"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"models-documentation": {
|
|
39
|
+
"content": {
|
|
40
|
+
"id": "models-documentation",
|
|
41
|
+
"mdPath": "models/documentation.md",
|
|
42
|
+
"jsonPath": "models/documentation.json",
|
|
43
|
+
"title": "Documentation",
|
|
44
|
+
"createdAt": "2024-10-29T07:59:37.000Z",
|
|
45
|
+
"updatedAt": "2024-10-29T07:59:37.000Z",
|
|
46
|
+
"tags": {
|
|
47
|
+
"previous": [
|
|
48
|
+
"introduction"
|
|
49
|
+
],
|
|
50
|
+
"next": [
|
|
51
|
+
"contributing"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"models-contributing": {
|
|
57
|
+
"content": {
|
|
58
|
+
"id": "models-contributing",
|
|
59
|
+
"mdPath": "models/contributing.md",
|
|
60
|
+
"jsonPath": "models/contributing.json",
|
|
61
|
+
"title": "Contributing",
|
|
62
|
+
"createdAt": "2024-10-29T07:59:37.000Z",
|
|
63
|
+
"updatedAt": "2024-10-29T07:59:37.000Z",
|
|
64
|
+
"tags": {
|
|
65
|
+
"previous": [
|
|
66
|
+
"documentation"
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"models-faq": {
|
|
72
|
+
"content": {
|
|
73
|
+
"id": "models-faq",
|
|
74
|
+
"mdPath": "models/faq.md",
|
|
75
|
+
"jsonPath": "models/faq.json",
|
|
76
|
+
"title": "FAQ",
|
|
77
|
+
"createdAt": "2024-10-29T07:59:37.000Z",
|
|
78
|
+
"updatedAt": "2024-10-29T07:59:37.000Z"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Applying Models
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# FAQ
|
package/package.json
CHANGED
package/envs/.dev.env
DELETED
package/envs/.develop.env
DELETED
package/envs/.master.env
DELETED
package/scripts/build-content.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
const { writeFileSync } = require("fs");
|
|
2
|
-
const { join } = require("path");
|
|
3
|
-
|
|
4
|
-
const {
|
|
5
|
-
mkdirs,
|
|
6
|
-
encoding,
|
|
7
|
-
srcDir,
|
|
8
|
-
listContent,
|
|
9
|
-
readContent,
|
|
10
|
-
removeContentTags,
|
|
11
|
-
getTags,
|
|
12
|
-
} = require("./utils");
|
|
13
|
-
|
|
14
|
-
const outputDir = join(__dirname, "..", "content");
|
|
15
|
-
|
|
16
|
-
mkdirs(outputDir);
|
|
17
|
-
|
|
18
|
-
const destFilename = (filename) =>
|
|
19
|
-
`${outputDir}/${filename.replace(srcDir, "").replace(/[\d]+_/g, "")}`;
|
|
20
|
-
|
|
21
|
-
const buildMarkdownContent = (filename) => {
|
|
22
|
-
const content = readContent(filename, true);
|
|
23
|
-
const dest = destFilename(filename);
|
|
24
|
-
mkdirs(dest);
|
|
25
|
-
writeFileSync(dest, content, encoding);
|
|
26
|
-
return filename;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const buildJSONContent = (filename) => {
|
|
30
|
-
const content = readContent(filename, false);
|
|
31
|
-
const tags = getTags(content);
|
|
32
|
-
const dest = destFilename(filename).replace(".md", ".json");
|
|
33
|
-
mkdirs(dest);
|
|
34
|
-
writeFileSync(
|
|
35
|
-
dest,
|
|
36
|
-
JSON.stringify(
|
|
37
|
-
{
|
|
38
|
-
tags,
|
|
39
|
-
content: removeContentTags(content),
|
|
40
|
-
},
|
|
41
|
-
null,
|
|
42
|
-
2
|
|
43
|
-
),
|
|
44
|
-
encoding
|
|
45
|
-
);
|
|
46
|
-
return filename;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const build = () => {
|
|
50
|
-
const files = listContent();
|
|
51
|
-
return files.map(buildMarkdownContent).map(buildJSONContent);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
build();
|
package/scripts/build-index.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
const { writeFileSync, readdirSync } = require("fs");
|
|
2
|
-
const { join } = require("path");
|
|
3
|
-
const { getStamps } = require("git-date-extractor");
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
encoding,
|
|
7
|
-
ROOT,
|
|
8
|
-
srcDir,
|
|
9
|
-
mkdirs,
|
|
10
|
-
contentDir,
|
|
11
|
-
isDir,
|
|
12
|
-
listContent,
|
|
13
|
-
readContent,
|
|
14
|
-
contentUrl,
|
|
15
|
-
getTitle,
|
|
16
|
-
getTags,
|
|
17
|
-
} = require("./utils");
|
|
18
|
-
|
|
19
|
-
const outputDir = join(__dirname, "..", "content");
|
|
20
|
-
|
|
21
|
-
mkdirs(outputDir);
|
|
22
|
-
|
|
23
|
-
const fileData = (stamps, filename) => {
|
|
24
|
-
const { created, modified } = stamps[join(contentDir, filename)];
|
|
25
|
-
const content = readContent(filename);
|
|
26
|
-
const lines = content.split("\n").filter(Boolean);
|
|
27
|
-
const title = getTitle(lines[0]);
|
|
28
|
-
const tags = getTags(content);
|
|
29
|
-
const filepath = filename.replace(/^[/]/g, "").replace(/[\d]+_/g, "");
|
|
30
|
-
const id = filepath
|
|
31
|
-
.replace(".md", "")
|
|
32
|
-
.replace(/\//g, "-")
|
|
33
|
-
.replace("-content", "");
|
|
34
|
-
return {
|
|
35
|
-
id,
|
|
36
|
-
mdPath: filepath,
|
|
37
|
-
jsonPath: filepath.replace(".md", ".json"),
|
|
38
|
-
title,
|
|
39
|
-
createdAt: new Date(created * 1000).toJSON(),
|
|
40
|
-
updatedAt: new Date(modified * 1000).toJSON(),
|
|
41
|
-
tags,
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const folderData = (stamps, folder) => {
|
|
46
|
-
const pages = listContent(join(srcDir, folder)).filter(
|
|
47
|
-
(f) => !f.endsWith("0_content.md")
|
|
48
|
-
);
|
|
49
|
-
return {
|
|
50
|
-
content: fileData(stamps, join(folder, "0_content.md")),
|
|
51
|
-
...(pages.length
|
|
52
|
-
? {
|
|
53
|
-
pages: Object.fromEntries(
|
|
54
|
-
pages
|
|
55
|
-
.map((f) => f.replace(srcDir, ""))
|
|
56
|
-
.map((filename) => [
|
|
57
|
-
contentUrl(filename),
|
|
58
|
-
{ content: fileData(stamps, filename) },
|
|
59
|
-
])
|
|
60
|
-
),
|
|
61
|
-
}
|
|
62
|
-
: {}),
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const run = async () => {
|
|
67
|
-
const stamps = await getStamps({
|
|
68
|
-
projectRootPath: ROOT,
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// keep the folder structure
|
|
72
|
-
const folders = readdirSync(srcDir).filter((f) => isDir(join(srcDir, f)));
|
|
73
|
-
const data = folders.map((folder) => [folder, folderData(stamps, folder)]);
|
|
74
|
-
const pages = Object.fromEntries(data);
|
|
75
|
-
const content = {
|
|
76
|
-
pages,
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
writeFileSync(
|
|
80
|
-
join(outputDir, "index.json"),
|
|
81
|
-
JSON.stringify(content, null, 2),
|
|
82
|
-
encoding
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
run()
|
|
87
|
-
.then(() => process.exit(0))
|
|
88
|
-
.catch((err) => {
|
|
89
|
-
console.error(err);
|
|
90
|
-
process.exit(1);
|
|
91
|
-
});
|
package/scripts/build.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
const { existsSync, copyFileSync, unlinkSync, writeFileSync } = require("fs");
|
|
2
|
-
const { join } = require("path");
|
|
3
|
-
|
|
4
|
-
const {
|
|
5
|
-
mkdirs,
|
|
6
|
-
encoding,
|
|
7
|
-
srcDir,
|
|
8
|
-
listContent,
|
|
9
|
-
readContent,
|
|
10
|
-
} = require("./utils");
|
|
11
|
-
|
|
12
|
-
const outputDir = join(__dirname, "..", "www");
|
|
13
|
-
|
|
14
|
-
mkdirs(outputDir);
|
|
15
|
-
|
|
16
|
-
const copyFile = (src, dest) => {
|
|
17
|
-
existsSync(dest) && unlinkSync(dest);
|
|
18
|
-
mkdirs(dest);
|
|
19
|
-
copyFileSync(src, dest);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const copyTemplates = (folder) => {
|
|
23
|
-
mkdirs(folder);
|
|
24
|
-
["template.css", "template.html", "template.js"].map((v) =>
|
|
25
|
-
copyFile(join(__dirname, v), join(folder, v.replace("template", "index")))
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const buildContent = (filename) => {
|
|
30
|
-
const destFolder = join(outputDir, filename.replace(".md", ""));
|
|
31
|
-
copyTemplates(destFolder);
|
|
32
|
-
|
|
33
|
-
const content = readContent(filename, true);
|
|
34
|
-
|
|
35
|
-
writeFileSync(join(destFolder, "content.md"), content, encoding);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const generateIndex = (files) => {
|
|
39
|
-
copyTemplates(outputDir);
|
|
40
|
-
const content = `
|
|
41
|
-
# Table of Contents
|
|
42
|
-
|
|
43
|
-
${files
|
|
44
|
-
.map((f) => f.replace(".md", ""))
|
|
45
|
-
.map((f) => `- [${f}](./${f})`)
|
|
46
|
-
.join("\n\n")}
|
|
47
|
-
`.trim();
|
|
48
|
-
writeFileSync(join(outputDir, "content.md"), content, encoding);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const build = () => {
|
|
52
|
-
const files = listContent().map((f) => f.replace(srcDir, ""));
|
|
53
|
-
generateIndex(files);
|
|
54
|
-
return files.map(buildContent);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
build();
|
package/scripts/check-content.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
listContent,
|
|
3
|
-
readContent,
|
|
4
|
-
isTag,
|
|
5
|
-
listAssets,
|
|
6
|
-
baseAssetRef,
|
|
7
|
-
} = require("./utils");
|
|
8
|
-
|
|
9
|
-
const allAssets = listAssets();
|
|
10
|
-
|
|
11
|
-
const checkFilename = (filename) =>
|
|
12
|
-
filename
|
|
13
|
-
.split("/")
|
|
14
|
-
.pop()
|
|
15
|
-
.replace(".md", "")
|
|
16
|
-
.match(/^[\d]_[a-z\d\-]+$/g);
|
|
17
|
-
|
|
18
|
-
const isValidLinks = (url) => !url.match(/\s/g) && !!new URL(url)?.host;
|
|
19
|
-
|
|
20
|
-
const getUrls = (content) =>
|
|
21
|
-
(content.match(/href="([^"]*)/g) || []).map((v) => v.replace('href="', ""));
|
|
22
|
-
|
|
23
|
-
const checkAssets = (content) => {
|
|
24
|
-
const urls = (content.match(/src="([^"]*)/g) || []).map((v) =>
|
|
25
|
-
v.replace(`src="${baseAssetRef}`, "")
|
|
26
|
-
);
|
|
27
|
-
const invalid = urls.filter((v) => !allAssets.includes(v));
|
|
28
|
-
if (invalid.length > 0) {
|
|
29
|
-
console.error(
|
|
30
|
-
"Invalid referenced assets",
|
|
31
|
-
invalid.map((v) => `${baseAssetRef}${v}`)
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
return invalid.length === 0;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const checks = {
|
|
38
|
-
'File should start with "# "': (content) => content.startsWith("# "),
|
|
39
|
-
"Links must be valid": (content) => getUrls(content).every(isValidLinks),
|
|
40
|
-
"Links must not point to staging website": (content) =>
|
|
41
|
-
[
|
|
42
|
-
"http://www-staging.hestia.earth",
|
|
43
|
-
"https://www-staging.hestia.earth",
|
|
44
|
-
].every((v) => !content.includes(v)),
|
|
45
|
-
'Images and videos must be included in the "src/assets" folder': checkAssets,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const checkContent = (filename) => {
|
|
49
|
-
const content = readContent(filename);
|
|
50
|
-
return [
|
|
51
|
-
checkFilename(filename)
|
|
52
|
-
? ""
|
|
53
|
-
: "File names must contain lowercase letters, numbers or dashes only, and start with a number followed by an underscore for sorting.",
|
|
54
|
-
...Object.entries(checks)
|
|
55
|
-
.filter(([key, value]) => !value(content))
|
|
56
|
-
.map(([key, value]) => key),
|
|
57
|
-
].filter(Boolean);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const run = () => {
|
|
61
|
-
const files = listContent();
|
|
62
|
-
const allErrors = files
|
|
63
|
-
.map((f) => ({
|
|
64
|
-
f,
|
|
65
|
-
errors: checkContent(f),
|
|
66
|
-
}))
|
|
67
|
-
.filter(({ errors }) => errors.length);
|
|
68
|
-
|
|
69
|
-
if (allErrors.length) {
|
|
70
|
-
allErrors.map(({ f, errors }) => {
|
|
71
|
-
console.error("Error in", f, ":");
|
|
72
|
-
errors.map((e) => console.error(`\t- ${e}`));
|
|
73
|
-
});
|
|
74
|
-
process.exit(1);
|
|
75
|
-
} else {
|
|
76
|
-
process.exit(0);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
run();
|
package/scripts/template.css
DELETED
package/scripts/template.html
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<title>Markdown Preview</title>
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
|
-
|
|
8
|
-
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.2.1/marked.min.js"></script>
|
|
9
|
-
|
|
10
|
-
<link rel="stylesheet" href="https://cdn.hestia.earth/prod/styles.css">
|
|
11
|
-
<link rel="stylesheet" href="index.css">
|
|
12
|
-
</head>
|
|
13
|
-
<body>
|
|
14
|
-
<noscript>Please enable JavaScript to continue using this application.</noscript>
|
|
15
|
-
|
|
16
|
-
<a href="../"><< Back to index</a>
|
|
17
|
-
|
|
18
|
-
<div id="main"></div>
|
|
19
|
-
|
|
20
|
-
<script type="text/javascript" src="index.js"></script>
|
|
21
|
-
</body>
|
|
22
|
-
</html>
|
package/scripts/template.js
DELETED
package/scripts/utils.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
readdirSync,
|
|
3
|
-
readFileSync,
|
|
4
|
-
lstatSync,
|
|
5
|
-
existsSync,
|
|
6
|
-
mkdirSync,
|
|
7
|
-
} = require("fs");
|
|
8
|
-
const { join, resolve, parse } = require("path");
|
|
9
|
-
|
|
10
|
-
const encoding = "utf8";
|
|
11
|
-
const ROOT = resolve(join(__dirname, ".."));
|
|
12
|
-
const contentDir = join("src", "content");
|
|
13
|
-
const srcDir = join(ROOT, contentDir);
|
|
14
|
-
const assetDir = join(ROOT, "src", "assets");
|
|
15
|
-
|
|
16
|
-
const isDir = (path) => {
|
|
17
|
-
try {
|
|
18
|
-
return lstatSync(path).isDirectory();
|
|
19
|
-
} catch (_err) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const mkdirs = (folder) =>
|
|
25
|
-
!existsSync(parse(folder).dir) &&
|
|
26
|
-
mkdirSync(parse(folder).dir, { recursive: true });
|
|
27
|
-
|
|
28
|
-
const unique = (values) =>
|
|
29
|
-
values.some((v) => typeof v === "object")
|
|
30
|
-
? [...new Set(values.map((v) => JSON.stringify(v)))].map((v) =>
|
|
31
|
-
JSON.parse(v)
|
|
32
|
-
)
|
|
33
|
-
: [...new Set(values)];
|
|
34
|
-
|
|
35
|
-
const baseAssetRef = "/guide-content/assets";
|
|
36
|
-
const listAssets = (directory = assetDir) =>
|
|
37
|
-
readdirSync(directory)
|
|
38
|
-
.flatMap((path) =>
|
|
39
|
-
isDir(join(directory, path))
|
|
40
|
-
? listAssets(join(directory, path))
|
|
41
|
-
: !path.startsWith(".")
|
|
42
|
-
? join(directory, path)
|
|
43
|
-
: null
|
|
44
|
-
)
|
|
45
|
-
.filter(Boolean)
|
|
46
|
-
.map((v) => v.replace(assetDir, ""));
|
|
47
|
-
|
|
48
|
-
const listContent = (directory = srcDir) =>
|
|
49
|
-
readdirSync(directory)
|
|
50
|
-
.flatMap((path) =>
|
|
51
|
-
isDir(join(directory, path))
|
|
52
|
-
? listContent(join(directory, path))
|
|
53
|
-
: !path.startsWith(".")
|
|
54
|
-
? join(directory, path)
|
|
55
|
-
: null
|
|
56
|
-
)
|
|
57
|
-
.filter(Boolean)
|
|
58
|
-
.filter((f) => f.endsWith(".md"));
|
|
59
|
-
const contentPath = (filename) =>
|
|
60
|
-
filename.includes(srcDir) ? filename : join(srcDir, filename);
|
|
61
|
-
const contentUrl = (filename) =>
|
|
62
|
-
filename
|
|
63
|
-
.replace(/\//g, "-")
|
|
64
|
-
.substring(1)
|
|
65
|
-
.replace(/[\d]+_/g, "")
|
|
66
|
-
.replace(".md", "");
|
|
67
|
-
const readContent = (filename, removeTags = false) => {
|
|
68
|
-
const content = readFileSync(contentPath(filename), encoding).trim();
|
|
69
|
-
return removeTags ? removeContentTags(content) : content;
|
|
70
|
-
};
|
|
71
|
-
const getTitle = (value) => value.replace("# ", "");
|
|
72
|
-
|
|
73
|
-
const removeContentTags = (content) =>
|
|
74
|
-
content.replace(/\/[a-z]+\s\~(.*)\~/g, "");
|
|
75
|
-
const isTag =
|
|
76
|
-
(key = "tag") =>
|
|
77
|
-
(value) =>
|
|
78
|
-
value.startsWith(`/${key}`);
|
|
79
|
-
const getTag =
|
|
80
|
-
(key = "tag") =>
|
|
81
|
-
(value) =>
|
|
82
|
-
value.replace(`/${key} `, "").replace(/\~/g, "");
|
|
83
|
-
const getTags = (content) =>
|
|
84
|
-
content
|
|
85
|
-
.match(/\/([a-z]+)\s\~(.*)\~/g)
|
|
86
|
-
?.map((v) => ({
|
|
87
|
-
key: v.split(" ")[0].trim().replace("/", ""),
|
|
88
|
-
value: v.split(" ")[1].trim().replace(/\~/g, ""),
|
|
89
|
-
}))
|
|
90
|
-
.reduce(
|
|
91
|
-
(prev, { key, value }) => ({
|
|
92
|
-
...prev,
|
|
93
|
-
[key]: [...(prev[key] || []), value],
|
|
94
|
-
}),
|
|
95
|
-
{}
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
module.exports = {
|
|
99
|
-
encoding,
|
|
100
|
-
ROOT,
|
|
101
|
-
contentDir,
|
|
102
|
-
srcDir,
|
|
103
|
-
isDir,
|
|
104
|
-
mkdirs,
|
|
105
|
-
unique,
|
|
106
|
-
listContent,
|
|
107
|
-
contentPath,
|
|
108
|
-
contentUrl,
|
|
109
|
-
readContent,
|
|
110
|
-
getTitle,
|
|
111
|
-
removeContentTags,
|
|
112
|
-
isTag,
|
|
113
|
-
getTag,
|
|
114
|
-
getTags,
|
|
115
|
-
listAssets,
|
|
116
|
-
baseAssetRef,
|
|
117
|
-
};
|
package/test.js
DELETED