Skip to content

Commit

Permalink
lume -s improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Mar 27, 2021
1 parent 7f0ea01 commit 287ca8c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ project adheres to [Semantic Versioning](http://semver.org/).
- The `permalink` value can be a relative path (must starts with `./` or `../`), that will be resolved to the directory name.
- The `url` filter allows urls starting with `~` to reference to source files that will be automatically resolved to the final url.

### Fixed
- On reload files in `lume --serve`, some ignored files were not correctly filtered.
- Improved `lume --serve`: only rebuild the site if it's needed.

## [0.16.3] - 2021-03-21
### Fixed
- SVGO dependency fails SVG plugin [#43]
Expand Down
22 changes: 17 additions & 5 deletions site.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,27 @@ export default class Site {
async update(files) {
await this.dispatchEvent({ type: "beforeUpdate", files });

let rebuildIsNeeded = false;

for (const file of files) {
// file inside a _data file or folder
// It's an ignored file
if (this.source.isIgnored(file)) {
continue;
}

// It's inside a _data file or folder
if (file.includes("/_data/") || file.match(/\/_data.\w+$/)) {
await this.source.loadFile(file);
rebuildIsNeeded = true;
continue;
}

// file path contains /_ or /.
// The path contains /_ or /.
if (file.includes("/_") || file.includes("/.")) {
continue;
}

//Static file
// It's a static file
const entry = this.source.isStatic(file);

if (entry) {
Expand All @@ -253,11 +261,15 @@ export default class Site {
continue;
}

//Default
// Default
await this.source.loadFile(file);
rebuildIsNeeded = true;
}

if (rebuildIsNeeded) {
await this.#buildPages();
}

await this.#buildPages();
await this.dispatchEvent({ type: "afterUpdate", files });
}

Expand Down
13 changes: 13 additions & 0 deletions source.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ export default class Source {
return false;
}

/**
* Check whether a path is ignored or not
*/
isIgnored(path) {
for (const pattern of this.ignored) {
if (path.startsWith(pattern)) {
return true;
}
}

return false;
}

/**
* Load a directory recursively
*/
Expand Down

0 comments on commit 287ca8c

Please sign in to comment.