From 1fbb9cf2fd094831dfdb6b36ef65a70b03233260 Mon Sep 17 00:00:00 2001 From: Andrey Helldar Date: Tue, 1 Feb 2022 21:30:59 +0300 Subject: [PATCH] Added `DocSearch` for documentation --- .env.example | 3 +++ .gitattributes | 1 + .github/workflows/docs.yml | 13 ++++++++----- .gitignore | 1 + docs/.vuepress/.gitignore | 4 ++++ docs/.vuepress/config.js | 19 ++++++++++++++++--- package.json | 9 ++++++--- 7 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 .env.example create mode 100644 docs/.vuepress/.gitignore diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..a98ecdbc --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +VITE_APP_ALGOLIA_APP_ID= +VITE_APP_ALGOLIA_API_KEY= +VITE_APP_ALGOLIA_INDEX_NAME= diff --git a/.gitattributes b/.gitattributes index a1f8d63f..b1479fa9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,6 +8,7 @@ docs/ export-ignore excludes/ export-ignore .editorconfig export-ignore +.env.example export-ignore .gitattributes export-ignore .gitignore export-ignore diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 8f6a533a..c71efa06 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,11 +3,11 @@ name: docs on: workflow_dispatch: repository_dispatch: - types: - - generate-docs + types: + - generate-docs release: - types: - - created + types: + - created jobs: handle-dispatch: @@ -35,11 +35,14 @@ jobs: ${{ runner.os }}-npm- - name: Install dependencies - if: steps.npm-cache.outputs.cache-hit != 'true' run: npm i - name: Build VuePress site run: npm run build + env: + VITE_APP_ALGOLIA_APP_ID: ${{ secrets.VITE_APP_ALGOLIA_APP_ID }} + VITE_APP_ALGOLIA_API_KEY: ${{ secrets.VITE_APP_ALGOLIA_API_KEY }} + VITE_APP_ALGOLIA_INDEX_NAME: ${{ secrets.VITE_APP_ALGOLIA_INDEX_NAME }} - name: Deploy to GitHub Pages uses: crazy-max/ghaction-github-pages@v2 diff --git a/.gitignore b/.gitignore index 2b5cbee6..680cee34 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ vendor/ .cache .DS_Store +.env .php_cs.cache .phpintel .temp diff --git a/docs/.vuepress/.gitignore b/docs/.vuepress/.gitignore new file mode 100644 index 00000000..1d57eb52 --- /dev/null +++ b/docs/.vuepress/.gitignore @@ -0,0 +1,4 @@ +.cache/ +.temp/ + +dist/ diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index e45d3f5a..da061deb 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -1,6 +1,10 @@ const fs = require('fs'); const path = require('path'); +require('dotenv').config(); + +const hostname = 'laravel-lang.com'; + module.exports = { lang: 'en-US', title: 'Laravel Lang', @@ -8,11 +12,12 @@ module.exports = { head: [ ['link', { rel: 'icon', href: '/images/logo.svg' }], - ['meta', { name: 'twitter:image', content: 'https://laravel-lang.com/images/social-logo.png' }] + ['meta', { name: 'twitter:image', content: `https://${ hostname }/images/social-logo.png` }] ], theme: '@vuepress/theme-default', themeConfig: { + hostname, base: '/', logo: '/images/logo.svg', @@ -88,7 +93,15 @@ module.exports = { description: $page => $page.frontmatter.description, type: _ => 'website', image: (_, $site) => $site.domain + '/images/social-logo.png' - } + }, + [ + '@vuepress/docsearch', + { + appId: process.env.VITE_APP_ALGOLIA_APP_ID, + apiKey: process.env.VITE_APP_ALGOLIA_API_KEY, + indexName: process.env.VITE_APP_ALGOLIA_INDEX_NAME + } + ] ] ] }; @@ -118,7 +131,7 @@ function getChildren(folder, sort = 'asc') { } function resolveNumeric(value) { - const sub = value.substr(0, value.indexOf('.')); + const sub = value.substring(0, value.indexOf('.')); const num = Number(sub); diff --git a/package.json b/package.json index 48e1b095..69cda783 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "url": "https://github.com/Laravel-Lang/lang/issues" }, "scripts": { - "dev": "vuepress dev docs", + "dev": "vuepress dev docs --debug", "build": "vuepress build docs" }, "repository": { @@ -20,8 +20,11 @@ "docs" ], "devDependencies": { - "@vuepress/plugin-theme-data": "^2.0.0-beta.33", - "vuepress": "^2.0.0-beta.33", + "@vuepress/plugin-docsearch": "^2.0.0-beta.35", + "@vuepress/plugin-theme-data": "^2.0.0-beta.35", + "@vueuse/core": "^7.5.5", + "dotenv": "^15.0.0", + "vuepress": "^2.0.0-beta.35", "vuepress-plugin-seo": "^0.2.0" } }