{"id":17223426,"url":"https://github.com/conduitry/story","last_synced_at":"2025-03-25T16:23:38.722Z","repository":{"id":163440913,"uuid":"76906511","full_name":"Conduitry/story","owner":"Conduitry","description":"Minimal HTML5 history API wrapper // Mirror of https://git.chor.date/Conduitry/story","archived":false,"fork":false,"pushed_at":"2017-03-15T20:55:05.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-30T14:28:21.334Z","etag":null,"topics":["html5-history-api","javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Conduitry.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":"2016-12-19T23:48:21.000Z","updated_at":"2018-10-11T12:05:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"cb9011e4-0d32-4142-a5b2-7d41f747a9ac","html_url":"https://github.com/Conduitry/story","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/Conduitry%2Fstory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Conduitry%2Fstory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Conduitry%2Fstory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Conduitry%2Fstory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Conduitry","download_url":"https://codeload.github.com/Conduitry/story/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245497229,"owners_count":20624971,"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":["html5-history-api","javascript"],"created_at":"2024-10-15T04:08:17.244Z","updated_at":"2025-03-25T16:23:38.678Z","avatar_url":"https://github.com/Conduitry.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# story\nMinimal HTML5 history API wrapper\n\n## About\nThe purpose of this library was to create a very thin wrapper around the HTML5 history API, but still one that handles the basic everyday tasks. It started as a bit of shared code that I found myself using on a couple of personal projects, so I decided to publish it here.\n\nIt handles programmatically switching to a URL or replacing a URL, informing your code when the URL changes, and intercepting clicks on hyperlinks to call the history API instead of performing page navigation.\n\n## What it is not\nIt is not an actual router. You provide a function, this library calls your function when the URL changes. That's it.\n\n## How to use\nThis is an ES2015 module. You will need some way to bundle and transpile this for your app.\n\n## Methods available\n\n### `setBase(base)`\nSet a new value for the base path. Defaults to `\"/\"`. This should be the root path of your app.\n\n### `watch(cb)`\nRegister a new callback to be informed whenever the path changes. Your callback will be called with one argument, the portion of the path after the currently specified base.\n\n### `unwatch(cb)`\nUnregisters a previously registered watcher.\n\n### `to(url)`\nPerform (virtual) navigation to the new URL. `url` will be appended to the current base.\n\nAlso calls any currently registered watchers.\n\n### `replace(url)`\nReplace the current URL with the new one you specify. `url` will be appended to the current base. Call this when you want to, for example, perform a redirect without creating a new entry in the navigation history.\n\nAlso calls any currently registered watchers.\n\n## Hyperlink handling\nActivating hyperlinks will be replaced with a call to `to()` provided that:\n* the control/meta/shift keys were not pressed during the click, and the click was not done with the middle mouse button\n* the hyperlink element has no `target` value\n* the hyperlink's `href` begins with the currently selected base - defaults to `\"/\"` and can be changed with `setBase()`\n\nIf you have a hyperlink that would otherwise be caught by the click handler and you do not want it to be, you can specify `target=\"_self\"` on the link element.\n\n## License\nThis code was written by Conduitry and is released into the public domain.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconduitry%2Fstory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconduitry%2Fstory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconduitry%2Fstory/lists"}