
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
a very experimental static site generator overlay on top of Sapper. For a simple demo see this:
a very experimental static site generator overlay on top of Sapper. For a simple demo see this:
https://www.youtube.com/watch?v=o_o0PAts9Gg&feature=youtu.be
yarn add sapper svelte ssg
src/routes/data/[slug].json.js
file in your main Sapper project, that looks like this:const { getData } = require('../../../ssg.config')
export async function get(req, res) {
const { slug } = req.params
const splitSlug = slug.split('___ssg___')
const category = splitSlug[0]
const realSlug = splitSlug[1]
const data = await getData(category, realSlug)
if (data) {
res.writeHead(200, { 'Content-Type': 'application/json' })
res.end(JSON.stringify(data))
} else {
res.writeHead(404, { 'Content-Type': 'application/json' })
res.end(JSON.stringify({ message: `Not found` }))
}
}
ssg.config.js
that exports a getInitialData
(run once) and getData
(run each time) function that provides this data:exports.getData = async (category, slug) => {
// read cache and
// do less expensive subsequent fetches
const data = require(path.resolve('.ssg/data.json'))
const result = data[category][slug]
if (typeof result === 'undefined') throw new Error('no data found for ' + slug)
return result
}
exports.getInitialData = async () => {
// do expensive initial fetches and cache them in .ssg/data.json
return {
index: [{ title: 'foo', slug: 'foo' }, { title: 'bar', slug: 'bar' }],
foo: { title: 'foo', html: '<div> the foo post </div>' },
bar: { title: 'bar', html: '<div> the bar post </div>' },
}
}
In your templates, you may now query this data at any time:
<!-- src/routes/talks/[slug].svelte -->
<script context="module">
export async function preload({ params, query }) {
const res = await this.fetch(`data/talks___ssg___${params.slug}.json`)
const data = await res.json()
if (res.status === 200) {
return { post: data }
} else {
this.error(res.status, data.message)
}
}
</script>
Under the hood, ssg
runs sapper dev
for you, and watches and reloads it whenever you change your config or contents folder.
It runs getInitialData
once and saves that result to a cache, and then you can run getData
anytime you want to query that cache.
FAQs
a very experimental static site generator overlay on top of Sapper.
We found that 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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
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.