@rettangoli/sites 0.2.3 → 0.2.4
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/package.json +2 -2
- package/src/createSiteBuilder.js +11 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rettangoli/sites",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Generate static sites using Markdown and YAML. Straightforward, zero-complexity. Complete toolkit for landing pages, blogs, documentation, admin dashboards, and more.git remote add origin git@github.com:yuusoft-org/sitic.git",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Luciano Hanyon Wu",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"memfs": "^4.36.0",
|
|
31
31
|
"puty": "^0.0.4",
|
|
32
|
-
"vitest": "^
|
|
32
|
+
"vitest": "^4.0.15"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"test": "vitest run --reporter=verbose"
|
package/src/createSiteBuilder.js
CHANGED
|
@@ -96,8 +96,8 @@ export function createSiteBuilder({ fs, rootDir = '.', md, functions = {}, quiet
|
|
|
96
96
|
|
|
97
97
|
readTemplatesRecursively(templatesDir);
|
|
98
98
|
|
|
99
|
-
// Function to extract frontmatter from a page file
|
|
100
|
-
function
|
|
99
|
+
// Function to extract frontmatter and content from a page file
|
|
100
|
+
function extractFrontmatterAndContent(pagePath) {
|
|
101
101
|
const pageFileContent = fs.readFileSync(pagePath, 'utf8');
|
|
102
102
|
const lines = pageFileContent.split('\n');
|
|
103
103
|
let frontmatterStart = -1;
|
|
@@ -122,7 +122,11 @@ export function createSiteBuilder({ fs, rootDir = '.', md, functions = {}, quiet
|
|
|
122
122
|
frontmatter = yaml.load(frontmatterContent, { schema: yaml.JSON_SCHEMA }) || {};
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
// Extract content after frontmatter
|
|
126
|
+
const contentStart = frontmatterEnd + 1;
|
|
127
|
+
const content = lines.slice(contentStart).join('\n').trim();
|
|
128
|
+
|
|
129
|
+
return { frontmatter, content };
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
// Function to scan all pages and build collections
|
|
@@ -144,8 +148,8 @@ export function createSiteBuilder({ fs, rootDir = '.', md, functions = {}, quiet
|
|
|
144
148
|
// Recursively scan subdirectories
|
|
145
149
|
scanPages(dir, relativePath);
|
|
146
150
|
} else if (item.isFile() && (item.name.endsWith('.yaml') || item.name.endsWith('.md'))) {
|
|
147
|
-
// Extract frontmatter
|
|
148
|
-
const frontmatter =
|
|
151
|
+
// Extract frontmatter and content
|
|
152
|
+
const { frontmatter, content } = extractFrontmatterAndContent(itemPath);
|
|
149
153
|
|
|
150
154
|
// Calculate URL
|
|
151
155
|
const baseFileName = item.name.replace(/\.(yaml|md)$/, '');
|
|
@@ -176,7 +180,8 @@ export function createSiteBuilder({ fs, rootDir = '.', md, functions = {}, quiet
|
|
|
176
180
|
}
|
|
177
181
|
collections[trimmedTag].push({
|
|
178
182
|
data: frontmatter,
|
|
179
|
-
url: url
|
|
183
|
+
url: url,
|
|
184
|
+
content: content
|
|
180
185
|
});
|
|
181
186
|
}
|
|
182
187
|
});
|