docs: add .env instruction

This commit is contained in:
jinhojang6 2024-03-13 01:19:35 +09:00
parent 6955a5443e
commit f051721df3
4 changed files with 33 additions and 4 deletions

View File

@ -19,12 +19,20 @@ $ git clone https://github.com/acid-info/logos-docs-template.git
$ yarn install
```
3. Start the website:
3. Create .env and run fetch-content.js
```bash
GITHUB_TOKEN=
```
and `node fetch-content.js`
4. Start the website:
```bash
$ yarn start
```
4. Visit `http://localhost:3000` in your browser
5. Visit `http://localhost:3000` in your browser
## Configuration

View File

@ -2,7 +2,27 @@ const https = require('https')
const fs = require('fs')
const path = require('path')
// NOTE: Replace YOUR_GITHUB_TOKEN with your GitHub token
function loadEnv() {
const envPath = path.resolve(process.cwd(), '.env')
try {
const data = fs.readFileSync(envPath, 'utf8')
data.split('\n').forEach(line => {
line = line.trim()
if (line && !line.startsWith('#')) {
const [key, value] = line.split('=')
process.env[key.trim()] = value.trim()
}
})
} catch (err) {
console.error('Error loading .env file', err)
}
}
loadEnv()
async function fetchFromGitHub(url, callback) {
https
.get(
@ -10,7 +30,8 @@ async function fetchFromGitHub(url, callback) {
{
headers: {
'User-Agent': 'Node.js',
Authorization: `token {YOUR_GITHUB_TOKEN}`,
// NOTE: Create .env file and add GITHUB_TOKEN=your_token
Authorization: `token ${process.env.GITHUB_TOKEN}`,
},
},
res => {

Binary file not shown.