Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@benev/turtle

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@benev/turtle - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

6

package.json
{
"name": "@benev/turtle",
"version": "0.1.1",
"version": "0.1.2",
"description": "static site generator",

@@ -28,3 +28,3 @@ "license": "MIT",

"@types/shelljs": "^0.8.12",
"glob": "^10.2.4",
"glob": "^10.2.6",
"globby": "^13.1.3",

@@ -34,3 +34,3 @@ "shelljs": "^0.8.5"

"devDependencies": {
"@types/node": "^20.1.7",
"@types/node": "^20.2.3",
"cynic": "^0.2.1",

@@ -37,0 +37,0 @@ "http-server": "^14.1.1",

@@ -11,2 +11,3 @@

- turtle also copies other files like css and whatnot
- turtle has proper typescript typings

@@ -17,2 +18,4 @@ <br/>

note, turtle doesn't care whether you use typescript or plain javascript, but in the examples here i'll be using the two interchangeably.
<br/>

@@ -33,3 +36,3 @@

```sh
npx @benev/turtle +help
npx @benev/turtle --help
```

@@ -43,2 +46,4 @@

turtle will sniff out your `.html.js` files, and render them into html pages.
```js

@@ -63,2 +68,75 @@ import {webpage, html} from "@benev/turtle"

### you can write template partials
it can accept a context object
you tell turtle to ignore it with `--exclude="**/*.partial.html.js"`
`page.partial.html.ts`
```ts
import {webpage, html} from "@benev/turtle"
export default webpage<{x: number}>(async({v}, {x}) => html`
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>@benev/turtle - stamp test</title>
<link rel="stylesheet" href="${v("/style.css")}"/>
</head>
<body>
<h1>@benev/turtle - stamp test</h1>
<p>${x}</p>
</body>
</html>
`)
```
<br/>
### write your first turtle script, like `stamp.turtle.js`
turtle also sniffs out `.turtle.js` scripts and executes them.
in these, you can do anything you want. your turtle script function is provided some handy stuff like the `write_webpage` function.
`stamp.turtle.ts`
```ts
import {turtle_script} from "@benev/turtle"
// import the partial from the previous example
import page from "./page.partial.html.js"
// we'll stamp out a webpage for each of these values
const values = [1, 2]
// your default export must be a turtle_script
export default turtle_script(async({write_webpage}) => {
// loop over each value
await Promise.all(values.map(async(x) => {
// write a webpage
await write_webpage({
// provide the page template
template: page,
// provide the x value in the context
context: {x},
// specify the destination relative
// to this build script
destination: `${x}.html`,
})
}))
})
```
<br/>
### you've gotta get into *hash versioning!*

@@ -65,0 +143,0 @@ - that's what the above example is doing with that `v` function

@@ -26,3 +26,4 @@ #!/usr/bin/env node

static site generator.
consumes .html.js template files.
renders .html.js template files into html.
executes .turtle.js script files.
copies all other files.

@@ -29,0 +30,0 @@ `.trim(),

@@ -6,9 +6,22 @@

// we'll stamp out a webpage for each of these values
const values = [1, 2]
// your default export must be a turtle_script
export default turtle_script(async({write_webpage}) => {
// loop over each value
await Promise.all(values.map(async(x) => {
// write a webpage
await write_webpage({
// provide the page template
template: page,
// provide the x value in the context
context: {x},
// specify the destination relative
// to this build script
destination: `${x}.html`,

@@ -15,0 +28,0 @@ })

@@ -13,3 +13,4 @@ #!/usr/bin/env node

static site generator.
consumes .html.js template files.
renders .html.js template files into html.
executes .turtle.js script files.
copies all other files.

@@ -16,0 +17,0 @@ `.trim(),

import { turtle_script } from "../../build/turtle_script.js";
import page from "./page.partial.html.js";
// we'll stamp out a webpage for each of these values
const values = [1, 2];
// your default export must be a turtle_script
export default turtle_script(async ({ write_webpage }) => {
// loop over each value
await Promise.all(values.map(async (x) => {
// write a webpage
await write_webpage({
// provide the page template
template: page,
// provide the x value in the context
context: { x },
// specify the destination relative
// to this build script
destination: `${x}.html`,

@@ -10,0 +18,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc