Răsfoiți Sursa

put documentation into separate file

Rodja Trappe 1 an în urmă
părinte
comite
f9a9a3ca53
3 a modificat fișierele cu 21 adăugiri și 18 ștergeri
  1. 1 0
      main.py
  2. 8 18
      search.vue
  3. 12 0
      website/static/documentation_index.json

+ 1 - 0
main.py

@@ -34,6 +34,7 @@ app.add_middleware(SessionMiddleware, secret_key=os.environ.get('NICEGUI_SECRET_
 
 
 app.add_static_files('/favicon', str(Path(__file__).parent / 'website' / 'favicon'))
 app.add_static_files('/favicon', str(Path(__file__).parent / 'website' / 'favicon'))
 app.add_static_files('/fonts', str(Path(__file__).parent / 'website' / 'fonts'))
 app.add_static_files('/fonts', str(Path(__file__).parent / 'website' / 'fonts'))
+app.add_static_files('/static', str(Path(__file__).parent / 'website' / 'static'))
 
 
 
 
 @app.get('/logo.png')
 @app.get('/logo.png')

+ 8 - 18
search.vue

@@ -17,19 +17,7 @@ export default {
     return {
     return {
       query: "",
       query: "",
       results: [],
       results: [],
-      documents: [
-        {
-          title: "Introduction",
-          content: "This is the introduction to our documentation...",
-          url: "/docs/introduction",
-        },
-        {
-          title: "Getting Started",
-          content: "Here's how to get started with our project...",
-          url: "/docs/getting_started",
-        },
-        // More documents...
-      ],
+      documents: [],
       fuse: null,
       fuse: null,
     };
     };
   },
   },
@@ -40,22 +28,24 @@ export default {
     },
     },
   },
   },
 
 
-  created() {
+  async created() {
+    let response = await fetch("/static/documentation_index.json");
+    if (!response.ok) {
+      throw new Error(`HTTP error! status: ${response.status}`);
+    }
+    this.documents = await response.json();
     let options = {
     let options = {
       keys: ["title", "content"],
       keys: ["title", "content"],
     };
     };
-
     this.fuse = new Fuse(this.documents, options);
     this.fuse = new Fuse(this.documents, options);
   },
   },
 
 
   methods: {
   methods: {
     search() {
     search() {
       this.results = this.fuse.search(this.query);
       this.results = this.fuse.search(this.query);
-      console.log(this.results);
     },
     },
-
     goTo(url) {
     goTo(url) {
-      this.$router.push(url);
+      window.location.href = url;
     },
     },
   },
   },
 };
 };

+ 12 - 0
website/static/documentation_index.json

@@ -0,0 +1,12 @@
+[
+  {
+    "title": "Introduction",
+    "content": "This is the introduction to our documentation...",
+    "url": "/docs/introduction"
+  },
+  {
+    "title": "Getting Started",
+    "content": "Here's how to get started with our project...",
+    "url": "/docs/getting_started"
+  }
+]