Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump the metalsmith group with 2 updates #2966

Merged
merged 4 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/metalsmith-lunr-index/index.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const markdown = require('@metalsmith/markdown')
const inPlace = require('@metalsmith/in-place')
const lunr = require('lunr')
const Metalsmith = require('metalsmith')

Expand All @@ -13,7 +13,7 @@ describe('metalsmith-lunr-index plugin', () => {
beforeAll((done) => {
Metalsmith('lib/metalsmith-lunr-index/fixtures')
.use(extractPageHeadings())
.use(markdown())
.use(inPlace({ transform: 'jstransformer-marked' }))
.use(plugin())
.build((err, files) => {
if (err) {
Expand Down
26 changes: 9 additions & 17 deletions lib/metalsmith.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ const { readFileSync } = require('fs')
const { dirname, join, resolve } = require('path')

// Third party metalsmith plugins and utilities
const inplace = require('@metalsmith/in-place') // render templating syntax in source files
const inPlace = require('@metalsmith/in-place') // render templating syntax in source files
const layouts = require('@metalsmith/layouts') // apply layouts to source files
const markdown = require('@metalsmith/markdown') // render markdown in source files
const permalinks = require('@metalsmith/permalinks') // apply a permalink pattern to files
const postcss = require('@metalsmith/postcss')
const sass = require('@metalsmith/sass') // convert Sass files to CSS using Dart Sass
const { glob } = require('glob') // Match files using glob patterns
const Metalsmith = require('metalsmith') // static site generator
const canonical = require('metalsmith-canonical') // add a canonical url property to pages
const renamer = require('metalsmith-renamer') // rename files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

const slugger = require('slugger') // generate slugs from titles

// Helpers and config
Expand Down Expand Up @@ -102,16 +100,6 @@ module.exports = metalsmith
env: (value) => metalsmith.env(value)
})

// rename .md files to .md.njk, so they're passed through the Nunjucks parser
.use(renamer({
markdown: {
pattern: '**/*.md',
rename: (name) => {
return `${name}.njk`
}
}
}))

// extract page headings
.use(extractPageHeadings())

Expand Down Expand Up @@ -203,19 +191,23 @@ module.exports = metalsmith
.use(titleChecker())

// render templating syntax in source files
.use(inplace({
pattern: '**/*.njk',
.use(inPlace({
pattern: '**/*.{md,njk}',
transform: 'jstransformer-nunjucks',
engineOptions: nunjucksOptions
}))

// render markdown in source files
.use(markdown({
.use(inPlace({
transform: 'jstransformer-marked',
engineOptions: {
breaks: true, // Enable line breaks
mangle: false, // Don't mangle emails
smartypants: true, // use "smart" typographic punctuation
highlight: highlighter,
renderer: new DesignSystemRenderer() // Markdown renderer

// Custom markdown renderer
renderer: new DesignSystemRenderer()
Copy link
Contributor

@domoscargin domoscargin Jul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our custom renderer uses a separate marked install - we had some issues in the past around keeping that in sync with jstransformer-marked. Right now, that's using v4.3.0 of marked, whereas the custom renderer is using v5.0.2.

Though I guess metalsmith-markdown also uses an internal version of marked (v4.3.0 at the mo), so it's probably not a problem since the dependencies are the same. The explicit transform option in inPlace is really helpful in explaining what's using what here, so hopefully any issues would be easier to debug in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@domoscargin Good point. Shall I drop that last commit, one for another day?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, keep it - it's the same issue but we drop a dependency, so an improvement in that sense!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brill, will do

For reference, the dependencies are still the same (which helps)

Before

├─┬ @metalsmith/[email protected]
│ └── [email protected]
└── [email protected]

After

├─┬ [email protected]
│ └── [email protected]
└── [email protected]

}
}))

Expand Down
Loading