feat: add base path for deploy

This commit is contained in:
2026-08-25 10:36:10 +05:00
parent b296b6fa20
commit 6d770dc642
3 changed files with 18 additions and 4 deletions
+4 -3
View File
@@ -2,6 +2,7 @@
import '../app.css'; import '../app.css';
import favicon from '$lib/assets/favicon.svg'; import favicon from '$lib/assets/favicon.svg';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { resolve } from '$app/paths';
import { getLocale, initLocale, setLocale } from '$lib/i18n/locale.svelte'; import { getLocale, initLocale, setLocale } from '$lib/i18n/locale.svelte';
import { t } from '$lib/i18n/t'; import { t } from '$lib/i18n/t';
import { LOCALES, type Locale } from '$lib/i18n/dict'; import { LOCALES, type Locale } from '$lib/i18n/dict';
@@ -19,10 +20,10 @@
<div class="app"> <div class="app">
<header> <header>
<a href="/" class="brand">easy-png-tools</a> <a href={resolve('/')} class="brand">easy-png-tools</a>
<nav aria-label={t('header.sectionsAria')}> <nav aria-label={t('header.sectionsAria')}>
<a class="nav-link workspace-link" href="/">{t('header.workspace')}</a> <a class="nav-link workspace-link" href={resolve('/')}>{t('header.workspace')}</a>
<a class="nav-link" href="/list-tools">{t('header.catalog')}</a> <a class="nav-link" href={resolve('/list-tools')}>{t('header.catalog')}</a>
<div class="lang-switch" role="group" aria-label="Language / Язык"> <div class="lang-switch" role="group" aria-label="Language / Язык">
{#each LOCALES as l (l)} {#each LOCALES as l (l)}
<button <button
+2 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts"> <script lang="ts">
import { CATEGORIES } from '$lib/categories'; import { CATEGORIES } from '$lib/categories';
import { resolve } from '$app/paths';
import { t } from '$lib/i18n/t'; import { t } from '$lib/i18n/t';
import { toolDescription, toolTitle } from '$lib/i18n/tool-strings'; import { toolDescription, toolTitle } from '$lib/i18n/tool-strings';
import ToolCard from '$lib/components/search/ToolCard.svelte'; import ToolCard from '$lib/components/search/ToolCard.svelte';
@@ -26,7 +27,7 @@
toolId={tool.id} toolId={tool.id}
title={toolTitle(tool)} title={toolTitle(tool)}
description={toolDescription(tool)} description={toolDescription(tool)}
href="/tools/{tool.id}" href={resolve(`/tools/${tool.id}`)}
/> />
</div> </div>
{/each} {/each}
+12
View File
@@ -2,12 +2,24 @@ import adapter from '@sveltejs/adapter-static';
import { sveltekit } from '@sveltejs/kit/vite'; import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
declare const process: { env: Record<string, string | undefined> };
const rawBase = (process.env.BASE_PATH ?? '').trim();
const base: '' | `/${string}` =
rawBase === '' || rawBase === '/'
? ''
: (`/${rawBase.replace(/^\/+/, '').replace(/\/+$/, '')}` as `/${string}`);
export default defineConfig({ export default defineConfig({
ssr: { ssr: {
noExternal: ['@lucide/svelte'] noExternal: ['@lucide/svelte']
}, },
plugins: [ plugins: [
sveltekit({ sveltekit({
paths: {
base
},
compilerOptions: { compilerOptions: {
// Force runes mode for the project, except for libraries. Can be removed in svelte 6. // Force runes mode for the project, except for libraries. Can be removed in svelte 6.
runes: ({ filename }) => runes: ({ filename }) =>