Skip to content

Commit

Permalink
Update to latest Metalsmith Layouts plugin (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
willeastcott authored Feb 14, 2023
1 parent 4481921 commit d4c9829
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 111 deletions.
4 changes: 3 additions & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ Metalsmith(__dirname)
partialName: 'shader-editor-navigation'
}))
.use(tutorials('tutorials')())
.use(layouts())
.use(layouts({
pattern: '**/*.html'
}))
.use(locale()())
.use(i18nout()({
data: localization
Expand Down
7 changes: 1 addition & 6 deletions lib/i18n/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ module.exports = function makePlugin() {

return function (files, metalsmith, done) {
for (const filename in files) {
// add locale metadata to files

// Ensure Windows paths are converted to forward slashes as necessary
const filenameForwardSlashes = filename.replace(/\\/g, "/");

const locale = filenameForwardSlashes.split("/")[0];
const locale = filename.split(path.sep)[0];
files[filename].locale = locale; // locale: 'en'
files[filename][locale] = true; // 'en': true
}
Expand Down
6 changes: 5 additions & 1 deletion lib/tutorials/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@ module.exports = function makePlugin(dir) {
contents: Buffer.from(taggedProjectTemplate(project))
};

files[file.path + '/index.html'] = file;
// change path separators to OS specific
let fileKey = file.path + '/index.html';
fileKey = fileKey.split('/').join(path.sep);

files[fileKey] = file;
}
}

Expand Down
117 changes: 15 additions & 102 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
},
"devDependencies": {
"@metalsmith/layouts": "2.4.0",
"@metalsmith/layouts": "^2.6.0",
"@metalsmith/markdown": "^1.9.0",
"@metalsmith/permalinks": "2.4.1",
"@playcanvas/eslint-config": "^1.3.0",
Expand Down

0 comments on commit d4c9829

Please sign in to comment.