diff --git a/mdsvex.config.js b/mdsvex.config.js deleted file mode 100644 index 5576a98..0000000 --- a/mdsvex.config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - extensions: ['.md'] -}; diff --git a/src/lib/components/HoverIcon.svelte b/src/lib/components/HoverIcon.svelte index 7fbff3c..58d0bc0 100644 --- a/src/lib/components/HoverIcon.svelte +++ b/src/lib/components/HoverIcon.svelte @@ -4,29 +4,35 @@ let className: string = ''; export { className as class }; export let src: string | null = null; - export let text: string; + export let alt: string | undefined = undefined; export let size: number = 32; export let black: boolean = false; - let isUrl; - $: isUrl = src?.startsWith('/') || src?.startsWith('http'); + function isUrl(src?: string) { + return src?.startsWith('/') || src?.startsWith('http'); + } -
+ {#if src} - {#if isUrl} - {text} + {#if isUrl(src)} + {:else} {/if} {:else} - {text} + {alt ?? 'Без иконки'} {/if} -
+ diff --git a/src/lib/components/MdsvexLayout.svelte b/src/lib/components/MdsvexLayout.svelte new file mode 100644 index 0000000..061e2b2 --- /dev/null +++ b/src/lib/components/MdsvexLayout.svelte @@ -0,0 +1,11 @@ + + + + +{@render children()} diff --git a/src/lib/components/NavBar.svelte b/src/lib/components/NavBar.svelte index 3316ee0..84e5596 100644 --- a/src/lib/components/NavBar.svelte +++ b/src/lib/components/NavBar.svelte @@ -20,7 +20,7 @@ diff --git a/src/lib/components/SocialButton.svelte b/src/lib/components/SocialButton.svelte index f12be28..b18df8b 100644 --- a/src/lib/components/SocialButton.svelte +++ b/src/lib/components/SocialButton.svelte @@ -14,7 +14,7 @@ target={isLinkLocal(href) ? '_self' : '_blank'} >
- +
= 40rem', false); - + - + diff --git a/src/lib/components/WarningBlock.svelte b/src/lib/components/WarningBlock.svelte index e76765c..50c9cf5 100644 --- a/src/lib/components/WarningBlock.svelte +++ b/src/lib/components/WarningBlock.svelte @@ -3,8 +3,8 @@ diff --git a/src/lib/util/LinkResolver.ts b/src/lib/util/LinkResolver.ts index 23e1814..b942ba1 100644 --- a/src/lib/util/LinkResolver.ts +++ b/src/lib/util/LinkResolver.ts @@ -1,3 +1,4 @@ +// TODO: чашки на иконках выглядят страшненько, пока что пусть лучше будет голая ссылка const icons: Record = { none: 'material-symbols:link', 'steamcommunity.com': 'simple-icons:steam', @@ -12,10 +13,10 @@ const icons: Record = { 'bsky.social': 'simple-icons:bluesky', // https://хамяк.рф 'xn--80auf8a2c.xn--p1ai': 'fluent-emoji-high-contrast:hamster', - 'teasanctuary.ru': '/icons/tea-sanctuary-white.svg', + // 'teasanctuary.ru': '/icons/tea-sanctuary-white.svg', 'hl.teasanctuary.ru': '/icons/half-life.svg', 'git.teasanctuary.ru': 'devicon-plain:git', - localhost: '/icons/tea-sanctuary-white.svg', + // localhost: '/icons/tea-sanctuary-white.svg', email: 'material-symbols:alternate-email', rss: 'material-symbols:rss-feed' }; diff --git a/src/routes/blog/[slug]/+page.svelte b/src/routes/blog/[slug]/+page.svelte index b143f3e..4679b12 100644 --- a/src/routes/blog/[slug]/+page.svelte +++ b/src/routes/blog/[slug]/+page.svelte @@ -72,18 +72,17 @@
diff --git a/svelte.config.js b/svelte.config.js index ebf0dc8..8bcc2c3 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,8 +1,13 @@ import adapter from '@sveltejs/adapter-static'; import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; import { mdsvex } from 'mdsvex'; -import mdsvexConfig from './mdsvex.config.js'; import autoImport from 'sveltekit-autoimport'; +import { join, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +// https://flaviocopes.com/fix-dirname-not-defined-es-module-scope/ +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); /** @type {import('@sveltejs/kit').Config} */ const config = { @@ -34,7 +39,10 @@ const config = { extensions: ['.svelte', '.md'], preprocess: [ vitePreprocess(), - mdsvex(mdsvexConfig), + mdsvex({ + extensions: ['.md'], + layout: join(__dirname, "./src/lib/components/MdsvexLayout.svelte") + }), autoImport({ include: ['**/*.(svelte|md)'], components: ['./src/lib/components/', { name: './src' }]