Skip to content

Commit f656779

Browse files
DOC: use default meilisearch credentials (#210)
* DOC: use default meilisearch credentials * FIX: no longer required env variables * DBG: fix syntax * DOC: update theme options * DOC: remove duplicated word Co-authored-by: Revathy Venugopal <[email protected]> --------- Co-authored-by: Revathy Venugopal <[email protected]>
1 parent c27f5b8 commit f656779

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

.github/workflows/ci_cd.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ env:
1212
PACKAGE_NAME: 'ansys-sphinx-theme'
1313
PACKAGE_NAMESPACE: 'ansys_sphinx_theme'
1414
DOCUMENTATION_CNAME: 'sphinxdocs.ansys.com'
15-
MEILISEARCH_HOST_NAME: ${{ secrets.MEILISEARCH_HOST_NAME}}
16-
MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_API_KEY}}
1715

1816
concurrency:
1917
group: ${{ github.workflow }}-${{ github.ref }}

doc/source/conf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@
6565
"version_match": get_version_match(__version__),
6666
},
6767
"use_meilisearch": {
68-
"host": os.getenv("MEILISEARCH_HOST_NAME", ""),
69-
"api_key": os.getenv("MEILISEARCH_API_KEY", ""),
7068
"index_uids": {
7169
"ansys-ansys-sphinx-theme-sphinx-docs": "ansys-sphinx-theme",
7270
"pyansys-docs-all-public": "PyAnsys",

doc/source/user_guide/options.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ For example:
2525
"show_prev_next": False,
2626
"show_breadcrumbs": True,
2727
"additional_breadcrumbs": [
28-
("Ansys", "https://www.ansys.com/"),
29-
],
28+
("Ansys", "https://www.ansys.com/"),
29+
],
3030
}
3131
3232
When you are on the documentation's homepage, the breadcrumb shows the homepage
@@ -118,10 +118,12 @@ This dictionary should contain the following keys:
118118
#. ``host``: The host name of your MeiliSearch instance. It is hosted at
119119
https://search.pyansys.com on port 443 (default).
120120
You can set this to an environment variable using
121-
``os.getenv()`` for added security.
121+
``os.getenv()`` for added security. If no value is provided, the default
122+
public host for PyAnsys is used.
122123

123124
#. ``api_key``: The API key for your MeiliSearch instance.
124-
You can also set this to an environment variable using ``os.getenv()``.
125+
You can also set this to an environment variable using ``os.getenv()``. If no
126+
value is provided, the default public API key for PyAnsys is used.
125127

126128
#. ``index_uids``: A dictionary that provides a mapping between the unique
127129
identifier (UID) of an index and its
@@ -155,8 +157,6 @@ Here is the example configuration of using MeiliSearch in
155157
156158
html_theme_options = {
157159
"use_meilisearch": {
158-
"host": os.getenv("MEILISEARCH_HOST_NAME", ""),
159-
"api_key": os.getenv("MEILISEARCH_API_KEY", ""),
160160
"index_uids": {
161161
"ansys-ansys-sphinx-theme-sphinx-docs": "ansys-sphinx-theme",
162162
"pyansys-docs-all-public": "PyAnsys",

src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-field.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,20 @@
1818
<!-- Include the MeiliSearch JavaScript library for the search bar -->
1919
<script src="https://cdn.jsdelivr.net/npm/docs-searchbar.js@latest/dist/cdn/docs-searchbar.min.js"></script>
2020
<script>
21+
// If no credentials provided, use the default ones
22+
{% if not theme_use_meilisearch.host and not theme_use_meilisearch.api_key %}
23+
{% set HOST_URL = "https://search.pyansys.com" %}
24+
{% set API_KEY = "A1Qxly2sls6g1rb1sIKEVEtE7R1UsHad0VgqnvKhD5nhBNf5de" %}
25+
{% else %}
26+
{% set HOST_URL = theme_use_meilisearch.host %}
27+
{% set API_KEY = theme_use_meilisearch.api_key %}
28+
{% endif %}
29+
2130
// Initialize the MeiliSearch bar with the given API key and host
2231
// inspect the first value of index UID as default
2332
let theSearchBar = docsSearchBar({
24-
hostUrl: "{{ theme_use_meilisearch.host }}" ,
25-
apiKey: "{{ theme_use_meilisearch.api_key }}" ,
33+
hostUrl: "{{ HOST_URL }}",
34+
apiKey: "{{ API_KEY }}",
2635
indexUid: "{{ theme_use_meilisearch.index_uids.items()|first|first }}",
2736
inputSelector: '#search-bar-input, #indexUidSelector',
2837
enableDarkMode: 'auto',

src/ansys_sphinx_theme/theme/ansys_sphinx_theme/theme.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ hidden_icons =
1212
additional_breadcrumbs =
1313
use_edit_page_button = True
1414
switcher =
15-
use_meilisearch=
15+
use_meilisearch =

0 commit comments

Comments
 (0)