This commit is contained in:
Sergey Yarkov 2023-10-05 21:23:11 +03:00
parent df1d7ea0be
commit 2d03b0c484
No known key found for this signature in database
GPG Key ID: E91CE1FABC619B6F
21 changed files with 3325 additions and 2655 deletions

View File

@ -5,7 +5,6 @@ import { defineConfig } from "astro/config";
*/ */
import sitemap from "@astrojs/sitemap"; import sitemap from "@astrojs/sitemap";
import solidJs from "@astrojs/solid-js"; import solidJs from "@astrojs/solid-js";
import image from "@astrojs/image";
import netlifyCMS from "astro-netlify-cms"; import netlifyCMS from "astro-netlify-cms";
/** /**
@ -394,9 +393,6 @@ export default defineConfig({
], ],
}, },
}), }),
image({
serviceEntryPoint: "@astrojs/image/sharp",
}),
], ],
markdown: { markdown: {
syntaxHighlight: "prism", syntaxHighlight: "prism",
@ -442,4 +438,5 @@ export default defineConfig({
], ],
}, },
trailingSlash: "ignore", trailingSlash: "ignore",
scopedStyleStrategy: "where",
}); });

View File

@ -1,4 +1,4 @@
import { Handler } from "@netlify/functions"; import type { Handler } from "@netlify/functions";
import { redisClient } from "../../redis"; import { redisClient } from "../../redis";
const getViewsBySlug = async (slug: string): Promise<number> => { const getViewsBySlug = async (slug: string): Promise<number> => {

5835
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,6 @@
"email": "serzh.yarkov@gmail.com", "email": "serzh.yarkov@gmail.com",
"url": "https://yarkov.tech" "url": "https://yarkov.tech"
}, },
"type": "module",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"dev": "astro dev", "dev": "astro dev",
@ -18,28 +17,27 @@
"astro": "astro" "astro": "astro"
}, },
"dependencies": { "dependencies": {
"@astrojs/image": "^0.16.9", "@astrojs/rss": "^3.0.0",
"@astrojs/rss": "^2.4.3", "@astrojs/sitemap": "^3.0.0",
"@astrojs/sitemap": "^1.3.1", "@astrojs/solid-js": "^3.0.1",
"@astrojs/solid-js": "^2.2.0", "@netlify/functions": "^2.1.0",
"@netlify/functions": "^1.6.0", "@sindresorhus/slugify": "^2.2.1",
"@sindresorhus/slugify": "^2.2.0", "astro": "^3.2.0",
"astro": "^2.5.5", "astro-icon": "^0.8.1",
"astro-icon": "^0.8.0", "astro-netlify-cms": "^0.5.4",
"astro-netlify-cms": "^0.5.3", "hast-util-to-string": "^3.0.0",
"hast-util-to-string": "^2.0.0", "hastscript": "^8.0.0",
"hastscript": "^7.2.0",
"html-escaper": "^3.0.3", "html-escaper": "^3.0.3",
"ioredis": "^5.3.2", "ioredis": "^5.3.2",
"mime-types": "^2.1.35", "mime-types": "^2.1.35",
"quicklink": "^2.3.0", "quicklink": "^2.3.0",
"rehype-autolink-headings": "^6.1.1", "rehype-autolink-headings": "^7.0.0",
"rehype-slug": "^5.1.0", "rehype-slug": "^6.0.0",
"sharp": "^0.31.0", "sharp": "^0.32.6",
"solid-js": "^1.7.5" "solid-js": "^1.7.12"
}, },
"devDependencies": { "devDependencies": {
"@types/mime-types": "^2.1.1", "@types/mime-types": "^2.1.2",
"sass": "^1.62.1" "sass": "^1.68.0"
} }
} }

View File

@ -1,5 +1,5 @@
--- ---
import { Picture } from "@astrojs/image/components"; import { Image } from "astro:assets";
export interface Props { export interface Props {
src: string; src: string;
@ -10,18 +10,15 @@ const { src, alt } = Astro.props as Props;
--- ---
<div class="cover"> <div class="cover">
<figure> <Image
<Picture
itemprop="image" itemprop="image"
src={src} src={src}
width={700}
height={400}
sizes="(max-width: 450px) 450px, 700px" sizes="(max-width: 450px) 450px, 700px"
widths={[450, 700]} format="webp"
formats={["webp"]}
aspectRatio={"16:9"}
alt={alt ? alt : ""} alt={alt ? alt : ""}
background={"chocolate"}
/> />
</figure>
</div> </div>
<style lang="scss"> <style lang="scss">

View File

@ -55,7 +55,7 @@ const t = useTranslation(Astro);
</div> </div>
<div class="published"> <div class="published">
<time itemprop="datePublished" datetime={pubDate.toString()}> <time itemprop="datePublished" datetime={pubDate.toString()}>
{createDateFormatter(pageLang).format(pubDate)} {createDateFormatter(pageLang).format(pubDate)}&nbsp;
</time> </time>
<span itemprop="author">{author}</span> <span itemprop="author">{author}</span>
</div> </div>
@ -72,7 +72,7 @@ const t = useTranslation(Astro);
</article> </article>
<script define:vars={{ slug, IS_DEV: import.meta.env.DEV }}> <script define:vars={{ slug, IS_DEV: import.meta.env.DEV }}>
(async () => { (async () => {
if (IS_DEV) return; if (IS_DEV) return;
const response = await fetch(`/api/views?slug=${slug}`, { method: "POST" }); const response = await fetch(`/api/views?slug=${slug}`, { method: "POST" });
if (!response.ok) return; if (!response.ok) return;
@ -80,7 +80,7 @@ const t = useTranslation(Astro);
const $views = document.getElementById("views"); const $views = document.getElementById("views");
if (isNaN(parseInt(views, 10))) return; if (isNaN(parseInt(views, 10))) return;
if ($views) $views.textContent = views; if ($views) $views.textContent = views;
})(); })();
</script> </script>
<style lang="scss" is:global> <style lang="scss" is:global>

View File

@ -1,6 +1,6 @@
--- ---
export type Props = astroHTML.JSX.ButtonHTMLAttributes; export type Props = astroHTML.JSX.ButtonHTMLAttributes;
const attrs = Astro.props as Props; const attrs = Astro.props;
--- ---
<button {...attrs}> <button {...attrs}>

View File

@ -48,7 +48,7 @@ const t = useTranslation(Astro);
rows={10} rows={10}
required></textarea> required></textarea>
<div class="footer"> <div class="footer">
<Button type="submit"> <Button type={"submit"}>
<UIString key={"btn.submit"} /> <UIString key={"btn.submit"} />
</Button> </Button>
</div> </div>

View File

@ -1,9 +1,7 @@
--- ---
import { DEFAULT_LANGUAGE } from "@root/constants";
import { getLanguageFromURL } from "@i18n/utils";
import { Icon } from "astro-icon"; import { Icon } from "astro-icon";
import type { CollectionEntry } from "astro:content"; import type { CollectionEntry } from "astro:content";
// import UIString from "../UIString"; import UIString from "@components/UIString.astro";
export interface Props { export interface Props {
data: CollectionEntry<"projects">["data"]; data: CollectionEntry<"projects">["data"];
@ -29,14 +27,14 @@ const { icon, title, year, description, articleUrl, sourceUrl, demoUrl } = data;
{ {
articleUrl && ( articleUrl && (
<a class="btn-link" href={articleUrl} target="_blank"> <a class="btn-link" href={articleUrl} target="_blank">
Статья <UIString key={'btn.article'} />
</a> </a>
) )
} }
{ {
sourceUrl && ( sourceUrl && (
<a class="btn-link" href={sourceUrl} target="_blank"> <a class="btn-link" href={sourceUrl} target="_blank">
Исходник <UIString key={'btn.sourceCode'} />
<Icon name="link-out" width="15" height="15" /> <Icon name="link-out" width="15" height="15" />
</a> </a>
) )
@ -44,7 +42,7 @@ const { icon, title, year, description, articleUrl, sourceUrl, demoUrl } = data;
{ {
demoUrl && ( demoUrl && (
<a class="btn-link" href={demoUrl} target="_blank"> <a class="btn-link" href={demoUrl} target="_blank">
Демо <UIString key={'btn.demo'} />
<Icon name="link-out" width="15" height="15" /> <Icon name="link-out" width="15" height="15" />
</a> </a>
) )

3
src/env.d.ts vendored
View File

@ -1,2 +1,3 @@
/// <reference path="../.astro/types.d.ts" /> /// <reference path="../.astro/types.d.ts" />
/// <reference types="@astrojs/image/client" /> /// <reference types="@astrojs/client" />
/// <reference types="vite/client" />

View File

@ -1,5 +1,5 @@
--- ---
import NotFound from "@templates/NotFound.astro"; import NotFoundPage from "@templates/NotFound.astro";
--- ---
<NotFound /> <NotFoundPage />

View File

@ -1,7 +1,7 @@
--- ---
import { getLanguageKeys } from "@i18n/utils"; import { getLanguageKeys } from "@i18n/utils";
import { DEFAULT_LANGUAGE } from "@root/constants"; import { DEFAULT_LANGUAGE } from "@root/constants";
import About from "@templates/About.astro"; import AboutTemplate from "@templates/About.astro";
// TODO: do not generate pages without required data // TODO: do not generate pages without required data
export function getStaticPaths() { export function getStaticPaths() {
@ -11,4 +11,4 @@ export function getStaticPaths() {
} }
--- ---
<About /> <AboutTemplate />

View File

@ -1,7 +1,7 @@
--- ---
import { getLanguageKeys } from "@i18n/utils"; import { getLanguageKeys } from "@i18n/utils";
import { DEFAULT_LANGUAGE } from "@root/constants"; import { DEFAULT_LANGUAGE } from "@root/constants";
import Articles from "@templates/Articles.astro"; import ArticlesTemplate from "@templates/Articles.astro";
export function getStaticPaths() { export function getStaticPaths() {
return getLanguageKeys() return getLanguageKeys()
@ -10,4 +10,4 @@ export function getStaticPaths() {
} }
--- ---
<Articles /> <ArticlesTemplate />

View File

@ -1,7 +1,7 @@
--- ---
import { getLanguageKeys } from "@i18n/utils"; import { getLanguageKeys } from "@i18n/utils";
import { DEFAULT_LANGUAGE } from "@root/constants"; import { DEFAULT_LANGUAGE } from "@root/constants";
import Contacts from "@templates/Contacts.astro"; import ContactsTemplate from "@templates/Contacts.astro";
export function getStaticPaths() { export function getStaticPaths() {
return getLanguageKeys() return getLanguageKeys()
@ -10,4 +10,4 @@ export function getStaticPaths() {
} }
--- ---
<Contacts /> <ContactsTemplate />

View File

@ -1,7 +1,7 @@
--- ---
import { getLanguageKeys } from "@i18n/utils"; import { getLanguageKeys } from "@i18n/utils";
import { DEFAULT_LANGUAGE } from "@root/constants"; import { DEFAULT_LANGUAGE } from "@root/constants";
import Home from "@templates/Home.astro"; import HomeTemplate from "@templates/Home.astro";
export function getStaticPaths() { export function getStaticPaths() {
return getLanguageKeys() return getLanguageKeys()
@ -10,4 +10,4 @@ export function getStaticPaths() {
} }
--- ---
<Home /> <HomeTemplate />

View File

@ -1,7 +1,7 @@
--- ---
import { getLanguageKeys } from "@i18n/utils"; import { getLanguageKeys } from "@i18n/utils";
import { DEFAULT_LANGUAGE } from "@root/constants"; import { DEFAULT_LANGUAGE } from "@root/constants";
import Projects from "@templates/Projects.astro"; import ProjectsTemplate from "@templates/Projects.astro";
export function getStaticPaths() { export function getStaticPaths() {
return getLanguageKeys() return getLanguageKeys()
@ -10,4 +10,4 @@ export function getStaticPaths() {
} }
--- ---
<Projects /> <ProjectsTemplate />

View File

@ -1,5 +1,5 @@
--- ---
import About from "@templates/About.astro"; import AboutPage from "@templates/About.astro";
--- ---
<About /> <AboutPage />

View File

@ -1,5 +1,5 @@
--- ---
import Articles from "@templates/Articles.astro"; import ArticlesPage from "@templates/Articles.astro";
--- ---
<Articles /> <ArticlesPage />

View File

@ -1,5 +1,5 @@
--- ---
import Contacts from "@root/templates/Contacts.astro"; import ContactsPage from "@root/templates/Contacts.astro";
--- ---
<Contacts /> <ContactsPage />

View File

@ -1,5 +1,5 @@
--- ---
import Projects from "@root/templates/Projects.astro"; import ProjectsPage from "@root/templates/Projects.astro";
--- ---
<Projects /> <ProjectsPage />

View File

@ -5,7 +5,7 @@ import { createRelativeArticleUrl } from "@root/utils";
import * as utils from "@i18n/utils"; import * as utils from "@i18n/utils";
// TODO: generate feed for RU, EN, ... languages // TODO: generate feed for RU, EN, ... languages
export async function get() { export async function GET() {
const articles = await getCollection("blog", (e) => !e.data.draft); const articles = await getCollection("blog", (e) => !e.data.draft);
return rss({ return rss({
title: SITE_METADATA.name, title: SITE_METADATA.name,