
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.
A gulp plugin to generate a static site.
var ssg = require('gulp-ssg');
var site = {
title: 'My site'
};
gulp.task('html', function() {
return gulp.src('content/**/*.md')
.pipe(ssg(site))
.pipe(gulp.dest('public/'));
});
This will rename the files so they have pretty URLs e.g.
content/index.md -> public/index.html
content/foo.md -> public/foo/index.html
content/bar/index.md -> public/bar/index.html
content/bar/hello.md -> public/bar/hello/index.html
It will also add properties to a meta
object of each file:
file.meta.url
file.meta.isHome
file.meta.isIndex
file.meta.sectionUrl
file.meta.section
Finally, it will add an index
property to the passed in site
object which is a tree of all the content.
The above example would look like:
{
name: 'root',
url: '/',
files: [<index.html>, <foo/index.html> ] // All files in this section
sections: [
{
name: 'bar',
url: 'bar',
files: [<bar/index.html>, <bar/foo/index.html>]
}
]
}
As implied above each file has a reference back to it's section in this tree.
It gets more interesting when combined with other pipes. For example:
var ssg = require('gulp-ssg');
var frontmatter = require('gulp-front-matter');
var marked = require('gulp-marked');
var site = {
title: 'My site'
};
gulp.task('html', function() {
return gulp.src('content/**/*.md')
.pipe(frontmatter({
property: 'meta'
}))
.pipe(marked())
.pipe(ssg(site, {
property: 'meta'
}))
.pipe(gulp.dest('public/'));
});
This will extract any YAML front-matter, convert the content of each file from markdown to HTML, then run the ssg. The data extracted from the front-matter will be combined with the data extracted by the ssg in the meta
property.
## Templates
A common requirement of static sites is to pass the content through some template engine. There is nothing built into gulp-ssg
to do this, but it's very easy to add with another pipe.
After the step above you will have created a bunch of HTML files. Now you can run them through a templating pipe. All the files are processed before the next pipe, so the template will have access to the complete site index for things like generating global navigation, or a list of sub-pages in the current section.
So to add this to the above example:
var ssg = require('gulp-ssg');
var frontmatter = require('gulp-front-matter');
var marked = require('gulp-marked');
var fs = require('fs');
var es = require('event-stream');
var mustache = require('mustache');
var site = {
title: 'My site'
};
gulp.task('html', function() {
var template = String(fs.readFileSync('templates/page.html'));
return gulp.src('content/**/*.md')
.pipe(frontmatter({
property: 'meta'
}))
.pipe(marked())
.pipe(ssg(site, {
property: 'meta'
}))
.pipe(es.map(function(file, cb) {
var html = mustache.render(template, {
page: file.meta,
site: site,
content: String(file.contents)
});
file.contents = new Buffer(html);
cb(null, file);
}))
.pipe(gulp.dest('public/'));
});
This uses es.map
to modify the stream directly, but if you have a common way of rendering many sites it might be worth writing a little plug-in with a bit more error handling etc.
string
The base URL of the site, defaults to '/'. This should be the path to where your site will eventually be deployed.
string
A property to sort pages by in the index, defaults to url
. For example, this could be a property like order
extracted from the YAML front-matter, giving content editors full control over the order of pages.
string
The name of the property to attach data to, defaults to meta
.
array
A list of properties to extract from index pages to add to the section, defaults to an empty list. For example, you could add a sectionTitle
to front-matter in your index.md
files, then use this it for link text in your global navigation.
index
(e.g. index.md
) to have the site index fully traversed.FAQs
Generate a static website content tree
The npm package gulp-ssg receives a total of 22 weekly downloads. As such, gulp-ssg popularity was classified as not popular.
We found that gulp-ssg 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.