{"id":16973729,"url":"https://github.com/prinsss/hexo-hide-posts","last_synced_at":"2025-10-27T05:02:05.635Z","repository":{"id":46122137,"uuid":"156699026","full_name":"prinsss/hexo-hide-posts","owner":"prinsss","description":"A plugin to hide specific posts from your Hexo blog and make them only accessible by links. (隐藏 Hexo 文章)","archived":false,"fork":false,"pushed_at":"2024-07-18T14:10:50.000Z","size":263,"stargazers_count":202,"open_issues_count":3,"forks_count":17,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T07:06:44.273Z","etag":null,"topics":["hexo","hexo-plugin","hide","unlisted"],"latest_commit_sha":null,"homepage":"","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/prinsss.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":"2018-11-08T11:49:12.000Z","updated_at":"2025-03-09T12:43:20.000Z","dependencies_parsed_at":"2024-02-20T09:45:22.928Z","dependency_job_id":"fee8a62a-9e2f-4b7e-ab4a-b699cb06779a","html_url":"https://github.com/prinsss/hexo-hide-posts","commit_stats":{"total_commits":44,"total_committers":4,"mean_commits":11.0,"dds":0.2727272727272727,"last_synced_commit":"6146769cd7fd7e2de90bfa37e82e55a54540e097"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prinsss%2Fhexo-hide-posts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prinsss%2Fhexo-hide-posts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prinsss%2Fhexo-hide-posts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prinsss%2Fhexo-hide-posts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prinsss","download_url":"https://codeload.github.com/prinsss/hexo-hide-posts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305934,"owners_count":20917208,"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":["hexo","hexo-plugin","hide","unlisted"],"created_at":"2024-10-14T01:03:21.792Z","updated_at":"2025-10-27T05:02:05.552Z","avatar_url":"https://github.com/prinsss.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hexo-hide-posts\n\n[![npm-version](https://img.shields.io/npm/v/hexo-hide-posts.svg)](https://www.npmjs.com/package/hexo-hide-posts)\n[![hexo-version](https://img.shields.io/badge/hexo-%3E=4.0.0-blue?logo=hexo)](https://hexo.io)\n\n[**中文文档**](https://github.com/printempw/hexo-hide-posts/blob/master/README_ZH.md)\n\nA plugin to hide specific posts from your Hexo blog and make them only accessible by links.\n\n**Hide** means your posts will not come up in article lists (homepage, archive, category, tag, feed, sitemap, whatever), or search results either (by telling search engines not to index these pages with a \"noindex\" meta tag). Only those who know the link can view the post, and you can share the link with anyone.\n\nThis means that posts marked as hidden could still be seen by anyone, but only if they guess the link.\n\n## Installation\n\n``` bash\nnpm install hexo-hide-posts\n```\n\n## Usage\n\nAdd `hidden: true` to the [front-matter](https://hexo.io/docs/front-matter) of posts which you want to hide.\n\ne.g. Edit `source/_posts/lorem-ipsum.md`:\n\n```text\n---\ntitle: 'Lorem Ipsum'\ndate: '2019/8/10 11:45:14'\nhidden: true\n---\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit.\n```\n\nThis post will not be shown anywhere, but you can still access it by `https://hexo.test/lorem-ipsum/`. (If you want to completely prevent a post from rendering, just set it as a [draft](https://hexo.io/docs/writing.html#Drafts).)\n\nTo get a list of hidden posts, you can run `hexo hidden:list` from command line.\n\nFor developers, `all_posts` and `hidden_posts` added to [Local Variables](https://hexo.io/api/locals) may be useful.\n\n## Config\n\nIn your site's `_config.yml`:\n\n```yml\nhide_posts:\n  # Should hexo-hide-posts be enabled.\n  enable: true\n\n  # The front-matter key for flagging hidden posts.\n  # You can change the filter name if you like.\n  filter: hidden\n\n  # Add \"noindex\" meta tag to prevent hidden posts from being indexed by search engines.\n  noindex: true\n\n  # Generators in the allowlist will have access to the hidden posts.\n  # Common generators in Hexo: 'index', 'tag', 'category', 'archive', 'sitemap', 'feed'\n  # allowlist_generators: []\n\n  # Generators in the blocklist can *not* access the hidden posts.\n  # The allowlist has higher priority than the blocklist, if both set.\n  # blocklist_generators: ['*']\n```\n\ne.g. Set filter to `secret`, so you can use `secret: true` in front-matter instead.\n\n## Advanced Config\n\nFor power users, they can have a more fine-grained control on access to hidden posts by configuring blocklist and allowlist. This feature is available in version 0.3.0 or later.\n\n**Config Example 1**: Hide the flagged posts everywhere, but make them visible on archives page and sitemap.\n\n```yml\nhide_posts:\n  enable: true\n  # This property was previously called `public_generators` prior to v0.2.0, and was renamed in newer version.\n  allowlist_generators: ['archive', 'sitemap']\n```\n\n**Config Example 2**: Hide the flagged posts only on homepage and RSS, and show them elsewhere.\n\n```yml\nhide_posts:\n  enable: true\n  # For advanced usage of allowlist/blocklist, check `lib/isGeneratorAllowed.test.js` for more test cases.\n  allowlist_generators: ['*']\n  blocklist_generators: ['index', 'feed']\n```\n\n**Note:** although most of generator plugins respect a naming convention that they register\ngenerator with the name in their package names, the generator name could be arbitrary.\nFor example, [`hexo-generator-searchdb`](https://github.com/next-theme/hexo-generator-searchdb) does not register\ngenerators with name `searchdb`, but `xml` and `json`.\nFor accurate generator name, you should check their source code.\n\n\u003e Tips: Run `hexo g --debug` command will show you all the generators installed with their names in the debug log.\n\n**Config Example 3**: Pass a custom JavaScript function to determine which generator should be allowlisted.\n\nThis could be done by adding a [plugin script](https://hexo.io/docs/plugins) to your Hexo blog.\n\n```js\n// FILE: scripts/allowlist.js (filename does not matter, you name it)\n\nhexo.config.hide_posts.allowlist_function = function (name) {\n  return /archive|feed/.test(name);\n}\n```\n\n## Custom ACL Function\n\nFor even more fine-grained control over which posts should be visible in which place, meet the most powerful feature of the plugin: **Custom ACL (Access Control List) Function**.\n\nIn version 0.4.0 and later, a custom JavaScript function could be configured to determine wether a generator could access a post or not, giving you the full control and inspection. The function accepts two arguments, the `post` object and the current `generatorName`. The global variable `hexo` is also available in the context.\n\nHere is an example. Use with caution!\n\n```js\n// FILE: scripts/acl.js\nconst isGeneratorAllowed = require('hexo-hide-posts/lib/isGeneratorAllowed');\n\n// Advanced usage: ACL (Access Control List) per post.\n// The most powerful way to control which posts should be included in which generator.\n// Return `true` to allow and `false` to block access. It's all up to you.\nhexo.config.hide_posts.acl_function_per_post = function (post, generatorName) {\n  // Mark the post with front-matter `acl: xxx` so we can recognize it here.\n  // For the full definition of `post` and all available properties,\n  // see: https://github.com/hexojs/hexo/blob/master/lib/models/post.js\n  // console.log(post, post.slug, post.acl, post.tags, post.categories)\n\n  // Posts marked as \"no-rss\" will not be included in the feed and sitemap\n  if (post.acl === 'no-rss') {\n    return generatorName !== 'atom' \u0026\u0026 generatorName !== 'sitemap';\n  }\n\n  // Posts marked as \"archive-only\" will only be included in the archive\n  if (post.acl === 'archive-only') {\n    return generatorName === 'archive';\n  }\n\n  // You can also filter posts with tags and categories\n  // All posts in category \"news\" will NOT be hidden\n  // if (post.tags.find({ name: 'news' }).length) {}\n  if (post.categories.find({ name: 'news' }).length) {\n    return true;\n  }\n\n  // Or even the creation date!\n  // All posts created before 2020 will be hidden\n  if (post.date.year() \u003c 2020) {\n    return false;\n  }\n\n  // For the rest of posts, apply the default rule (allowlist \u0026 blocklist)\n  return isGeneratorAllowed(hexo.config.hide_posts, generatorName);\n}\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprinsss%2Fhexo-hide-posts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprinsss%2Fhexo-hide-posts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprinsss%2Fhexo-hide-posts/lists"}