|
1 |
| -# Astro Starter Kit: Integration Package |
| 1 | +[日本語版はこちら](https://github.com/t0yohei/astro-qiita-loader/blob/master/README-ja.md) |
2 | 2 |
|
3 |
| -This is a template for an Astro integration. Use this template for writing integrations to use in multiple projects or publish to NPM. |
| 3 | +# Astro Qiita Loader |
4 | 4 |
|
5 |
| -```sh |
6 |
| -npm create astro@latest -- --template integration |
| 5 | +This package provides a Qiita loader for Astro, allowing you to use [Qiita posts as content collections](https://qiita.com/api/v2/docs#%E6%8A%95%E7%A8%BF). |
| 6 | + |
| 7 | +## Requirements |
| 8 | + |
| 9 | +This package requires Astro 5.0.0 or later. |
| 10 | + |
| 11 | +## Installation |
| 12 | + |
| 13 | +```bash |
| 14 | +npm install astro-qiita-loader |
| 15 | +``` |
| 16 | + |
| 17 | +## Usage |
| 18 | + |
| 19 | +You can use the `qiitaLoader` in your content configuration at `src/content/config.ts`: |
| 20 | + |
| 21 | +```ts |
| 22 | +import { qiitaLoader } from "astro-qiita-loader"; |
| 23 | + |
| 24 | +export const collections = { |
| 25 | + qiitas: qiitaLoader({ |
| 26 | + url: "https://qiita.com/api/v2/items", |
| 27 | + authToken: "your_qiita_api_token", // Optional |
| 28 | + }), |
| 29 | +}; |
7 | 30 | ```
|
8 | 31 |
|
9 |
| -[](https://stackblitz.com/github/withastro/astro/tree/latest/examples/integration) |
10 |
| -[](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/integration) |
11 |
| -[](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/integration/devcontainer.json) |
| 32 | +You can then use these like any other content collection in Astro: |
12 | 33 |
|
13 |
| -## 🚀 Project Structure |
| 34 | +```astro |
| 35 | +--- |
| 36 | +import { getCollection } from "astro:content"; |
14 | 37 |
|
15 |
| -Inside of your Astro project, you'll see the following folders and files: |
| 38 | +const qiitas = await getCollection("qiitas"); |
| 39 | +--- |
16 | 40 |
|
17 |
| -```text |
18 |
| -/ |
19 |
| -├── index.ts |
20 |
| -├── tsconfig.json |
21 |
| -├── package.json |
| 41 | +<ul> |
| 42 | + {qiitas.map((qiita) => ( |
| 43 | + <li> |
| 44 | + <a href={qiita.data.url} target="_blank" rel="noopener"> |
| 45 | + {qiita.data.title} |
| 46 | + </a> |
| 47 | + </li> |
| 48 | + ))} |
| 49 | +</ul> |
22 | 50 | ```
|
23 | 51 |
|
24 |
| -The `index.ts` file is the "entry point" for your integration. Export your integration in `index.ts` to make them importable from your package. |
| 52 | +## Options |
| 53 | + |
| 54 | +`qiitaLoader` has the following options: |
| 55 | + |
| 56 | +- `url`: Qiita API URL. Set the URL of the posts you want to fetch. |
| 57 | +- `authToken`: Qiita API authentication token. Optional: 1000 req/hr with token, 60 req/hr without |
| 58 | + |
| 59 | +## Sample |
25 | 60 |
|
26 |
| -## 🧞 Commands |
| 61 | +See the [sample](https://github.com/t0yohei/astro-qiita-loader/tree/master/demo) for reference. |
27 | 62 |
|
28 |
| -All commands are run from the root of the project, from a terminal: |
| 63 | +## License |
29 | 64 |
|
30 |
| -| Command | Action | |
31 |
| -| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
32 |
| -| `npm link` | Registers this package locally. Run `npm link my-integration` in an Astro project to install your integration | |
33 |
| -| `npm publish` | [Publishes](https://docs.npmjs.com/creating-and-publishing-unscoped-public-packages#publishing-unscoped-public-packages) this package to NPM. Requires you to be [logged in](https://docs.npmjs.com/cli/v8/commands/npm-adduser) | |
| 65 | +[MIT](https://github.com/t0yohei/astro-qiita-loader/blob/master/LICENSE) |
0 commit comments