@stati/core 1.29.1 → 1.29.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/dist/core/templates.d.ts
CHANGED
|
@@ -23,6 +23,15 @@ export interface RenderPageExtras {
|
|
|
23
23
|
/** Image state of the page; without it `stati.image()` emits a plain `<img>` */
|
|
24
24
|
images?: PageImages | undefined;
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Discovers partials in the hierarchy for a given page path.
|
|
28
|
+
* Scans all parent directories for folders starting with underscore.
|
|
29
|
+
*
|
|
30
|
+
* @param pagePath - The path to the page (relative to srcDir), with `/` or `\` separators
|
|
31
|
+
* @param config - Stati configuration
|
|
32
|
+
* @returns Object mapping partial names to their file paths
|
|
33
|
+
*/
|
|
34
|
+
export declare function discoverPartials(pagePath: string, config: StatiConfig): Promise<Record<string, string>>;
|
|
26
35
|
/**
|
|
27
36
|
* Clear the cached template engine. Call this when templates change in dev mode
|
|
28
37
|
* so the next build recompiles them, or when shutting down a dev session.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/core/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAG1B,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,OAAO,EAEP,QAAQ,EACR,MAAM,EACP,MAAM,mBAAmB,CAAC;AAuB3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,KAAK,EAAE,UAAU,EAAqB,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,eAAe,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,OAAO,C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AAED,wBAAsB,UAAU,CAC9B,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EACnB,GAAG,EAAE,GAAG,EACR,UAAU,CAAC,EAAE,OAAO,EAAE,EACtB,QAAQ,CAAC,EAAE,SAAS,EAAE,EACtB,MAAM,CAAC,EAAE,OAAO,mBAAmB,EAAE,WAAW,EAChD,GAAG,CAAC,EAAE,QAAQ,EAAE,EAChB,MAAM,CAAC,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,gBAAgB,GACxB,OAAO,CAAC,YAAY,CAAC,CA8RvB"}
|
package/dist/core/templates.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Eta } from 'eta';
|
|
2
|
-
import { join,
|
|
2
|
+
import { join, relative, basename, posix } from 'node:path';
|
|
3
3
|
import glob from 'fast-glob';
|
|
4
4
|
import { createFallbackLogger } from './utils/index.js';
|
|
5
5
|
import { TEMPLATE_EXTENSION } from '../constants.js';
|
|
@@ -50,15 +50,16 @@ function createNavView(helpers, reads) {
|
|
|
50
50
|
* Discovers partials in the hierarchy for a given page path.
|
|
51
51
|
* Scans all parent directories for folders starting with underscore.
|
|
52
52
|
*
|
|
53
|
-
* @param pagePath - The path to the page (relative to srcDir)
|
|
53
|
+
* @param pagePath - The path to the page (relative to srcDir), with `/` or `\` separators
|
|
54
54
|
* @param config - Stati configuration
|
|
55
55
|
* @returns Object mapping partial names to their file paths
|
|
56
56
|
*/
|
|
57
|
-
async function discoverPartials(pagePath, config) {
|
|
57
|
+
export async function discoverPartials(pagePath, config) {
|
|
58
58
|
const srcDir = resolveSrcDir(config);
|
|
59
59
|
const partials = {};
|
|
60
|
-
// Get the directory of the current page
|
|
61
|
-
|
|
60
|
+
// Get the directory of the current page. Windows paths use backslashes, so convert them
|
|
61
|
+
// first, or the folders between the root and the page's own folder are skipped.
|
|
62
|
+
const pageDir = posix.dirname(pagePath.replace(/\\/g, '/'));
|
|
62
63
|
const pathSegments = pageDir === '.' ? [] : pageDir.split('/');
|
|
63
64
|
// Scan from root to current directory (least specific first)
|
|
64
65
|
// This allows more specific partials to override less specific ones
|