VuePress μμνκΈ°
VuePress λ₯Ό μ΄μ©νμ¬ TIL μ μμ±νλ €κ³ νλ€. VuePress λ₯Ό μ΄μ©νμ¬ md νμΌμ html λ‘ λ³ννκ³ μ΄λ₯Ό μλΉμ€ νλ €κ³ νλ€. κ·ΈλΌ Vuepress λ 무μμΈκ°?
Vuepress λ 무μ?
- Vuepress λ Vue.js λ‘ κ°λ°λμ΄μ§ μ μ μ¬μ΄νΈ μμ±κΈ°μ΄λ€
- κΈ°μ λ¬Έμ μμ±μ μν΄ μ΅μ νλ κΈ°λ³Έν λ§λ₯Ό μ 곡ν΄μ€λ€
- Plugin APIλ₯Ό μ 곡ν΄μ£Όμ΄ νλ¬κ·ΈμΈμ μ μνκ±°λ μ μ©ν μ μλ€. ( Google Analytics, PWA λ₯Ό μμ½κ² μ μ©κ°λ₯ν¨ )
κΈ°λ³Έ μ€μΉ λ° λΉλ
# global install
$ yarn global add vuepress
# install as a local dependency
$ yarn add -D vuepress
$ mkdir docs
# λ§ν¬λ€μ΄ νμΌμ μμ±νλ€.
$ echo '# Hello VuePress' > docs/README.md
package.json μ scripts μΆκ°
{
"scripts": {
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
}
}
# Development Mode
$ yarn docs:dev
# build to static files
$ yarn docs:build
Directory Structure
VuePress μμ κΆμ₯λλ ꡬ쑰λ μλμ κ°λ€
.
βββ docs
β βββ .vuepress (Optional)
β β βββ components (Optional)
β β βββ theme (Optional)
β β β βββ Layout.vue
β β βββ public (Optional)
β β βββ styles (Optional)
β β β βββ index.styl
β β β βββ palette.styl
β β βββ templates (Optional, Danger Zone)
β β β βββ dev.html
β β β βββ ssr.html
β β βββ config.js (Optional)
β β βββ enhanceApp.js (Optional)
β β
β βββ README.md
β βββ guide
β β βββ README.md
β βββ config.md
β
βββ package.json
:::warning Note μμΈν μ¬νμ VuePress 곡μλ¬Έμ λ₯Ό μ°Έκ³ νκΈΈ λ°λλ€ :::
Default Page Routing
νκ² λλ ν λ¦¬λ‘ docs
λ₯Ό μ¬μ©νλ€. μλμ λͺ¨λ 'μλκ²½λ‘'λ docs
λλ ν 리μ μλμ μ΄λ€.
κΈ°λ³Έ νμ΄μ§ λΌμ°ν
κ²½λ‘λ λ€μκ³Ό κ°λ€
|κ²½λ‘|νμ΄μ§ λΌμ°ν
|
| :-- | :-- |
|/README.md
|/
|
|/guide/README.md
|/guide/
|
|/config.md
|/config.html
|
Maekdown Extensions
Syntax Highlighting in Code Blocks
input
``` js export default { name: 'MyComponent', // ... } ```
output
export default {
name: 'MyComponent',
// ...
}
Line Numbers
You can enable line numbers for each code blocks via config:
module.exports = {
markdown: {
lineNumbers: true
}
}
Deploying
GitHub Pages
docs/.vuepress/config.js
μ base μ€μ https://github.com/<USERNAME>/<REPO>
μ κ²½μ° base λ "//" κ° λ¨ -
νλ‘μ νΈ λ΄μ deploy.sh μ€μ
#!/usr/bin/env sh
abort on errors
set -e
build
npm run docs:build
navigate into the build output directory
cd docs/.vuepress/dist
if you are deploying to a custom domain
echo 'www.example.com' > CNAME
git init git add -A git commit -m 'deploy'
if you are deploying to https://.github.io
git push -f git@github.com:/.github.io.git master
if you are deploying to https://.github.io/
git push -f https://github.com/javapark/javapark.github.io.git master:gh-pages
cd -
3. `main.yaml` μ€μ
name: Build and Deploy on: [push] jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@main
- name: Vuepress deploy
uses: jenkey2011/vuepress-deploy@1.0.1
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BUILD_SCRIPT: yarn && yarn docs:build
TARGET_BRANCH: gh-pages
BUILD_DIR: docs/.vuepress/dist
### [Netlify](https://vuepress.vuejs.org/guide/deploy.html#netlify)
1. [Netlify](https://www.netlify.com/) , setup up a new project from GitHub with the following settings:
- **Build Command:** vuepress build docs or yarn docs:build or npm run docs:build
- **Publish directory:** docs/.vuepress/dist
2. Hit the deploy button
## Ref
- [Vuepress λ‘ κΈ°μ λ¬Έμ λΉ λ₯΄κ² λ§λ€μ΄λ³΄μ](https://limdongjin.github.io/vuejs/vuepress/#table-of-contents)
- [VuePress](https://vuepress.vuejs.org/)
<Comment />