{"id":23276736,"url":"https://github.com/shoriwe/static","last_synced_at":"2025-04-06T11:47:03.740Z","repository":{"id":46563301,"uuid":"410935485","full_name":"shoriwe/static","owner":"shoriwe","description":"A simple static frontend generator library in Go.","archived":false,"fork":false,"pushed_at":"2022-05-28T03:52:39.000Z","size":1471,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-12T17:33:10.680Z","etag":null,"topics":["go","static","website"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shoriwe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-27T15:15:17.000Z","updated_at":"2021-10-25T22:00:16.000Z","dependencies_parsed_at":"2022-09-04T18:53:57.468Z","dependency_job_id":null,"html_url":"https://github.com/shoriwe/static","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shoriwe%2Fstatic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shoriwe%2Fstatic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shoriwe%2Fstatic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shoriwe%2Fstatic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shoriwe","download_url":"https://codeload.github.com/shoriwe/static/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478295,"owners_count":20945264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","static","website"],"created_at":"2024-12-19T21:36:38.718Z","updated_at":"2025-04-06T11:47:03.718Z","avatar_url":"https://github.com/shoriwe.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# static\n\nA simple static frontend generator library.\n\n## Examples\n\n- [https://shoriwe.github.io/plasma/index.html](https://shoriwe.github.io/plasma/index.html)\n\n## Features\n\n- Go to JavaScript (**Powered by [GopherJS](https://github.com/gopherjs/gopherjs)**)\n- Go to WASM (**Powered by the standard library**)\n- Templating system\n- Templating scripting (**Powered by [gplasma](https://github.com/shoriwe/gplasma)**)\n\n## Important\n\nIf you are on **Windows** use the WSL to compile your project. This happens cause **GopherJS** still does not support\nthis platform.\n\n## Quicklook\n\nFor this example we will virtually store our scripts in the root of our project, in a folder called `scripts`. Something\nsimilar with the assets and templates.\n\n`my-project/main.go`\n\n```go\npackage main\n\nimport (\n\t\"github.com/shoriwe/static/pkg/engine\"\n)\n\nfunc main() {\n\tvar (\n\t\ttemplates engine.Templates\n\t\tscripts   engine.Scripts\n\t\tassets    engine.Assets\n\t\tloadError error\n\t)\n\ttemplates, loadError = engine.LoadTemplates(\"./templates\")\n\tif loadError != nil {\n\t\tpanic(loadError)\n\t}\n\tscripts, loadError = engine.LoadScripts(\n\t\t\"./scripts\", // This is the directory where the `Go` to then `JavaScript` scripts will be located\n\t\t\"js\",        // When the project start to be generated, the compiled JavaScript will be stored in this folder relative to the output one\n\t)\n\tif loadError != nil {\n\t\tpanic(loadError)\n\t}\n\tassets, loadError = engine.LoadAssets(\n\t\t\"./assets\", // This is the directory where all static assets will be searched for\n\t\t\"static\",   // This is the directory where all assets will be stored once the project is generated.\n\t)\n\tif loadError != nil {\n\t\tpanic(loadError)\n\t}\n\tmyProjectEngine := engine.NewEngine(\n\t\ttemplates,\n\t\tscripts,\n\t\tassets,\n\t)\n\thandlingError := myProjectEngine.HandlePath(\"/index.html\", // Define a new path to generate\n\t\tfunc(e *engine.Engine) ([]byte, error) {\n\t\t\tscriptUrl, getError := e.ScriptURL(\"hello-world\")\n\t\t\tif getError != nil {\n\t\t\t\treturn nil, getError\n\t\t\t}\n\t\t\trenderedTemplate, renderError := e.RenderTemplate(\n\t\t\t\t\"index.html\", // Search for the index.html templates in the specified templates directory\n\t\t\t\tmap[string]string{\n\t\t\t\t\t\"url\": scriptUrl,\n\t\t\t\t},\n\t\t\t)\n\t\t\tif renderError != nil {\n\t\t\t\treturn nil, renderError\n\t\t\t}\n\t\t\treturn e.MinifyHTML(renderedTemplate)\n\t\t},\n\t)\n\tif handlingError != nil { // These throws and error when the path was already in use\n\t\tpanic(handlingError)\n\t}\n\tgenerationError := myProjectEngine.Generate(\"output/sample-1\") // Create the path \"output/sample-1\" and write to it all assets, scripts and defined paths\n\tif generationError != nil {\n\t\tpanic(generationError)\n\t}\n}\n```\n\nFinally, to generate the page simply execute in the root of your project\n\n```shell\ngo run\n```\n\n## Documentation\n\nYou can find the documentation on the wiki section.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshoriwe%2Fstatic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshoriwe%2Fstatic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshoriwe%2Fstatic/lists"}