{"_id":"@alterjs/saber-plugin-query-posts","_rev":"1-95cb0251ff5ac67010bf7cd20d729402","name":"@alterjs/saber-plugin-query-posts","dist-tags":{"latest":"0.13.0"},"versions":{"0.12.2":{"name":"@alterjs/saber-plugin-query-posts","version":"0.12.2","license":"MIT","_id":"@alterjs/saber-plugin-query-posts@0.12.2","maintainers":[{"name":"chawyehsu","email":"su+npm@chawyehsu.com"}],"homepage":"https://github.com/chawyehsu/saber#readme","bugs":{"url":"https://github.com/chawyehsu/saber/issues"},"dist":{"shasum":"6f3ec837bd99b20debd9cdccf8428f855fb95a1f","tarball":"https://registry.npmjs.org/@alterjs/saber-plugin-query-posts/-/saber-plugin-query-posts-0.12.2.tgz","fileCount":5,"integrity":"sha512-zVS8s64SboRSxj+JH3N44ITAlJ4nhdEAFrhIrFLfe+c8W1nXNYm3kKpT7J3buvZkKMe6vNXvE6R/6GZe6EEyxQ==","signatures":[{"sig":"MEQCIBR7G8YvoHHwLDIE4K709HQCJT2BaDn3yp/clW8yflDqAiAHzFf/FkpEjD+YUx43BffC65M7GkZ5nJuBb01y/HyyJQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14765},"main":"./dist/index.min.cjs","module":"./dist/index.min.mjs","exports":{".":{"import":"./dist/index.min.mjs","require":"./dist/index.min.cjs"}},"gitHead":"3cee52f698379a4c669de07556ef9beb401a326a","scripts":{"lint":"eslint src","build":"rimraf dist && rollup -c","build:example":"saber build example","prepublishOnly":"npm run build"},"_npmUser":{"name":"chawyehsu","email":"su+npm@chawyehsu.com"},"repository":{"url":"git+https://github.com/chawyehsu/saber.git","type":"git"},"_npmVersion":"10.7.0","description":"Query posts plugin for Saber app","directories":{},"_nodeVersion":"18.20.4","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"rollup":"^4.24.0","url-join":"^5.0.0","@rollup/plugin-json":"^6.1.0","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-commonjs":"^28.0.1","@rollup/plugin-node-resolve":"^15.3.0"},"peerDependencies":{"@alterjs/saber":">=0.12.2"},"_npmOperationalInternal":{"tmp":"tmp/saber-plugin-query-posts_0.12.2_1729089253612_0.24707856100634862","host":"s3://npm-registry-packages"}},"0.13.0":{"name":"@alterjs/saber-plugin-query-posts","version":"0.13.0","description":"Query posts plugin for Saber app","license":"MIT","repository":{"type":"git","url":"git+https://github.com/chawyehsu/saber.git"},"exports":{".":{"import":"./dist/index.min.mjs","require":"./dist/index.min.cjs"}},"main":"./dist/index.min.cjs","module":"./dist/index.min.mjs","scripts":{"build":"rimraf dist && rollup -c","build:example":"saber build example","lint":"eslint src","prepublishOnly":"npm run build"},"peerDependencies":{"@alterjs/saber":"^0.13.0"},"devDependencies":{"url-join":"^5.0.0"},"publishConfig":{"access":"public"},"_id":"@alterjs/saber-plugin-query-posts@0.13.0","gitHead":"df690b0df6c45372cb41b7fa42003f08edc08bf5","bugs":{"url":"https://github.com/chawyehsu/saber/issues"},"homepage":"https://github.com/chawyehsu/saber#readme","_nodeVersion":"18.20.4","_npmVersion":"10.7.0","dist":{"integrity":"sha512-Mkb6zHdjCeNSULJKFJRCjWP48l98UFRpAQyheZDgJ1QjmnJ2UskeO3Ea3xk9n7Podpssw94w8QOm3Zosv5sikQ==","shasum":"9eae0df15cc7c1ac0f80a242f72612b3f7b67d63","tarball":"https://registry.npmjs.org/@alterjs/saber-plugin-query-posts/-/saber-plugin-query-posts-0.13.0.tgz","fileCount":5,"unpackedSize":14575,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBFy9MBwXr1PILR6O5g9YSS75Bs/B14Hf4/3TxQ2Az5cAiEA00hBHLaMk6ot9w2/Z7YzOa5uB6w8tgZd5GP6upBjxQo="}]},"_npmUser":{"name":"chawyehsu","email":"su+npm@chawyehsu.com"},"directories":{},"maintainers":[{"name":"chawyehsu","email":"su+npm@chawyehsu.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/saber-plugin-query-posts_0.13.0_1737181496363_0.7633153526680598"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-16T14:34:13.501Z","modified":"2025-01-18T06:24:56.773Z","0.12.2":"2024-10-16T14:34:13.773Z","0.13.0":"2025-01-18T06:24:56.597Z"},"bugs":{"url":"https://github.com/chawyehsu/saber/issues"},"license":"MIT","homepage":"https://github.com/chawyehsu/saber#readme","repository":{"type":"git","url":"git+https://github.com/chawyehsu/saber.git"},"description":"Query posts plugin for Saber app","maintainers":[{"name":"chawyehsu","email":"su+npm@chawyehsu.com"}],"readme":"# @alterjs/saber-plugin-query-posts\n\nQuery posts and inject them to specific pages. Useful when you're writing a blog.\n\n## Install\n\n```bash\nyarn add @alterjs/saber-plugin-query-posts\n```\n\n## Usage\n\nIn your `saber-config.yml`:\n\n```yml\nplugins:\n  - resolve: '@alterjs/saber-plugin-query-posts'\n```\n\nThen this plugin will inject all posts to pages whose attribute `injectAllPosts` is set to `true`, for instance you can create a `pages/index.md`:\n\n```markdown\n---\nlayout: index\ninjectAllPosts: true\n---\n\nWelcome to my homepage.\n```\n\nThen in the layout component `layouts/index.vue`, `page.posts` and `page.pagination` will be available:\n\n```vue\n<template>\n  <div>\n    <slot name=\"default\" />\n\n    <ul>\n      <li v-for=\"post in page.posts\" :key=\"post.permalink\">\n        <a :href=\"post.permalink\">\n          {{ post.title }}\n        </a>\n      </li>\n    </ul>\n\n    <a :href=\"page.pagination.prevLink\" v-if=\"page.pagination.hasPrev\">\n      ← Prev Page\n    </a>\n    <a :href=\"page.pagination.nextLink\" v-if=\"page.pagination.hasNext\">\n      Next Page →\n    </a>\n  </div>\n</template>\n\n<script>\nexport default {\n  props: ['page'],\n}\n</script>\n```\n\n## Draft Posts\n\nPosts with front matter `draft: true` will be excluded in `page.posts`, but they will still be built and accessible via permalink.\n\n## Tags\n\nThis plugin will automatically generate tag pages at `/tags/:tag` when you're using `tags` in page data, e.g. in a Markdown post:\n\n```markdown\n---\ntitle: hello\ndate: 2019-01-01\ntags:\n  - life\n  - random\n---\n\nhello\n```\n\n### Data Injected in Post Pages\n\nYou can access the detailed info of the tags of a post page via `this.page.tagsInfo`, for instance:\n\n```yaml\ntags:\n  - life\n  - random\n```\n\ngives you:\n\n```js\n;[\n  {\n    name: 'life',\n    permalink: '/tags/life',\n  },\n  {\n    name: 'random',\n    permalink: '/tags/random',\n  },\n]\n```\n\n### Tag Layout\n\nTag pages will use the `tag` layout or fallback to `default` layout.\n\nYou can access the tag name in the layout component via `this.page.tag`.\n\n## Categories\n\nThis plugin will automatically generate category pages at `/categories/:tag` when you're using `categories` in page data, e.g. in a Markdown post:\n\n```markdown\n---\ntitle: hello\ndate: 2019-01-01\ncategories:\n  - sports\n---\n\nhello\n```\n\nThen there will be a `/categories/sports` page，`categories` is an array, so you can assign the post to multiple categories.\n\n### Data Injected in Post Pages\n\nYou can access the detailed info of the categories of a post page via `this.page.categoriesInfo`, for instance:\n\n```yaml\ncategories:\n  - sports/football\n  - hobby\n```\n\ngives you:\n\n```js\n;[\n  {\n    name: 'sports',\n    permalink: '/categories/sports',\n  },\n  {\n    name: 'football',\n    permalink: '/categories/sports/football',\n  },\n  {\n    name: 'hobby',\n    permalink: '/categories/hobby',\n  },\n]\n```\n\n### Nesting Category\n\nIt also support nesting categories:\n\n```yaml\ncategories:\n  - sports/football\n```\n\nIn this way, it will generate two pages: `/categories/sports` and `/categories/sports/football` and both of them will include this post.\n\n### Category Layout\n\nCategory pages will use the `category` layout or fallback to `default` layout.\n\nYou can access the category name in the layout component via `this.page.category`.\n\n## Pagination\n\nBy default we show at most 30 posts per page, but you can configure this globally using `perPage` option in `saber-config.yml`:\n\n```yaml\nplugins:\n  - resolve: saber-plugin-query-posts\n    options:\n      perPage: 6\n```\n\nIt's also possible to configure this behavior for each page separately, in a page like `pages/index.md`:\n\n```markdown\n---\ninjectAllPosts:\n  perPage: 20\n---\n```\n\n## Options\n\n### perPage\n\n- Type: `number`\n- Default: `30`\n\nThe limit of posts to show per page.\n\n### firstPageOnly\n\n- Type: `boolean`\n- Default: `false`\n\nOnly generate the first page of posts.\n\n### tagsMap\n\n- Type: `{ [name: string]: string }`\n\nMap tag name to permalink's `:tag` part, by default `:tag` will be the tag name.\n\nFor example:\n\n```js\n{\n  tagsMap: {\n    'c++': 'cpp'\n  }\n}\n```\n\n### categoriesMap\n\nSame as `tagsMap` but for categories.\n\n### permalinks\n\n- Type: `{ category?: string, tag?: string }`\n- Default: `{ category: '/categories/:slug', tag: '/tags/:slug' }`\n\nThe permalink templates for category and tag pages, available placeholders:\n\n| placeholder | description                    |\n| ----------- | ------------------------------ |\n| slug        | Slugified tag / category name. |\n\n## License\n\nMIT.\n","readmeFilename":"README.md"}