{"id":17336493,"url":"https://github.com/nameoverflow/singlepager","last_synced_at":"2025-07-27T16:08:01.620Z","repository":{"id":90319023,"uuid":"86235306","full_name":"nameoverflow/SinglePager","owner":"nameoverflow","description":null,"archived":false,"fork":false,"pushed_at":"2018-01-19T03:42:25.000Z","size":17,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T21:51:29.593Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/nameoverflow.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":"2017-03-26T13:39:23.000Z","updated_at":"2020-03-09T07:06:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"19876f6c-9286-4517-b715-8e70ff3c68a3","html_url":"https://github.com/nameoverflow/SinglePager","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nameoverflow/SinglePager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nameoverflow%2FSinglePager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nameoverflow%2FSinglePager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nameoverflow%2FSinglePager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nameoverflow%2FSinglePager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nameoverflow","download_url":"https://codeload.github.com/nameoverflow/SinglePager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nameoverflow%2FSinglePager/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267383756,"owners_count":24078571,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-15T15:30:40.121Z","updated_at":"2025-07-27T16:08:01.566Z","avatar_url":"https://github.com/nameoverflow.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SinglePager\r\n\r\nFunctional similar to [InstantClick](https://github.com/dieulot/instantclick/), makes simple static pages dynamic and instant just like a single-page-application. Only change the content of specified container.\r\n\r\nFor use with Hexo, Jekyll, etc.\r\n\r\nReleased in ES2015 without any transformation or polyfill such as Babel.\r\n\r\n## Usage\r\n\r\n### Initialize\r\n\r\nInclude and initialize it.\r\n\r\n```html\r\n...\r\n\u003cdiv data-pager-shell\u003e\r\n  ...\r\n\u003c/div\u003e\r\n...\r\n\r\n\u003cscript src=\"singlepager.js\"\u003e\u003c/script\u003e\r\n\u003cscript\u003e\r\n  var sp = new Pager('data-pager-shell')\r\n\u003c/script\u003e\r\n```\r\n\r\nThe parameter of construct could be an attribute name string, or a configure object.\r\n\r\n```typescript\r\ninterface PagerConfig {\r\n  shellMark?: string,     // The mark attribute to replace content\r\n  disableMark?: string,   // Attribute mark links not be load\r\n  ignoreScript?: string,  // Ignore this `\u003cscript\u003e` tag\r\n  runBefore?: string,     // Run script in the `\u003cscript\u003e` tag before page switch\r\n  triggerTime?: number,   // Not implement\r\n  historyToSave?: number  // Number of histories to save\r\n}\r\n\r\nconst defaultConfig = \u003cPagerConfig\u003e{\r\n  shellMark: 'data-single-pager',\r\n  disableMark: 'data-pager-disabled',\r\n  ignoreScript: 'data-pager-ignore',\r\n  runBefore: 'data-run-before',\r\n  triggerTime: 100,\r\n  historyToSave: 3\r\n}\r\n\r\n```\r\n\r\n### `\u003cscript\u003e` Hook Tag\r\n\r\nWhile `\u003cscript\u003e` tags in container will default run after the page switching, it can be specified to run before or after the page switching.\r\n\r\nRemember that `\u003cscript\u003e` with `data-run-before` (or other name setted in config) would run before the content changes, so do not make references to the target page elements.\r\n\r\n```html\r\n\u003cdiv data-pager-shell\u003e\r\n  ...\r\n  \u003cdiv id=\"tag\"\u003e\u003c/div\u003e\r\n  \u003cscript\u003e\r\n    document.getElementById('tag').innerHTML += '\u003cp\u003eRun after mount\u003c/p\u003e'\r\n  \u003c/script\u003e\r\n  \u003cscript data-run-before\u003e\r\n    // Error!\r\n    // document.getElementById('tag').innerHTML += '\u003cp\u003eRun before mount\u003c/p\u003e'\r\n    alert('Run before mount')\r\n  \u003c/script\u003e\r\n  \u003cscript data-pager-disabled\u003e\r\n    alert('Do not run this')\r\n  \u003c/script\u003e\r\n\u003c/div\u003e\r\n\r\n```\r\n\r\n## Build\r\n\r\nRun `make` to dist, `make comile` to compile typescript (ts 2.2.1+ required)\r\n\r\n## Test\r\n\r\nPython 3.4+ required\r\n\r\nRun `python -m http.server` then open `http://127.0.0.1:8000/test/test.html`\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnameoverflow%2Fsinglepager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnameoverflow%2Fsinglepager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnameoverflow%2Fsinglepager/lists"}