
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
metalsmith-react-tpl
Advanced tools
Use React in metalsmith as a templating language
metalsmith-react-tpl
is a metalsmith plugin to render files using React.js based templates.
npm install metalsmith-react-tpl
Install the node modules and then add the metalsmith-react-tpl
key to your metalsmith.json
plugins. The simplest use case just requires the template engine you want to use:
{
"plugins": {
"metalsmith-react-tpl": true
}
}
If you want to specify additional options, pass in an object:
{
"plugins": {
"metalsmith-react-tpl": {
"baseFile": "base.jsx",
"isStatic": true,
"directory": "templates"
}
}
}
Simplest use case:
var templates = require('metalsmith-react-tpl');
metalsmith.use(templates());
To specify additional options:
metalsmith.use(templates({
baseFile: 'base.html'
isStatic: true,
directory: 'templates'
}));
If a rtemplate
field is set in the yaml
front-matter of your markdown files, metalsmith-react-tpl
will use the specified template instead of default.jsx
You can also set noConflict
to false
and the plugin will use the template
field instead of rtemplate
field in the yaml front-matter.
If you import css or any other non-standard js code using 'require',
you might want to make use of the requireIgnoreExt
to ignore those files.
baseFile
(optional)default: null
You can pass in a .html or .jsx baseFile depending on your setup, using a react baseFile will allow you to continue using React even for your main layout template.
Using a .jsx baseFile will result in the baseFile.jsx to use isStatic: false
and be rendered with ReactDOM.renderToString option and then will not have any reactid's passed through (Your templates will still go through the isStatic
option).
Specifies a file which the contents of the react template will render into.
This is similar to the index.html file which you ReactDOM.render() your components in.
In your base file, put {{content}}
in the location where you want your data will render into.
isStatic
(optional)default: true
Since this is a static site generator, by default, it will render the React Templates using renderToStaticMarkup()
However, you may choose to make a static site generator with React functionalities (similar to first render from server) and subsequently pull page routes via JavaScript / React.
Setting this parameter to false
will cause templates to be parsed using renderToString()
noConflict
(optional)default: true
By default, this plugin will read from the rtemplate
key in your yaml
front-matter. However, if this is the only templating plugin, you may
set noConflict
to false
to use the template
key instead.
directory
(optional)default: templates
Sets the directory which your react templates (or baseFile) resides.
pattern
(optional)default: **/*
Specifies a file filter pattern
html
(optional)default: true
Renames files from *.md to *.html
preserve
(optional)default: false
Stores a copy of un-templated contents into rawContents
meta.
requireIgnoreExt
(optional)default: []
A list of extensions to ignore. For example, {requireIgnoreExt: ['.css']}
would
ignore declarations like require('file.css')
Thanks to metalsmith-react-templates who i originally forked from.
FAQs
Use React in metalsmith as a templating language
The npm package metalsmith-react-tpl receives a total of 75 weekly downloads. As such, metalsmith-react-tpl popularity was classified as not popular.
We found that metalsmith-react-tpl demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.