Skip to content

Commit

Permalink
Fix truncated asset path strings
Browse files Browse the repository at this point in the history
There was an issue where asset names were getting truncated by a one character, but it was caused by extra unnecessary files getting ingested into the asset build.

This commit:

- Adds to buildAssets.js an error throw, when the conditions for the truncation exist.
- Removes the file that has been the main culprit — a README.md in the blog assets which 11ty thought was a .md file to be rendered into HTML.

Fixes #3859
  • Loading branch information
beechnut committed Jun 10, 2024
1 parent 1432a03 commit a034bcd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
7 changes: 0 additions & 7 deletions assets/blog/README.md

This file was deleted.

3 changes: 3 additions & 0 deletions config/buildAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ async function createAssetPaths() {
file.indexOf(publicDir) + publicDir.length,
);
const hashedAt = name.lastIndexOf('-');
if (hashedAt === -1) {
throw new Error(`hashedAt is -1, which is an error likely caused by a stray file (${file}) being pulled into the assets build path`)
}
const originalName = name.slice(0, hashedAt);
const key = `${originalName}${ext}`;
return {
Expand Down

0 comments on commit a034bcd

Please sign in to comment.