Skip to content

Commit

Permalink
feat: add algolia search with crawl actions
Browse files Browse the repository at this point in the history
  • Loading branch information
thangbuiq committed Feb 17, 2024
1 parent 0597170 commit b9fea87
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 16 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/auto_dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ jobs:
curl -X PUT \
-H "Authorization: Bearer ${{ secrets.TOKEN_GITHUB }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/merge?merge_method=squash"
curl -X PUT \
-H "Authorization: Bearer ${{ secrets.TOKEN_GITHUB }}" \
-H "Accept: application/vnd.github.v3+json" \
-d '{"merge_method": "squash"}' \
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/merge"
env:
USER_NAME: ubunchuu[bot]
USER_EMAIL: 159746302+ubunchuu-admin@users.noreply.github.com
16 changes: 16 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,19 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Install jq
uses: dcarbone/install-jq-action@v2.1.0

- name: Input Algolia secret into .env
run: |
touch .env
echo "API_KEY=${{ secrets.ALGOLIA_API_KEY }}" >> .env
echo "APPLICATION_ID=${{ secrets.ALGOLIA_APP_ID }}" >> .env
- name: Crawling the deployed website using Algolia DocSearch
run: |
docker run -it --env-file=.env -e "CONFIG=$(cat config.json | jq -r tostring)" algolia/docsearch-scraper
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
**/.env

# Dependencies
/node_modules

Expand Down
36 changes: 36 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"index_name": "ubunchuu-truong-usio",
"sitemap_urls": ["https://ubunchuu-truong-us.github.io/sitemap.xml"],
"sitemap_alternate_links": true,
"stop_urls": ["/tests"],
"selectors": {
"lvl0": {
"selector": "(//ul[contains(@class,'menu__list')]//a[contains(@class, 'menu__link menu__link--sublist menu__link--active')]/text() | //nav[contains(@class, 'navbar')]//a[contains(@class, 'navbar__link--active')]/text())[last()]",
"type": "xpath",
"global": true,
"default_value": "Documentation"
},
"lvl1": "header h1",
"lvl2": "article h2",
"lvl3": "article h3",
"lvl4": "article h4",
"lvl5": "article h5, article td:first-child",
"lvl6": "article h6",
"text": "article p, article li, article td:last-child"
},
"strip_chars": " .,;:#",
"custom_settings": {
"separatorsToIndex": "_",
"attributesForFaceting": ["language", "version", "type", "docusaurus_tag"],
"attributesToRetrieve": [
"hierarchy",
"content",
"anchor",
"url",
"url_without_anchor",
"type"
]
},
"conversation_id": ["833762294"],
"nb_hits": 46250
}
16 changes: 7 additions & 9 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ const config = {
// If you aren't using GitHub pages, you don't need these.
organizationName: 'ubunchuu-truong-us', // Usually your GitHub org/user name.
projectName: 'ubunchuu-truong-us.github.io', // Usually your repo name.
// Search bar config
themes: [
[
require.resolve('@easyops-cn/docusaurus-search-local'),
{
hashed: true,
},
],
],
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn',

Expand Down Expand Up @@ -68,6 +59,13 @@ const config = {
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
// Algolia DocSearch search integration
algolia: {
contextualSearch: true,
apiKey: '0a9bc2d53144bd55ed0ba248b6876331', // Public API Key (safe to share)
appId: '7VSRZ5ZBII', // Provided by Algolia to identify your application
indexName: 'ubunchuu-truong-usio', // Name of the index you want to target
},
// Replace with your project's social card
image: 'img/docusaurus-social-card.jpg',
navbar: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@docusaurus/core": "3.1.1",
"@docusaurus/preset-classic": "3.1.1",
"@easyops-cn/docusaurus-search-local": "^0.40.1",
"@docusaurus/theme-search-algolia": "^3.1.1",
"@mdx-js/react": "^3.0.1",
"clsx": "^2.0.0",
"prism-react-renderer": "^2.3.0",
Expand Down
6 changes: 1 addition & 5 deletions src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap');

/* code span {
font-family: 'JetBrains Mono', monospace !important;
} */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap');

/* You can override the default Infima variables here. */
:root {
Expand Down

0 comments on commit b9fea87

Please sign in to comment.