Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@holidayextras/static-site-generator
Advanced tools
Holiday Extras Static Site Generator in metalsmith / react
This is using metalsmith and react to create a static site given params.
git clone git@github.com:holidayextras/static-site-generator.git
cd static-site-generator
npm i
npm run build
src
src param provided for the .md file directorydataSource
the source to pull the content from as a function (or object as described below)dataSource.type
This can currently be either hxseo or prismicdataSource.url
This is the endpoint url for hxseo or prismic apidataSource.token
This is the token to pass in if the endpoint is privatetemplateDir
templateDir param provided for the template directorylayoutDir
layoutDir param provided for the layouts directorydestination
destination param provided for the output directoryassets
assets param provided for the assets directoryOptional
You can pass in a config
param too setup an object used in pages (domain, default agents etc)
webpack
is optional if you want to create a common js for the site and page specific js files for isomorphic pages. (This will be a link to the webpack.config.js file)
This repoistory is available on npm here, if you wish to release a new version simply bump the package.json version number and the build process will take care of the rest.
To add a store to the SSG build when using React
as a template, you can either pass in a store to the src/*.md
files or you can pass in a global store into the main SSG setup.
SSG({
src: path.join( __dirname, '..' ),
clean: clean,
config: config,
showReactIDs: true,
dataSource: {
type: 'api',
token: token,
initSetup: initSetup,
state: '../stores/mainStore.js'
},
layoutDir: '_layouts',
templateDir: '_layouts/_templates',
destination: '_site',
assets: 'public',
webpack: 'webpack.config.js'
})
or
---
template: mainTemplate.jsx
baseFile: baseTemplate.jsx
permalink: false
store: '../stores/mainStore.js'
dataSource:
host: 'api1.example.com'
port: '80'
type: 'api1'
query: '/getPagesFromHere?pages=test/'
repeater: 'data'
pageDataField: 'attributes'
pageNameField: 'pageName'
You can now build multiple API endpoints within a single app / template group, please see this example on how you can do this.
app/index.js
import config from '../config/'
import initSetup from '../config/initSetup'
const token = '0123456789'
SSG({
src: path.join( __dirname, '..' ),
clean: clean,
config: config,
showReactIDs: true,
dataSource: {
type: 'api',
token: token,
initSetup: initSetup
},
layoutDir: '_layouts',
templateDir: '_layouts/_templates',
destination: '_site',
assets: 'public',
webpack: 'webpack.config.js'
})
config/initSetup.js
const token = process.env.HAPI_TOKEN || '9876543210'
const initSetup = params => {
if ( !params.dataSource.type === 'api1' ) return params
params.dataSource.query += '&token=' + token
return params
}
export initSetup
src/api1.md
---
template: mainTemplate.jsx
baseFile: baseTemplate.jsx
permalink: false
dataSource:
host: 'api1.example.com'
port: '80'
type: 'api1'
query: '/getPagesFromHere?pages=test/'
repeater: 'data'
pageDataField: 'attributes'
pageNameField: 'pageName'
src/api2.md
---
template: mainTemplate.jsx
baseFile: baseTemplate.jsx
permalink: false
dataSource:
host: 'api2.example.com'
query: '/getPagesFromThere?thePages=anotherTest/'
repeater: 'articles'
pageNameField: 'html_url'
postPageNameChange: 'strip'
FAQs
Holiday Extras Static Site Generator in metalsmith / react
We found that @holidayextras/static-site-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.