@rettangoli/sites 0.2.2 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rettangoli/sites",
3
- "version": "0.2.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": "^3.2.4"
32
+ "vitest": "^4.0.15"
33
33
  },
34
34
  "scripts": {
35
35
  "test": "vitest run --reporter=verbose"
package/src/cli/build.js CHANGED
@@ -8,9 +8,10 @@ import { loadSiteConfig } from '../utils/loadSiteConfig.js';
8
8
  * @param {string} options.rootDir - Root directory of the site (defaults to cwd)
9
9
  * @param {Object} options.md - Optional markdown renderer
10
10
  * @param {boolean} options.quiet - Suppress build output logs
11
+ * @param {boolean} options.isScreenshotMode - Whether building for screenshot capture
11
12
  */
12
13
  export const buildSite = async (options = {}) => {
13
- const { rootDir = process.cwd(), md, functions, quiet = false } = options;
14
+ const { rootDir = process.cwd(), md, functions, quiet = false, isScreenshotMode = false } = options;
14
15
 
15
16
  // Load config file if needed
16
17
  let config = {};
@@ -23,7 +24,8 @@ export const buildSite = async (options = {}) => {
23
24
  rootDir,
24
25
  md: md || config.mdRender,
25
26
  functions: functions || config.functions || {},
26
- quiet
27
+ quiet,
28
+ isScreenshotMode
27
29
  });
28
30
 
29
31
  await build();
@@ -31,7 +31,7 @@ function isObject(item) {
31
31
  return item && typeof item === 'object' && !Array.isArray(item);
32
32
  }
33
33
 
34
- export function createSiteBuilder({ fs, rootDir = '.', md, functions = {}, quiet = false }) {
34
+ export function createSiteBuilder({ fs, rootDir = '.', md, functions = {}, quiet = false, isScreenshotMode = false }) {
35
35
  return async function build() {
36
36
  // Use provided md or default to rtglMarkdown
37
37
  const mdInstance = md || rtglMarkdown(MarkdownIt);
@@ -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 extractFrontmatter(pagePath) {
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
- return frontmatter;
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 = extractFrontmatter(itemPath);
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
  });
@@ -249,6 +254,7 @@ export function createSiteBuilder({ fs, rootDir = '.', md, functions = {}, quiet
249
254
  const pageData = deepMerge(globalData, frontmatter);
250
255
  pageData.collections = collections;
251
256
  pageData.page = { url };
257
+ pageData.build = { isScreenshotMode };
252
258
 
253
259
  let processedPageContent;
254
260
 
@@ -141,9 +141,9 @@ const screenshotCommand = async (options = {}) => {
141
141
  console.log('📋 Ignore patterns:', ignorePatterns);
142
142
  }
143
143
 
144
- // Build the site first
144
+ // Build the site first (with screenshot mode enabled)
145
145
  console.log('Building site...');
146
- await buildSite({ rootDir });
146
+ await buildSite({ rootDir, isScreenshotMode: true });
147
147
  console.log('Build complete');
148
148
 
149
149
  // Start temporary server