Comparing version 1.10.3 to 1.10.4
@@ -8,2 +8,8 @@ # Change Log | ||
## [1.10.3] - 2024-06-10 | ||
### Fixed | ||
- Don't display warning if detected encoding but no declared encoding | ||
## [1.10.3] - 2024-06-09 | ||
@@ -54,3 +60,3 @@ | ||
- `ContentStepConfig.getOutputFile(context)` can now return SsgFile or file path | ||
- `ContentStepConfig.getOutputFile(context)` can now return FileContents or file path | ||
@@ -73,3 +79,3 @@ ## [1.7.6] - 2024-05-17 | ||
- `SsgContext.readOrNew(filename, dir)` becomes `SsgContext.setOutputFrom(filename)` to denote it affects the context's `outputFile`. | ||
- `HtmlSsgFile.create(fileInfo, fileContents)` becomes `HtmlSsgFile.create(fileInfo)` to denote it uses `fileInfo`'s `contents`. | ||
- `HtmlFileContents.create(fileInfo, fileContents)` becomes `HtmlFileContents.create(fileInfo)` to denote it uses `fileInfo`'s `contents`. | ||
@@ -86,3 +92,3 @@ ## [1.7.4] - 2024-04-13 | ||
Update document title from SsgFile title. | ||
Update document title from FileContents title. | ||
@@ -131,3 +137,3 @@ ### Changed | ||
- HtmlSsgFile:meta.description | ||
- HtmlFileContents:meta.description | ||
@@ -252,3 +258,3 @@ ## [1.4.5] - 2023-04-23 | ||
- `SsgFileLang.variants` can contain `""` if there is the same file is found without language suffix. | ||
- `FileContentsLang.variants` can contain `""` if there is the same file is found without language suffix. | ||
@@ -265,3 +271,3 @@ ## [1.2.5] - 2022-11-13 | ||
- `SsgFile.lang.variants` don't include current `SsgFile.lang.lang` | ||
- `FileContents.lang.variants` don't include current `FileContents.lang.lang` | ||
@@ -272,3 +278,3 @@ ## [1.2.3] - 2022-11-13 | ||
- Find `SsgFile.lang.variants` for path with no directory. | ||
- Find `FileContents.lang.variants` for path with no directory. | ||
@@ -291,3 +297,3 @@ ## [1.2.2] - 2022-11-13 | ||
- `SsgFile.lang` changed from a single string to a `{ lang, variants }` so that you can know which variants of a file exist. | ||
- `FileContents.lang` changed from a single string to a `{ lang, variants }` so that you can know which variants of a file exist. | ||
@@ -312,10 +318,10 @@ ## [1.1.1] - 2022-11-11 | ||
- `SsgFile.readOrNew()` to allow creating a SsgFile in memory that doesn't exist on disk. | ||
- `FileContents.readOrNew()` to allow creating a FileContents in memory that doesn't exist on disk. | ||
### Changed | ||
- `FileInfo` renamed as `SsgFile` to both improve consistency and avoid name collisions. | ||
- `HtmlFileInfo` renamed as `HtmlSsgFile` for the same reasons. | ||
- `writeFileInfo()` becomes `ssgFile.write()` | ||
- `getFileInfo()` becomes `SsgFile.read()` | ||
- `FileInfo` renamed as `FileContents` to both improve consistency and avoid name collisions. | ||
- `HtmlFileInfo` renamed as `HtmlFileContents` for the same reasons. | ||
- `writeFileInfo()` becomes `FileContents.write()` | ||
- `getFileInfo()` becomes `FileContents.read()` | ||
- `SsgContext.locale` becomes a single string (not an array of strings anymore) as you cannot output for multiple languages at once (use one context per language if you need to do so). | ||
@@ -322,0 +328,0 @@ |
import { SsgContext } from "./SsgContext.js"; | ||
import { HtmlSsgFile } from "./util"; | ||
import { HtmlFileContents } from "./util"; | ||
export interface HtmlSsgContext<V = any> extends SsgContext<V> { | ||
file: HtmlSsgFile; | ||
file: HtmlFileContents; | ||
getVar(varName: string): string | undefined; | ||
setVar(varName: string, value: any): void; | ||
} |
import { ObjectUtil } from "./util/ObjectUtil.js"; | ||
import { ConsoleLogger } from "./ConsoleLogger"; | ||
import { FileContents, HtmlSsgFile } from "./util"; | ||
import { FileContents, HtmlFileContents } from "./util"; | ||
import * as assert from "node:assert"; | ||
@@ -84,3 +84,3 @@ export class SsgContextImpl { | ||
this.file = filePath.endsWith(".html") | ||
? HtmlSsgFile.read(filePath) | ||
? HtmlFileContents.read(filePath) | ||
: FileContents.read(filePath); | ||
@@ -106,3 +106,3 @@ return this.file; | ||
const fileInfo = new FileContents(filePath, encoding, this.file.contents, creationDate, lang); | ||
outFile = HtmlSsgFile.create(fileInfo); | ||
outFile = HtmlFileContents.create(fileInfo); | ||
} | ||
@@ -109,0 +109,0 @@ else { |
@@ -5,3 +5,3 @@ /// <reference types="node" /> | ||
*/ | ||
export type SsgFileLang = { | ||
export type FileContentsLang = { | ||
/** | ||
@@ -43,3 +43,3 @@ * The detected language for the file ("fr" for instance). | ||
*/ | ||
readonly lang: SsgFileLang; | ||
readonly lang: FileContentsLang; | ||
/** | ||
@@ -73,7 +73,7 @@ * A file path with "directory/prefix[_lang].ext" | ||
*/ | ||
lang: SsgFileLang); | ||
lang: FileContentsLang); | ||
get contents(): string; | ||
set contents(value: string); | ||
/** | ||
* Read a file to produce a SsgFile, or fail if the file doesn't exist. | ||
* Read a file to produce a FileContents, or fail if the file doesn't exist. | ||
* | ||
@@ -85,3 +85,3 @@ * @param fileName | ||
/** | ||
* Read a file or instantiate a brand new SsgFile if it doesn't exist. | ||
* Read a file or instantiate a brand new FileContents if it doesn't exist. | ||
* | ||
@@ -97,3 +97,3 @@ * @param fileName | ||
*/ | ||
static getLang(filePath: string): SsgFileLang; | ||
static getLang(filePath: string): FileContentsLang; | ||
/** | ||
@@ -100,0 +100,0 @@ * Get the text contents of a file, and how it is encoded. |
@@ -42,3 +42,3 @@ import fs from "fs"; | ||
/** | ||
* Read a file to produce a SsgFile, or fail if the file doesn't exist. | ||
* Read a file to produce a FileContents, or fail if the file doesn't exist. | ||
* | ||
@@ -55,3 +55,3 @@ * @param fileName | ||
/** | ||
* Read a file or instantiate a brand new SsgFile if it doesn't exist. | ||
* Read a file or instantiate a brand new FileContents if it doesn't exist. | ||
* | ||
@@ -58,0 +58,0 @@ * @param fileName |
export * from "./FileContents.js"; | ||
export * from "./FileUtil.js"; | ||
export * from "./HtmlSsgFile.js"; | ||
export * from "./HtmlFileContents.js"; | ||
export * from "./HtmlUtil.js"; |
export * from "./FileContents.js"; | ||
export * from "./FileUtil.js"; | ||
export * from "./HtmlSsgFile.js"; | ||
export * from "./HtmlFileContents.js"; | ||
export * from "./HtmlUtil.js"; |
@@ -5,3 +5,3 @@ { | ||
"author": "Jérôme Beau <javarome@gmail.com> (https://javarome.com)", | ||
"version": "1.10.3", | ||
"version": "1.10.4", | ||
"description": "Static Site Generation TypeScript API", | ||
@@ -8,0 +8,0 @@ "exports": "./dist/src/index.js", |
- [[Steps]] | ||
- [[SsgFile]] | ||
- [[FileContents]] | ||
- [[Context]] |
@@ -38,3 +38,3 @@ A [SsgContext](https://github.com/Javarome/ssg-api/blob/main/src/SsgContext.ts) is provided to Ssg methods (`SsgStep.execute(content)` and `ReplaceCommand.execute(context)`) to carry information about : | ||
Attributes of the `context.file` (including as a `HtmlSsgFile`) are implicitly available as variables, | ||
Attributes of the `context.file` (including as a `HtmlFileContents`) are implicitly available as variables, | ||
so that you can include `<!--#echo var="title" -->` in your files where you want the HTML title to be inserted for instance. | ||
@@ -41,0 +41,0 @@ |
@@ -1,2 +0,2 @@ | ||
Ssg manipulates files through a `SsgFile` types, which contain: | ||
Ssg manipulates files through a `FileContents` types, which contain: | ||
@@ -11,7 +11,7 @@ - the `name` of the file (including relative path) | ||
- get one for an existing (likely input) file using `SsgFile.read(context, fileName, encoding?)` | ||
- get or create in memory (if it doesn't exist) using `SsgFile.readOrNew(context, fileName, encoding?)` | ||
- get one for an existing (likely input) file using `FileContents.read(context, fileName, encoding?)` | ||
- get or create in memory (if it doesn't exist) using `FileContents.readOrNew(context, fileName, encoding?)` | ||
- save its (likely output) contents it in the output directory, using `context.file.write()` | ||
## HtmlSsgFile | ||
## HtmlFileContents | ||
@@ -18,0 +18,0 @@ HTML files automatic parsing will provide additional properties: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
139047