Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add algolia search #2603

Merged
merged 1 commit into from
Dec 4, 2024
Merged

docs: add algolia search #2603

merged 1 commit into from
Dec 4, 2024

Conversation

kagol
Copy link
Member

@kagol kagol commented Dec 3, 2024

PR

主要更新:

  • 引入 Algolia 全文搜索,在顶部导航增加搜索框,提供更好的搜索体验,之前只能搜索组件名称,现在可以搜索整个文档,包括使用指南文档、组件 Demo / API 文档
  • 移除原来左侧菜单上面的搜索框

效果如下:

image

image

image

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Introduced a search functionality with a dedicated search box and enhanced styling.
    • Updated documentation for installation, theme configuration, and internationalization to improve clarity and organization.
  • Bug Fixes

    • Corrected the binding for the modal component to ensure consistent naming.
  • Documentation

    • Enhanced structure and readability of multiple markdown documents by adjusting header levels and formatting.
  • Style

    • Added new CSS styles for the search feature and improved existing styles for better user experience.

@kagol kagol added the documentation 对文档的改进或补充 label Dec 3, 2024
Copy link

coderabbitai bot commented Dec 3, 2024

Walkthrough

This pull request primarily involves structural modifications to various markdown documentation files related to the TinyVue framework. The changes include adjustments to header levels for better organization and readability, alongside minor textual rephrasing for clarity. Additionally, several files introduce a search feature in the HTML and CSS, enhancing user navigation. The overall content and functionality of the documentation remain intact, focusing on improving the presentation and accessibility of the information provided.

Changes

File Path Change Summary
examples/sites/demos/pc/webdoc/develop-demo-en.md Header levels adjusted; minor text reformatting for clarity.
examples/sites/demos/pc/webdoc/develop-demo.md Header levels updated; formatting changes without altering content.
examples/sites/demos/pc/webdoc/envpreparation-open-en.md Header levels changed; text modified for clarity.
examples/sites/demos/pc/webdoc/envpreparation-open.md Header levels updated; content unchanged.
examples/sites/demos/pc/webdoc/faq-en.md Header levels adjusted for better organization; content remains the same.
examples/sites/demos/pc/webdoc/faq.md Header levels changed; content unchanged.
examples/sites/demos/pc/webdoc/form-valid-en.md Header levels standardized; minor text adjustments for clarity.
examples/sites/demos/pc/webdoc/form-valid.md Header levels updated for better hierarchy; content remains unchanged.
examples/sites/demos/pc/webdoc/i18n-en.md Header levels changed; minor content updates for clarity.
examples/sites/demos/pc/webdoc/i18n.md Header levels adjusted; content remains largely unchanged.
examples/sites/demos/pc/webdoc/import-components-en.md Header levels updated; minor text adjustments made.
examples/sites/demos/pc/webdoc/import-components.md Header levels changed; content remains the same.
examples/sites/demos/pc/webdoc/installation-en.md Header levels adjusted; content reformatted for clarity.
examples/sites/demos/pc/webdoc/installation.md Header levels changed; content refined for clarity.
examples/sites/demos/pc/webdoc/theme-en.md Header levels adjusted; content expanded for clarity on theme customization.
examples/sites/demos/pc/webdoc/theme.md Header levels updated; content preserved with enhanced organization.
examples/sites/index.html Added styles and scripts for DocSearch functionality.
examples/sites/src/App.vue Introduced envTarget constant for conditional rendering of the search box; corrected modalShow binding.
examples/sites/src/style.css New styles added for search feature, including media queries and CSS variables.
examples/sites/src/views/components/components.vue Updated semantic structure by replacing <div> with <h2> and <h3> tags; refined conditional rendering logic.
examples/sites/src/views/components/demo.vue Changed demo title from <div> to <h2> for better semantic structure.
examples/sites/src/views/layout/layout.vue Added :show-filter="false" prop to tiny-tree-menu component.

Possibly related PRs

Suggested labels

enhancement

🐰 "In the fields where we hop and play,
Our docs now shine in a clearer way!
With headers high and texts refined,
A search to help you, you will find.
So read with joy, and hop along,
For every change makes us more strong!" 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Dec 3, 2024

[e2e-test-warn]
The component to be tested is missing.

The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug".

Please make sure you've read our contributing guide

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (21)
examples/sites/src/views/components/components.vue (2)

149-151: Consider enhancing heading styles for better visual hierarchy

While the semantic structure has been improved, consider adding specific styles for the new heading tags to better distinguish the hierarchy visually.

<style lang="less" scoped>
+ h2.ti-f18 {
+   margin-bottom: 1rem;
+   color: var(--ti-heading-color, #191919);
+ }
+
+ h3.ti-f18 {
+   margin-top: 1.5rem;
+   color: var(--ti-subheading-color, #333);
+ }
</style>

Also applies to: 158-160


149-151: Semantic structure supports Algolia search integration

The improved heading structure with semantic HTML elements will enhance the effectiveness of Algolia's search functionality by providing better content structure for indexing and search relevance.

Also applies to: 158-160

examples/sites/src/views/layout/layout.vue (1)

Line range hint 149-156: Consider removing unused search functionality

Since the filter is now disabled and being replaced by Algolia search, the searchMenu method appears to be unused. Consider removing this method and its related functionality to maintain code cleanliness.

- const searchMenu = (value, data) => {
-   if (!value) return true
-   const trimValue = value.trim().toLowerCase()
-   const isGird = (trimValue === 'grid' || trimValue === '表格') && data.key?.startsWith('grid')
-   return data.label.toLowerCase().includes(value.toLowerCase()) || isGird
- }
examples/sites/demos/pc/webdoc/i18n-en.md (2)

Line range hint 24-31: Inconsistent locale text between Vue 3.0 and Vue 2.0 sections

The Chinese locale text is inconsistent between Vue 3.0 ('中文') and Vue 2.0 ('Chinese') sections. This might confuse users implementing i18n in their applications.

Suggest standardizing to either Chinese characters or English text across both sections:

     messages: {
       zhCN: {
-        test: '中文'
+        test: 'Chinese'
       },
       enUS: {
         test: 'English'
       }

Line range hint 51-90: Consider adding error handling examples

While the basic i18n setup is well documented, it would be beneficial to include examples of handling missing translations or fallback locales.

Consider adding a section demonstrating fallback configuration:

export default (i18n) =>
  locale.initI18n({
    i18n,
    VueI18n,
    fallbackLocale: 'enUS',  // Fallback to English when translation is missing
    messages: {
      // ... existing messages
    }
  })
examples/sites/demos/pc/webdoc/develop-demo-en.md (2)

Line range hint 42-52: Add explanation for process.env configuration requirement

The Vite configuration includes process.env definition without explaining why it's necessary for TinyVue components.

Consider adding an explanation:

```js {8-10}
//vite.config.js

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
  plugins: [vue()],
  define: {
    'process.env': { ...process.env }  // Required for TinyVue's runtime environment detection
  }
})

+> Note: The process.env definition is required for TinyVue components to properly detect the runtime environment and enable corresponding features.


---

Line range hint `54-83`: **Add TypeScript usage example**

The documentation shows JavaScript examples but lacks TypeScript support information.

Consider adding a TypeScript example:

```ts
<script setup lang="ts">
import { Button as TinyButton } from '@opentiny/vue'
import type { ButtonProps } from '@opentiny/vue'

// TypeScript props example
const buttonProps: ButtonProps = {
  type: 'success'
}
</script>
examples/sites/demos/pc/webdoc/installation-en.md (2)

Line range hint 60-84: Enhance CDN security and versioning

The CDN import section could be improved for better security and maintainability.

Consider these enhancements:

  1. Add SRI (Subresource Integrity) hashes:
-  <link rel="stylesheet" href="https://unpkg.com/@opentiny/vue-theme/index.css" />
+  <link rel="stylesheet" 
+        href="https://unpkg.com/@opentiny/vue-theme/index.css" 
+        integrity="sha384-..." 
+        crossorigin="anonymous" />
  1. Add a note about version pinning in production:
> Note: For production environments, it's recommended to pin to specific versions rather than using major version numbers (3.12) to avoid unexpected breaking changes.
🧰 Tools
🪛 LanguageTool

[style] ~61-~61: Consider a shorter alternative to avoid wordiness.
Context: ...e>.

## Import through CDN In order to experience TinyVue components faster, y...

(IN_ORDER_TO_PREMIUM)


Line range hint 106-142: Add rollback instructions for upgrades

The upgrade section should include rollback instructions in case of issues.

Consider adding:

### Rollback Instructions

If you encounter issues after upgrading:

1. Revert package.json changes:
   ```bash
   git checkout package.json
   git checkout package-lock.json # or yarn.lock
  1. Reinstall the previous version:

    npm install @opentiny/vue2@<previous-version> # or vue3
  2. Clear dependency cache:

    npm cache clean --force

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 LanguageTool</summary>

[style] ~108-~108: Specify a number, remove phrase, or simply use “many” or “numerous”
Context: ...ical Project Upgrade  due to`TinyVue`of a large number of projects and`@opentiny/vue2`or`@opentin...

(LARGE_NUMBER_OF)

---

[uncategorized] ~108-~108: Possible missing preposition found.
Context: ... maintained, you are advised to upgrade the latest versions using either of the fol...

(AI_HYDRA_LEO_MISSING_TO)

</details>

</details>

</blockquote></details>
<details>
<summary>examples/sites/demos/pc/webdoc/installation.md (2)</summary><blockquote>

Line range hint `42-53`: **Enhance TINY_MODE documentation.**

While the configuration is well explained, consider adding a list of valid values for `TINY_MODE` to help users understand their options.

Consider adding:
```diff
  <div class="tip custom-block">
    <br>
    <p><code> @opentiny/vue </code> 支持多种模式。如果您的工程非移动端工程,可以在上面配置代码中的<code>process.env</code>中,声明<code>TINY_MODE</code>的值,以使工程在构建时,能将移动端模式的代码摇掉,优化打包产物的体积。比如 <code>'process.env': { ...process.env,TINY_MODE:'pc' }</code>。</p>
+   <p>有效的 TINY_MODE 值包括:
+     <ul>
+       <li><code>pc</code>: PC端模式</li>
+       <li><code>mobile</code>: 移动端模式</li>
+     </ul>
+   </p>
  </div>

Line range hint 137-185: Consider using a dynamic GitHub issue link.

The troubleshooting section is helpful, but the hardcoded GitHub issue URL could become outdated.

Consider using a variable for the GitHub repository URL:

- 如果您在项目升级中遇到其他困难,可以到 github 上新建 issue 反馈(`https://github.com/opentiny/tiny-vue/issues`)
+ 如果您在项目升级中遇到其他困难,可以到 <a :href="`${repoUrl}/issues`">GitHub</a> 上新建 issue 反馈
examples/sites/demos/pc/webdoc/theme.md (1)

Line range hint 18-79: Consider adding visual examples of theme customization.

While the technical documentation is excellent, adding screenshots or a live demo of theme customization results would help users better understand the impact of their changes.

Would you like me to help create a visual guide showing before/after examples of theme customization?

examples/sites/demos/pc/webdoc/theme-en.md (2)

Line range hint 1-16: Improve English translation and consistency.

Several issues need attention:

  1. Some technical terms remain in Chinese
  2. Inconsistent formatting in code examples
  3. Mixed language usage in comments

Consider reviewing and updating the English translation for consistency and clarity. For example:

- 537/5000
- A set of global CSS variables is defined in the TinyVue component library to unify theme styles
+ The TinyVue component library defines a set of global CSS variables to unify theme styles

Line range hint 80-106: Standardize code comments in English documentation.

The code examples contain mixed Chinese and English comments.

Consider standardizing to English:

- // 效果同上
+ // Same effect as above

- // 挂载点
+ // Mount point
examples/sites/demos/pc/webdoc/form-valid-en.md (4)

5-7: Improve grammar in the introduction

The sentence structure needs improvement for better clarity.

-Form validation is based on`async-validator`Encapsulated, mainly used`validate`Function and`rules`Configuration rules of the.
+Form validation is encapsulated using `async-validator`, primarily utilizing the `validate` function and `rules` configuration.
🧰 Tools
🪛 LanguageTool

[grammar] ~6-~6: A word may be missing after ‘the’.
Context: ...nction andrulesConfiguration rules of the. ## API ### validate When submitting ...

(THE_SENT_END)


70-77: Improve formatting consistency in required section

The formatting of boolean values and special characters needs standardization.

-`true`: Set to`true`, indicates that the field is mandatory and the label is marked with a red asterisk \*.
-`false`: default value, indicating that the field is not mandatory. The label does not contain red asterisks \*.
+`true`: Set to `true`, indicates that the field is mandatory and the label is marked with a red asterisk (*).
+`false`: Default value, indicating that the field is not mandatory. The label does not contain red asterisks (*).
🧰 Tools
🪛 LanguageTool

[uncategorized] ~74-~74: Loose punctuation mark.
Context: ...at is, non-empty verification. - true: Set totrue, indicates that the field ...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~74-~74: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...`, indicates that the field is mandatory and the label is marked with a red asterisk...

(COMMA_COMPOUND_SENTENCE_2)


[uncategorized] ~76-~76: Loose punctuation mark.
Context: ...arked with a red asterisk *. - false: default value, indicating that the fiel...

(UNLIKELY_OPENING_PUNCTUATION)


Line range hint 253-280: Enhance validator example with TypeScript types

The validator example could be improved with TypeScript type annotations for better clarity and type safety.

-validatePass(rule, value, callback) {
+validatePass(rule: any, value: string, callback: (error?: Error) => void) {
   if (!/^(?=._[a-z])(?=._[A-Z])(?=.\*\\d)[a-zA-Z\d]{8,}$/.test(value)) {
     callback(new Error('At least eight characters, including at least one uppercase letter, one lowercase letter, and one digit'))
   } else {
     callback()
   }
 }

1-4: Enhance documentation searchability

Since this documentation is being integrated with Algolia search, consider adding relevant keywords and cross-references at the beginning of the document to improve searchability.

 # Form Verification Configuration
 
+> Keywords: form validation, async-validator, validation rules, form verification, input validation
+
+Related topics:
+- [Form Component](/components/form)
+- [Input Validation](/guides/validation)
+
 <br>
 <br>
examples/sites/src/style.css (2)

31-36: Consider using CSS Grid or Flexbox for search box positioning

Using absolute positioning with fixed pixel values could cause layout issues across different viewport sizes. Consider using CSS Grid or Flexbox for more flexible positioning.

.search-box {
-  position: absolute;
+  display: flex;
+  align-items: center;
   z-index: 1000;
-  top: 12px;
-  left: 360px;
+  margin-left: auto;
+  padding: 12px;
}

65-85: Improve responsive design breakpoints

The current media queries have overlapping breakpoints and fixed positioning values. Consider using relative units and standardizing the breakpoints.

@media screen and (max-width: 1023px) {
  .search-box {
-    left: 420px;
+    left: calc(50% - 100px);
  }
}

@media screen and (max-width: 768px) {
  .DocSearch-Modal {
    margin-top: 60px;
  }

  .search-box {
-    left: 360px;
+    left: calc(50% - 80px);
  }
}

@media screen and (max-width: 430px) {
  .search-box {
-    left: 300px;
+    left: calc(50% - 60px);
  }
}
examples/sites/src/App.vue (1)

Line range hint 5-5: Fix typo in variable name

The variable modalSHow has a typo and should be modalShow for consistency.

-      <tiny-modal :show-header="false" :show-footer="false" v-model="modalSHow" width="1400px" height="900px" resize>
+      <tiny-modal :show-header="false" :show-footer="false" v-model="modalShow" width="1400px" height="900px" resize>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5a3433a and 0f626d0.

📒 Files selected for processing (22)
  • examples/sites/demos/pc/webdoc/develop-demo-en.md (2 hunks)
  • examples/sites/demos/pc/webdoc/develop-demo.md (2 hunks)
  • examples/sites/demos/pc/webdoc/envpreparation-open-en.md (1 hunks)
  • examples/sites/demos/pc/webdoc/envpreparation-open.md (1 hunks)
  • examples/sites/demos/pc/webdoc/faq-en.md (1 hunks)
  • examples/sites/demos/pc/webdoc/faq.md (1 hunks)
  • examples/sites/demos/pc/webdoc/form-valid-en.md (15 hunks)
  • examples/sites/demos/pc/webdoc/form-valid.md (15 hunks)
  • examples/sites/demos/pc/webdoc/i18n-en.md (2 hunks)
  • examples/sites/demos/pc/webdoc/i18n.md (4 hunks)
  • examples/sites/demos/pc/webdoc/import-components-en.md (4 hunks)
  • examples/sites/demos/pc/webdoc/import-components.md (6 hunks)
  • examples/sites/demos/pc/webdoc/installation-en.md (4 hunks)
  • examples/sites/demos/pc/webdoc/installation.md (5 hunks)
  • examples/sites/demos/pc/webdoc/theme-en.md (3 hunks)
  • examples/sites/demos/pc/webdoc/theme.md (10 hunks)
  • examples/sites/index.html (1 hunks)
  • examples/sites/src/App.vue (2 hunks)
  • examples/sites/src/style.css (1 hunks)
  • examples/sites/src/views/components/components.vue (1 hunks)
  • examples/sites/src/views/components/demo.vue (1 hunks)
  • examples/sites/src/views/layout/layout.vue (1 hunks)
✅ Files skipped from review due to trivial changes (10)
  • examples/sites/demos/pc/webdoc/develop-demo.md
  • examples/sites/demos/pc/webdoc/import-components-en.md
  • examples/sites/demos/pc/webdoc/faq.md
  • examples/sites/demos/pc/webdoc/envpreparation-open.md
  • examples/sites/demos/pc/webdoc/form-valid.md
  • examples/sites/src/views/components/demo.vue
  • examples/sites/demos/pc/webdoc/faq-en.md
  • examples/sites/demos/pc/webdoc/i18n.md
  • examples/sites/demos/pc/webdoc/envpreparation-open-en.md
  • examples/sites/demos/pc/webdoc/import-components.md
🧰 Additional context used
🪛 Gitleaks (8.21.2)
examples/sites/index.html

36-36: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🪛 LanguageTool
examples/sites/demos/pc/webdoc/form-valid-en.md

[grammar] ~6-~6: A word may be missing after ‘the’.
Context: ...nction andrulesConfiguration rules of the. ## API ### validate When submitting ...

(THE_SENT_END)


[uncategorized] ~74-~74: Loose punctuation mark.
Context: ...at is, non-empty verification. - true: Set totrue, indicates that the field ...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~74-~74: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...`, indicates that the field is mandatory and the label is marked with a red asterisk...

(COMMA_COMPOUND_SENTENCE_2)


[uncategorized] ~76-~76: Loose punctuation mark.
Context: ...arked with a red asterisk *. - false: default value, indicating that the fiel...

(UNLIKELY_OPENING_PUNCTUATION)

🔇 Additional comments (5)
examples/sites/src/views/components/components.vue (1)

149-151: Great improvement in semantic HTML structure!

The replacement of <div> elements with proper heading tags (<h2> and <h3>) enhances accessibility, SEO, and document outline. This change makes the content structure more meaningful for screen readers and search engines.

Also applies to: 158-160

examples/sites/src/views/layout/layout.vue (2)

14-14: LGTM: Disabling filter aligns with Algolia search integration

The addition of :show-filter="false" correctly implements the removal of the existing search box from the left-side menu, making way for the new Algolia search in the top navigation.


13-15: Verify removal of filter-related CSS

Since the filter functionality is being removed, there might be associated CSS styles that could be cleaned up.

✅ Verification successful

No filter-related CSS cleanup needed

After examining the layout.vue file, I found that there are no specific CSS styles related to the filter functionality that need to be removed. The --layout-tree-menu-input-height variable is still being used for the general tree menu layout and isn't exclusively tied to the filter functionality. The removal of the filter feature was done cleanly at the template level by setting :show-filter="false" without leaving any orphaned CSS.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for filter-related CSS styles in the codebase
rg -l "tiny-input|--layout-tree-menu-input-height" --type css

Length of output: 63


Script:

#!/bin/bash
# Let's try a broader search for filter-related CSS in various file types
rg -t css -t vue -t scss -t less "filter.*input|tree.*input|menu.*input" -A 2 -B 2

Length of output: 112


Script:

#!/bin/bash
# Search specifically in the layout.vue file and its directory for any CSS styles
fd -e vue -e css -e scss -e less . examples/sites/src/views/layout | xargs cat

Length of output: 10152


Script:

#!/bin/bash
# Look for any CSS classes that might be related to the filter functionality
rg "\..*filter.*|\..*search.*menu" -t css -t vue -t scss -t less

Length of output: 94

examples/sites/demos/pc/webdoc/installation.md (2)

Line range hint 3-15: LGTM! Clear version compatibility documentation.

The version compatibility information is well-structured and includes important details about Vue 2.7+ support.


Line range hint 83-106: LGTM! Clear documentation of runtime options.

The runtime options table clearly explains the different bundle options available from v3.17.0.

Comment on lines +31 to +40
.search-box {
position: absolute;
z-index: 1000;
top: 12px;
left: 360px;
}

.DocSearch-Container {
z-index: 1000;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Review z-index hierarchy

The z-index values of 1000 for both .search-box and .DocSearch-Container might conflict with the existing z-index hierarchy defined in :root. Consider using the existing z-index variables for consistency.

.search-box {
  position: absolute;
-  z-index: 1000;
+  z-index: var(--docs-float-settings-zindex);
  top: 12px;
  left: 360px;
}

.DocSearch-Container {
-  z-index: 1000;
+  z-index: var(--docs-float-settings-zindex);
}

Committable suggestion skipped: line range outside the PR's diff.

@@ -21,12 +21,24 @@
window.DEPLOY_URL = ''
window.process = { env: {} }
</script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3"/>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add SRI hash for CDN resources

Add integrity hashes for the CDN resources to prevent supply chain attacks.

-    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3"/>
+    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3" 
+          integrity="sha384-..." 
+          crossorigin="anonymous"/>

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +34 to +41
docsearch({
appId: "AGPA5UXHMH",
apiKey: "5fa09fc20270efa61d68e2c2eb0f56df",
indexName: "opentiny",
container: ".search-box",
debug: false
});
</script>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Security: Move API credentials to environment variables

The Algolia API credentials should not be exposed in client-side code. Move these to environment variables and load them securely.

      docsearch({
-        appId: "AGPA5UXHMH",
-        apiKey: "5fa09fc20270efa61d68e2c2eb0f56df",
-        indexName: "opentiny",
+        appId: import.meta.env.VITE_ALGOLIA_APP_ID,
+        apiKey: import.meta.env.VITE_ALGOLIA_API_KEY,
+        indexName: import.meta.env.VITE_ALGOLIA_INDEX_NAME,
         container: ".search-box",
         debug: false
      });

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Gitleaks (8.21.2)

36-36: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

Comment on lines +46 to +49
const searchBox = document.querySelector('.search-box')
if (searchBox && envTarget === 'open') {
searchBox.style.display = 'block'
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid direct DOM manipulation in Vue

Instead of using direct DOM manipulation, consider using Vue's reactivity system and v-show/v-if directives.

-      const searchBox = document.querySelector('.search-box')
-      if (searchBox && envTarget === 'open') {
-        searchBox.style.display = 'block'
-      }

Move the logic to the template:

<template>
  <div class="search-box" v-show="showSearchBox">
    <!-- search box content -->
  </div>
</template>

<script>
export default {
  setup() {
    const showSearchBox = computed(() => envTarget === 'open')
    return {
      showSearchBox
    }
  }
}
</script>

@zzcr zzcr merged commit c53a740 into dev Dec 4, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 对文档的改进或补充
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants