Skip to content

Commit 09e7a4e

Browse files
committed
chore: update readme
1 parent 9f33a9a commit 09e7a4e

File tree

3 files changed

+124
-65
lines changed

3 files changed

+124
-65
lines changed

README-ja.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
[English version here](https://github.com/t0yohei/astro-qiita-loader/blob/master/README.md)
2+
3+
# Astro Qiita Loader
4+
5+
このパッケージは、[Qiita の投稿をコンテンツコレクション](https://qiita.com/api/v2/docs#%E6%8A%95%E7%A8%BF)として使用できる Astro 用の Qiita ローダーを提供します。
6+
7+
## 必要要件
8+
9+
このパッケージは Astro 5.0.0 以降が必要です。
10+
11+
## インストール
12+
13+
```bash
14+
npm install astro-qiita-loader
15+
```
16+
17+
## 使用方法
18+
19+
`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", // オプション
28+
}),
29+
};
30+
```
31+
32+
次に、Astro では以下のように使用できます。
33+
34+
```astro
35+
---
36+
import { getCollection } from "astro:content";
37+
38+
const qiitas = await getCollection("qiitas");
39+
---
40+
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>
50+
```
51+
52+
これで、他のコンテンツコレクションと同じように使用できます。
53+
54+
## オプション
55+
56+
`qiitaLoader`には以下のオプションがあります。
57+
58+
- `url`: Qiita API の URL。取得したい投稿用の URL を設定する。
59+
- `authToken`: Qiita API の認証トークン。トークンあり:1000 回/時、なし:60 回/時まで
60+
61+
## サンプル
62+
63+
[サンプル](https://github.com/t0yohei/astro-qiita-loader/tree/master/demo)を参照してください。
64+
65+
## ライセンス
66+
67+
[MIT](https://github.com/t0yohei/astro-qiita-loader/blob/master/LICENSE)

README.md

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,65 @@
1-
# Astro Starter Kit: Integration Package
1+
[日本語版はこちら](https://github.com/t0yohei/astro-qiita-loader/blob/master/README-ja.md)
22

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
44

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+
};
730
```
831

9-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/integration)
10-
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/integration)
11-
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/integration/devcontainer.json)
32+
You can then use these like any other content collection in Astro:
1233

13-
## 🚀 Project Structure
34+
```astro
35+
---
36+
import { getCollection } from "astro:content";
1437
15-
Inside of your Astro project, you'll see the following folders and files:
38+
const qiitas = await getCollection("qiitas");
39+
---
1640
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>
2250
```
2351

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
2560

26-
## 🧞 Commands
61+
See the [sample](https://github.com/t0yohei/astro-qiita-loader/tree/master/demo) for reference.
2762

28-
All commands are run from the root of the project, from a terminal:
63+
## License
2964

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)

demo/README.md

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,7 @@
1-
# Astro Starter Kit: Minimal
1+
# Astro Qiita Loader Demo
22

3-
```sh
4-
npm create astro@latest -- --template minimal
5-
```
3+
This is a demo of the Astro Qiita Loader.
64

7-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/minimal)
8-
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/minimal)
9-
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/minimal/devcontainer.json)
5+
## Demo Page
106

11-
> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
12-
13-
## 🚀 Project Structure
14-
15-
Inside of your Astro project, you'll see the following folders and files:
16-
17-
```text
18-
/
19-
├── public/
20-
├── src/
21-
│ └── pages/
22-
│ └── index.astro
23-
└── package.json
24-
```
25-
26-
Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.
27-
28-
There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
29-
30-
Any static assets, like images, can be placed in the `public/` directory.
31-
32-
## 🧞 Commands
33-
34-
All commands are run from the root of the project, from a terminal:
35-
36-
| Command | Action |
37-
| :------------------------ | :----------------------------------------------- |
38-
| `npm install` | Installs dependencies |
39-
| `npm run dev` | Starts local dev server at `localhost:4321` |
40-
| `npm run build` | Build your production site to `./dist/` |
41-
| `npm run preview` | Preview your build locally, before deploying |
42-
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
43-
| `npm run astro -- --help` | Get help using the Astro CLI |
44-
45-
## 👀 Want to learn more?
46-
47-
Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
7+
[Astro Qiita Loader Demo](https://astro-qiita-loader-demo.netlify.app/)

0 commit comments

Comments
 (0)