{"id":17871229,"url":"https://github.com/stulzq/hexo-statistics","last_synced_at":"2025-08-14T18:32:10.167Z","repository":{"id":41743157,"uuid":"510217094","full_name":"stulzq/hexo-statistics","owner":"stulzq","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-08T03:43:52.000Z","size":927,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-28T11:38:36.937Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stulzq.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":"2022-07-04T04:55:42.000Z","updated_at":"2024-08-25T22:47:34.000Z","dependencies_parsed_at":"2022-09-26T21:21:28.894Z","dependency_job_id":null,"html_url":"https://github.com/stulzq/hexo-statistics","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stulzq%2Fhexo-statistics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stulzq%2Fhexo-statistics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stulzq%2Fhexo-statistics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stulzq%2Fhexo-statistics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stulzq","download_url":"https://codeload.github.com/stulzq/hexo-statistics/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229854836,"owners_count":18134831,"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-28T10:27:41.501Z","updated_at":"2024-12-15T17:42:11.766Z","avatar_url":"https://github.com/stulzq.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hexo Statistics\n\nEnglish|[中文](README_zh-CN.md)\n\nHexo blog traffic statistics service, based on redis. Use hyperloglog to count UV.\n\nDemo: https://xcmaster.com/\n\nArticle pv:\n\n![](img/page_pv.png)\n\nSite uv and pv:\n\n![](img/site_uv.png)\n\n\n## Get Start\n\n### Step\n\n- 1.Install redis and run in standalone mode\n- 2.Run hexo-statistics\n- 3.Configure your hexo template\n\n### Install Redis\n\nUbuntu: `apt-get install redis-server`\n\n#### Docker\n\n````shell\nmkdir -p /data/redis\n\ndocker run -p 6379:6379 \\\n  -v /data/redis/conf/redis.conf:/etc/redis/redis.conf \\\n  -v /data/redis/data:/data \\\n  --name hexo-stat-redis \\\n  -d redis:5.0 redis-server /etc/redis/redis.conf\n````\n\n### Run hexo-statistics\n\n#### Binary\n\n````shell\n\nexport hexo_version=v0.5.7\n\nwget https://github.com/stulzq/hexo-statistics/releases/download/$hexo_version/hexo-statistics-$hexo_version-linux-amd64.tar.gz\n\ntar -xzvf hexo-statistics-$hexo_version_linux_amd64.tar.gz\n\ncd hexo-statistics-$hexo_version_linux_amd64\n\n# update your config on conf/config.yml\n\nchmod +x hexo_statistics\n./hexo-statistics\n\n````\n\n#### Docker\n\n````shell\nmkdir -p /data/hexo-stat/conf\n\ncurl https://raw.githubusercontent.com/stulzq/hexo-statistics/main/conf/config.yml -o /data/hexo-stat/config.yml\n\n# update your config /data/hexo-stat/config.yml\n\ndocker run --name hexo-stat \\\n  -v /data/hexo-stat/conf:/app/conf \\\n  -v /data/hexo-stat/logs:/app/logs \\\n  -d stulzq/hexo-statistics:v0.1.0\n\n````\n\n### Configure template\n\nSave file to \u003cblog_root\u003e/source/js/hexo-stat.js\n\n````javascript\n\"use strict\";\n(function() {\n    var serverDomain = \"\u003cyou_statistics_domain\u003e\"\n    var apiPrefix=\"\" // eg: /api\n\n    function hexoGetData() {\n        $.ajax({\n            url: serverDomain+ apiPrefix +\"/stat/get?u=\" +encodeURIComponent(window.location.href),\n            type: \"GET\",\n            dataType: \"json\",\n            success: function (resp) {\n                hexoProcessResult(resp)\n                hexoCounter()\n            },\n        });\n    }\n\n    function hexoCounter(){\n        var hm = document.createElement(\"script\");\n        hm.src = serverDomain + apiPrefix +\"/stat/counter?u=\" + encodeURIComponent(window.location.href);\n        var s = document.getElementsByTagName(\"script\")[0];\n        s.parentNode.insertBefore(hm, s);\n    }\n\n    function hexoProcessResult(data) {\n        // set result\n        // site pv -\u003e data.sitePv\n        // site uv -\u003e data.siteUv\n        // page pv -\u003e data.pagePv\n\n        // example:\n        $(\".statistics\").append(`\u003cspan id=\"hexo_statistics_container_site_pv\" style=\"display: inline;\"\u003e总访问量 \u003cspan id=\"hexo_statistics_value_site_pv\"\u003e${data.sitePv}\u003c/span\u003e 次\u003c/span\u003e`);\n        $(\".statistics\").append(`\u003cspan id=\"hexo_statistics_container_site_uv\" style=\"display: inline;\"\u003e总访客数 \u003cspan id=\"hexo_statistics_value_site_uv\"\u003e${data.siteUv}\u003c/span\u003e 人\u003c/span\u003e`);\n        $(\"div .mt-1\").append(\n            `\u003cspan id=\"hexo_statistics_container_page_pv\" style=\"display: inline;\"\u003e\u003ci class=\"iconfont icon-eye\" aria-hidden=\"true\"\u003e\u003c/i\u003e \u003cspan id=\"hexo_statistics_value_page_pv\"\u003e${data.pagePv+1}\u003c/span\u003e 次\u003c/span\u003e`\n        );\n    }\n\n\n    hexoGetData();\n})();\n\n````\n\nInject js file:\n\n\u003efile in blog_root/scripts/inject.js\n\n````javascript\nhexo.extend.injector.register('body_end', '\u003cscript src=\"/js/hexo-stat.js\"\u003e\u003c/script\u003e', 'default');\n````\n\n## TODO\n\n- Data Export\n- Data Import\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstulzq%2Fhexo-statistics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstulzq%2Fhexo-statistics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstulzq%2Fhexo-statistics/lists"}