khoj/src/interface/web
Debanjum Singh Solanky 9f2c02d9f7 Chat with the default agent by default from web app home
Had temporarily updated the default selected agent to last used.
Revert for now as
1. The previous logic was buggy. It didn't select the default agent
   even when the last used agent was the default agent. Which would
   require more work.
2. It maybe too early anyway to set the default agent to last used.
2024-10-23 03:43:57 -07:00
..
.husky Throw warning on prettier formatting issues in web app 2024-08-05 03:58:20 +05:30
app Chat with the default agent by default from web app home 2024-10-23 03:43:57 -07:00
components/ui Format next.js web app with prettier 2024-08-05 04:59:06 +05:30
lib Format next.js web app with prettier 2024-08-05 04:59:06 +05:30
public Add OpenGraph metadata to web app pages for improve social share links 2024-08-10 18:14:05 +05:30
.env.development Add developer support for using next.js to serve generated static files (#814) 2024-06-22 20:12:41 +05:30
.env.production Add developer support for using next.js to serve generated static files (#814) 2024-06-22 20:12:41 +05:30
.eslintrc.json Throw warning on prettier formatting issues in web app 2024-08-05 03:58:20 +05:30
.gitignore Add developer support for using next.js to serve generated static files (#814) 2024-06-22 20:12:41 +05:30
components.json Add a fact checker feature with updated styling (#835) 2024-06-27 18:45:38 +05:30
image-loader.ts Nav Menu Upgrades and Minor UX Improvements (#869) 2024-07-27 14:12:00 +05:30
next.config.mjs Load static assets from Khoj server in dev environment 2024-08-04 04:25:48 +05:30
package.json Generate dynamic diagrams (via Excalidraw) (#940) 2024-10-22 16:13:46 -07:00
postcss.config.js Add a fact checker feature with updated styling (#835) 2024-06-27 18:45:38 +05:30
README.md Add developer support for using next.js to serve generated static files (#814) 2024-06-22 20:12:41 +05:30
tailwind.config.ts Add card to connect Whatsapp to Khoj on settings page 2024-07-30 15:25:14 +05:30
tsconfig.json Make most major changes for an updated chat UI (#843) 2024-07-14 23:18:06 +05:30
yarn.lock Generate dynamic diagrams (via Excalidraw) (#940) 2024-10-22 16:13:46 -07:00

This is a Next.js project.

Getting Started

First, install the dependencies:

yarn install

In case you run into any dependency linking issues, you can try running:

yarn add next

Run the development server:

yarn dev

Make sure the rewrites in next.config.mjs are set up correctly for your environment. The rewrites are used to proxy requests to the API server.

    rewrites: async () => {
        return [
            {
                source: '/api/:path*',
                destination: 'http://localhost:42110/api/:path*',
            },
        ];
    },

The destination should be the URL of the API server.

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying any of the .tsx pages. The page auto-updates as you edit the file.

Testing built files

We've setup a utility command for building and serving the built files. This is useful for testing the production build locally.

  1. Exporting code To build the files once and serve them, run:
yarn export

If you're using Windows:

yarn windowsexport
  1. Continuously building code

To keep building the files and serving them, run:

yarn watch

If you're using Windows:

yarn windowswatch

Now you should be able to load your custom pages from the Khoj app at http://localhost:42110/. To server any of the built files, you should update the routes in the web_client.py like so, where new_file is the new page you've added in this repo:

@web_client.post("/new_route", response_class=FileResponse)
@requires(["authenticated"], redirect="login_page")
def index_post(request: Request):

    return templates.TemplateResponse(
        "new_file/index.html",
        context={
            "request": request,
        },
    )

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!