Skip to content

Commit

Permalink
Merge branch 'master' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Jul 27, 2023
2 parents fc8b331 + 01c269b commit 03e24ef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ and this project try to adheres to [Semantic Versioning](https://semver.org/),
but not always is possible (due the use of unstable features from Deno).
Any BREAKING CHANGE between minor versions will be documented here in upper case.

## [Unreleased]
## [1.18.4] - Unreleased
### Added
- Generic to `Page` to set the data interface. For example: `Page<Post>`.

## [1.18.3] - 2023-07-26
### Fixed
- `relative_urls` give wrong URL when `prettyUrls` is disabled [#451]
- `module` loader cache.

## [1.18.2] - 2023-07-21
### Added
Expand Down Expand Up @@ -2340,7 +2345,8 @@ The first version.
[#450]: https://github.com/lumeland/lume/issues/450
[#451]: https://github.com/lumeland/lume/issues/451
[Unreleased]: https://github.com/lumeland/lume/compare/v1.18.2...HEAD
[1.18.4]: https://github.com/lumeland/lume/compare/v1.18.3...HEAD
[1.18.3]: https://github.com/lumeland/lume/compare/v1.18.2...v1.18.3
[1.18.2]: https://github.com/lumeland/lume/compare/v1.18.1...v1.18.2
[1.18.1]: https://github.com/lumeland/lume/compare/v1.18.0...v1.18.1
[1.18.0]: https://github.com/lumeland/lume/compare/v1.17.5...v1.18.0
Expand Down
14 changes: 7 additions & 7 deletions core/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import type { PageData, ProxyComponents } from "../core.ts";
import type { Entry } from "./fs.ts";

/** A page of the site */
export class Page {
export class Page<D extends PageData = PageData> {
/** The src info */
src: Src;

/**
* Used to save the page data
*/
data: PageData = {} as PageData;
data: D = {} as D;

/**
* Internal data. Used to save arbitrary data by plugins and processors
Expand Down Expand Up @@ -58,14 +58,14 @@ export class Page {
}

/** Duplicate this page. */
duplicate(index?: number, data: Data = {}): Page {
duplicate(index?: number, data: D = {} as D): Page {
const page = new Page({ ...this.src });

if (index !== undefined) {
page.src.path += `[${index}]`;
}

page.data = data as PageData;
page.data = data;
page.data.page = page;

return page;
Expand Down Expand Up @@ -158,12 +158,12 @@ export interface Src {
export type Content = Uint8Array | string;

/** The data of a page */
export interface Data {
export interface Data<D extends PageData = PageData> {
/** List of tags assigned to a page or folder */
tags?: string[];

/** The url of a page */
url?: string | ((page: Page) => string) | false;
url?: string | ((page: Page<D>) => string) | false;

/** Mark the page as a draft */
draft?: boolean;
Expand Down Expand Up @@ -193,7 +193,7 @@ export interface Data {
comp?: ProxyComponents;

/** The page object */
page?: Page;
page?: Page<D>;

// deno-lint-ignore no-explicit-any
[index: string]: any;
Expand Down
1 change: 1 addition & 0 deletions core/loaders/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const cached = new Set<string>();
export default async function module(path: string): Promise<Data> {
const url = isUrl(path) ? path : `file://${path}`;
const specifier = cached.has(url) ? `${url}#${Date.now()}` : url;
cached.add(url);
const mod = await import(specifier);
return toData(mod);
}
Expand Down

0 comments on commit 03e24ef

Please sign in to comment.