@benev/turtle
Advanced tools
Comparing version 0.3.5 to 0.3.6
{ | ||
"name": "@benev/turtle", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"description": "static site generator", | ||
@@ -29,3 +29,4 @@ "license": "MIT", | ||
"permissions": "chmod +x x/cli.js", | ||
"start": "http-server x/demo", | ||
"start": "run-p watch http", | ||
"http": "http-server x/demo", | ||
"watch": "tsc -w", | ||
@@ -32,0 +33,0 @@ "watch-test": "chokidar 'x/**/*.js' -c 'npm test'", |
@@ -13,10 +13,10 @@ | ||
destination_path, | ||
web_root_that_contains_template_module, | ||
web_root_for_output, | ||
}: Omit<PathConcepts, "template_path">): PathRoutingFunction { | ||
return (template_meta_url: string) => new PathRouter( | ||
return (import_meta_url: string) => new PathRouter( | ||
new PathDiscovery({ | ||
destination_path, | ||
web_root_that_contains_template_module, | ||
template_path: template_meta_url.slice("file://".length), | ||
web_root_for_output, | ||
template_path: import_meta_url.slice("file://".length), | ||
}) | ||
@@ -31,3 +31,3 @@ ) | ||
root(link: string) { | ||
root(link: string = "") { | ||
return this.#discovery.root(link).url | ||
@@ -34,0 +34,0 @@ } |
@@ -12,4 +12,4 @@ | ||
/** the absolute directory path of the web root that contains the template module (remember that turtle can read multiple different directory trees as sources) */ | ||
web_root_that_contains_template_module: string | ||
/** the absolute directory path of the web root that output is written to */ | ||
web_root_for_output: string | ||
} | ||
@@ -25,4 +25,4 @@ | ||
root(link: string) { | ||
const {template_path, web_root_that_contains_template_module} = this.#concepts | ||
const filepath = normalize(join(web_root_that_contains_template_module, link)) | ||
const {template_path, web_root_for_output} = this.#concepts | ||
const filepath = normalize(join(web_root_for_output, link)) | ||
const url = relative(dirname(template_path), filepath) | ||
@@ -29,0 +29,0 @@ return {url, filepath} |
@@ -42,3 +42,3 @@ | ||
destination_path: final_destination.absolute, | ||
web_root_that_contains_template_module: resolve(path.directory), | ||
web_root_for_output: final_destination.directory, | ||
}), | ||
@@ -45,0 +45,0 @@ } |
@@ -174,4 +174,4 @@ | ||
const path = PathRouter.make_path_routing_function({ | ||
web_root_for_output: "/home/chase/work/@benev/turtle/x/demo", | ||
destination_path: "/home/chase/work/@benev/turtle/x/demo/lol/2.html", | ||
web_root_that_contains_template_module: "/home/chase/work/@benev/turtle/x/demo", | ||
}) | ||
@@ -187,4 +187,4 @@ | ||
const path = PathRouter.make_path_routing_function({ | ||
web_root_for_output: "/home/chase/work/@benev/turtle/x/demo", | ||
destination_path: "/home/chase/work/@benev/turtle/x/demo/lol/2.html", | ||
web_root_that_contains_template_module: "/home/chase/work/@benev/turtle/x/demo", | ||
}) | ||
@@ -197,4 +197,4 @@ expect(path(url).local("style.css")).equals("../stamping/style.css") | ||
const path = PathRouter.make_path_routing_function({ | ||
web_root_for_output: "/home/chase/work/@benev/turtle/x/demo", | ||
destination_path: "/home/chase/work/@benev/turtle/x/demo/lol/2.html", | ||
web_root_that_contains_template_module: "/home/chase/work/@benev/turtle/x/demo", | ||
}) | ||
@@ -201,0 +201,0 @@ expect(path(url).dest("style.css")).equals("style.css") |
@@ -7,7 +7,7 @@ import { PathVersioner } from "./subparts/path_versioner.js"; | ||
readonly version: PathVersioner; | ||
static make_path_routing_function({ destination_path, web_root_that_contains_template_module, }: Omit<PathConcepts, "template_path">): PathRoutingFunction; | ||
static make_path_routing_function({ destination_path, web_root_for_output, }: Omit<PathConcepts, "template_path">): PathRoutingFunction; | ||
constructor(discovery: PathDiscovery); | ||
root(link: string): string; | ||
root(link?: string): string; | ||
local(link: string): string; | ||
dest(link: string): string; | ||
} |
@@ -16,7 +16,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
export class PathRouter { | ||
static make_path_routing_function({ destination_path, web_root_that_contains_template_module, }) { | ||
return (template_meta_url) => new PathRouter(new PathDiscovery({ | ||
static make_path_routing_function({ destination_path, web_root_for_output, }) { | ||
return (import_meta_url) => new PathRouter(new PathDiscovery({ | ||
destination_path, | ||
web_root_that_contains_template_module, | ||
template_path: template_meta_url.slice("file://".length), | ||
web_root_for_output, | ||
template_path: import_meta_url.slice("file://".length), | ||
})); | ||
@@ -29,3 +29,3 @@ } | ||
} | ||
root(link) { | ||
root(link = "") { | ||
return __classPrivateFieldGet(this, _PathRouter_discovery, "f").root(link).url; | ||
@@ -32,0 +32,0 @@ } |
@@ -6,4 +6,4 @@ export type PathConcepts = { | ||
destination_path: string; | ||
/** the absolute directory path of the web root that contains the template module (remember that turtle can read multiple different directory trees as sources) */ | ||
web_root_that_contains_template_module: string; | ||
/** the absolute directory path of the web root that output is written to */ | ||
web_root_for_output: string; | ||
}; | ||
@@ -10,0 +10,0 @@ export declare class PathDiscovery { |
@@ -20,4 +20,4 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
root(link) { | ||
const { template_path, web_root_that_contains_template_module } = __classPrivateFieldGet(this, _PathDiscovery_concepts, "f"); | ||
const filepath = normalize(join(web_root_that_contains_template_module, link)); | ||
const { template_path, web_root_for_output } = __classPrivateFieldGet(this, _PathDiscovery_concepts, "f"); | ||
const filepath = normalize(join(web_root_for_output, link)); | ||
const url = relative(dirname(template_path), filepath); | ||
@@ -24,0 +24,0 @@ return { url, filepath }; |
@@ -18,3 +18,3 @@ import { join, resolve } from "path"; | ||
destination_path: final_destination.absolute, | ||
web_root_that_contains_template_module: resolve(path.directory), | ||
web_root_for_output: final_destination.directory, | ||
}), | ||
@@ -21,0 +21,0 @@ }; |
@@ -151,4 +151,4 @@ import { assert, expect } from "cynic"; | ||
const path = PathRouter.make_path_routing_function({ | ||
web_root_for_output: "/home/chase/work/@benev/turtle/x/demo", | ||
destination_path: "/home/chase/work/@benev/turtle/x/demo/lol/2.html", | ||
web_root_that_contains_template_module: "/home/chase/work/@benev/turtle/x/demo", | ||
}); | ||
@@ -162,4 +162,4 @@ return { | ||
const path = PathRouter.make_path_routing_function({ | ||
web_root_for_output: "/home/chase/work/@benev/turtle/x/demo", | ||
destination_path: "/home/chase/work/@benev/turtle/x/demo/lol/2.html", | ||
web_root_that_contains_template_module: "/home/chase/work/@benev/turtle/x/demo", | ||
}); | ||
@@ -171,4 +171,4 @@ expect(path(url).local("style.css")).equals("../stamping/style.css"); | ||
const path = PathRouter.make_path_routing_function({ | ||
web_root_for_output: "/home/chase/work/@benev/turtle/x/demo", | ||
destination_path: "/home/chase/work/@benev/turtle/x/demo/lol/2.html", | ||
web_root_that_contains_template_module: "/home/chase/work/@benev/turtle/x/demo", | ||
}); | ||
@@ -175,0 +175,0 @@ expect(path(url).dest("style.css")).equals("style.css"); |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
126222