Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions web-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions web-app/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"type": "module",
"name": "vite-app ready",
"version": "0.0.0",
"private": true,
Expand Down Expand Up @@ -60,6 +61,7 @@
"prettier": "^3.0.3",
"start-server-and-test": "^2.0.1",
"vite": "^4.4.11",
"vite-plugin-sitemap": "^0.7.1",
"vitest": "^0.34.6"
}
}
2 changes: 0 additions & 2 deletions web-app/public/robots.txt

This file was deleted.

50 changes: 48 additions & 2 deletions web-app/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,58 @@
import { fileURLToPath, URL } from 'node:url'

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

// Static routes
const staticRoutes = [
'/',
'/about',
'/faq',
'/privacy',
'/branding',
'/guide',
'/dashboard',
'/extensions/smartapi',
'/extensions/x-bte',
'/extensions/x-translator?',
'/registry',
'/registry/translator',
'/documentation/getting-started',
'/documentation/smartapi-extensions',
'/documentation/openapi-specification',
'/ui', // For routes like /ui/:smartapi_id
'/editor',
]

// Fetch dynamic slugs asynchronously
async function fetchDynamicRoutes() {
try {
const response = await axios.get('https://smart-api.info/api/query?&q=__all__&fields=_id&size=1000&raw=1')
const dynamicRoutes = response.data.hits.map(item => `/ui/${item._id}`) // Only return URLs as strings
console.log('Fetched dynamic routes:', dynamicRoutes) // Log the dynamic routes
return dynamicRoutes
} catch (error) {
console.error('Error fetching dynamic routes:', error)
return [] // Return an empty array in case of error
}
}

// Fetch dynamic routes before config execution
const routes = await fetchDynamicRoutes()

// Combine static and dynamic routes
const dynamicRoutes = [...staticRoutes, ...routes]

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
Sitemap({
hostname: 'https://www.smart-api.info',
readable: true,
changefreq: 'monthly',
dynamicRoutes // Provide the combined routes as an array of strings
})
],
resolve: {
alias: {
Expand Down