{"id":16398818,"url":"https://github.com/sauldoescode/tinyrouter","last_synced_at":"2025-06-16T07:07:33.370Z","repository":{"id":71027897,"uuid":"44627134","full_name":"SaulDoesCode/TinyRouter","owner":"SaulDoesCode","description":"Tiny Front End Router for use in any modern website","archived":false,"fork":false,"pushed_at":"2016-12-24T18:47:05.000Z","size":5,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T09:43:28.960Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/SaulDoesCode.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-20T18:37:45.000Z","updated_at":"2023-08-02T02:15:05.000Z","dependencies_parsed_at":"2023-05-22T17:45:50.236Z","dependency_job_id":null,"html_url":"https://github.com/SaulDoesCode/TinyRouter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SaulDoesCode/TinyRouter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaulDoesCode%2FTinyRouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaulDoesCode%2FTinyRouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaulDoesCode%2FTinyRouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaulDoesCode%2FTinyRouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SaulDoesCode","download_url":"https://codeload.github.com/SaulDoesCode/TinyRouter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaulDoesCode%2FTinyRouter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260116643,"owners_count":22961064,"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":[],"created_at":"2024-10-11T05:14:00.666Z","updated_at":"2025-06-16T07:07:33.343Z","avatar_url":"https://github.com/SaulDoesCode.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TinyRouter\nTiny Front End Router for use in any modern website\n\n\n#### Quick Use\n\n##### How Handle a URL hash   \n\n  ``` javascript\n    router.handle(\"#anyHashOrLink\", () =\u003e {   \n         // do something when that hash/link has been called   \n    });   \n  ```    \n  \n##### set the Document Title \n\n``` javascript\n    router.setTitle(\"My Awesome Website Title\");\n```\n\n##### Open a link \n\n``` javascript   \n  // router.open( _link_ , _optional-boolean-for-newtab_);\n  \n  // Opens the link in the same window\n  router.open(\"/awesome-link\");\n \n  // Opens the link in a new tab\n  router.open(\"http://www.some-other-site.meh\",true); // notice the second parameter is just true, this opens the link in a new tab \n  // \n```\n##### Make an Element a click-able link\n\nSome arbitrary HTML\n``` html\n  \u003cbutton id=\"myfancybutton\"\u003e Fancy Link \u003c/button\u003e\n```\nthen in your JavaScript file \n``` javascript   \n  // Any CSS selector will work \n  router.makeLink(\"#myfancybutton\",\"www.fancylink.com\"); // This will change the window location on click of the element\n  \n  // Make link open in new tab -  add in true as the second parameter \n  router.makeLink(\"#myfancybutton\",\"www.fancylink.com\" , true );\n  \n  // What if it should open on a different event type ? - add in a third parameter with the desired event type\n  // any of the usual addEventListener types should work\n  router.makeLink(\"#myfancybutton\",\"www.fancylink.com\" , true , \"dblclick\");\n\n```\n\nAlternative Way of making an element a click-able link , simply add a ` link=\"URL\" ` attribute to the element   \nhere's an example   \n   \n``` html\n  \u003cdiv class=\"fancy-nav-item\"  link=\"/home\" \u003e Fancy Navigation Link \u003c/div\u003e\n```\n\n\n##### Set a View On an Element\nSome Site HTML\n``` html\n  \u003cmain class=\"important-content\"\u003e\n    \u003c!-- Some Content the user should see when the route changes --\u003e\n  \u003c/main\u003e\n```\n Your JavaScript  \n``` javascript   \n    var NewsView = `\n      \u003cdiv class=\"news-article\"\u003e\n        \u003ch2\u003e This Just In New Tiny Router Micro toolkit rocks the crowd \u003c/h2\u003e\n        \u003cp\u003e Lorem Ipsum ... \u003c/p\u003e\n      \u003c/div\u003e\n    `;\n    \n    router.handle(\"#news\", () =\u003e {   \n         // select the element to recieve the view with a CSS selector\n         router.setView('.important-content',NewsView); // This will set the contents of the element to NewsView  \n    }); \n    \n    // or Fetch the View from a URL   \n    \n    router.handle(\"#news\", () =\u003e {   \n         // select the element to recieve the view with a CSS selector\n         router.fetchView('.important-content',\"/news-service\");   \n         // This will set the contents of the element to the response of the url    \n    }); \n    \n    //also optional caching available for the router.fetchView function   \n    \n    router.fetchView('.important-content',\"/news-service\", true /* set cache to true  */ , \"identifier\");    \n    /* cache identifier (can be anything) */\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsauldoescode%2Ftinyrouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsauldoescode%2Ftinyrouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsauldoescode%2Ftinyrouter/lists"}