mirror of
https://github.com/sergeyyarkov/yarkov.tech.git
synced 2026-10-11 10:29:21 +03:00
feat: added mdx support
This commit is contained in:
parent
1cbe9ea47e
commit
5cc615307e
@ -5,6 +5,7 @@ import { escape } from "html-escaper";
|
|||||||
import solid from "@astrojs/solid-js";
|
import solid from "@astrojs/solid-js";
|
||||||
import image from "@astrojs/image";
|
import image from "@astrojs/image";
|
||||||
import compress from "astro-compress";
|
import compress from "astro-compress";
|
||||||
|
import mdx from "@astrojs/mdx";
|
||||||
|
|
||||||
const createAnchorLabel = (heading) => {
|
const createAnchorLabel = (heading) => {
|
||||||
const node = h("span.anchor-label", escape(heading));
|
const node = h("span.anchor-label", escape(heading));
|
||||||
@ -22,6 +23,7 @@ export default defineConfig({
|
|||||||
html: false,
|
html: false,
|
||||||
}),
|
}),
|
||||||
image(),
|
image(),
|
||||||
|
mdx(),
|
||||||
],
|
],
|
||||||
markdown: {
|
markdown: {
|
||||||
syntaxHighlight: "prism",
|
syntaxHighlight: "prism",
|
||||||
|
|||||||
1070
package-lock.json
generated
1070
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -19,6 +19,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/image": "^0.3.2",
|
"@astrojs/image": "^0.3.2",
|
||||||
|
"@astrojs/mdx": "^0.7.0",
|
||||||
"@astrojs/solid-js": "^0.4.1",
|
"@astrojs/solid-js": "^0.4.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.32.0",
|
"@typescript-eslint/eslint-plugin": "^5.32.0",
|
||||||
"@typescript-eslint/parser": "^5.32.0",
|
"@typescript-eslint/parser": "^5.32.0",
|
||||||
|
|||||||
@ -6,6 +6,21 @@
|
|||||||
font-size: var(--font-size-lg);
|
font-size: var(--font-size-lg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
& h1,
|
||||||
|
h2,
|
||||||
|
h3,
|
||||||
|
h4,
|
||||||
|
h5,
|
||||||
|
h6 {
|
||||||
|
margin-top: 3rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
padding-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
border-bottom: 1px solid var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
& ul {
|
& ul {
|
||||||
padding-left: 1.5rem;
|
padding-left: 1.5rem;
|
||||||
line-height: var(--line-height-base);
|
line-height: var(--line-height-base);
|
||||||
|
|||||||
14
src/components/Counter/Counter.scss
Normal file
14
src/components/Counter/Counter.scss
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
.counter {
|
||||||
|
margin: 2rem 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
row-gap: 15px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: var(--border-radius-md);
|
||||||
|
padding: 15px 5px;
|
||||||
|
& div {
|
||||||
|
display: flex;
|
||||||
|
column-gap: 3px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,17 +1,45 @@
|
|||||||
import type { Component } from 'solid-js';
|
import type { Component } from "solid-js";
|
||||||
|
|
||||||
import { createSignal, createEffect } from 'solid-js';
|
import { createSignal, createEffect } from "solid-js";
|
||||||
|
import Button from "@components/Button";
|
||||||
|
import "./Counter.scss";
|
||||||
|
|
||||||
const Counter: Component = () => {
|
const Counter: Component<{ tick?: number }> = (props) => {
|
||||||
|
const [isRunned, setIsRunned] = createSignal<boolean>(false);
|
||||||
const [count, setCount] = createSignal<number>(0);
|
const [count, setCount] = createSignal<number>(0);
|
||||||
|
|
||||||
|
const run = () => setIsRunned(true);
|
||||||
|
const stop = () => setIsRunned(false);
|
||||||
|
const inc = () => setCount(count() + 1);
|
||||||
|
const dec = () => setCount(count() - 1);
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
if (isRunned()) {
|
||||||
setCount(count() + 1);
|
setCount(count() + 1);
|
||||||
}, 500);
|
}
|
||||||
|
}, props.tick || 200);
|
||||||
});
|
});
|
||||||
|
|
||||||
return <div>{count()}</div>;
|
return (
|
||||||
|
<div class="counter">
|
||||||
|
<span>{count()}</span>
|
||||||
|
<div>
|
||||||
|
<Button disabled={isRunned()} onClick={run}>
|
||||||
|
Run
|
||||||
|
</Button>
|
||||||
|
<Button disabled={isRunned()} onClick={inc}>
|
||||||
|
+
|
||||||
|
</Button>
|
||||||
|
<Button disabled={isRunned()} onClick={dec}>
|
||||||
|
-
|
||||||
|
</Button>
|
||||||
|
<Button disabled={!isRunned()} onClick={stop}>
|
||||||
|
Stop
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Counter;
|
export default Counter;
|
||||||
|
|||||||
@ -5,18 +5,18 @@ import ArticleLayout from "@layouts/article.astro";
|
|||||||
|
|
||||||
// TODO: generate pages based on user language
|
// TODO: generate pages based on user language
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const data = await Astro.glob<ArticleType>("../../../content/articles/**/*.md");
|
const data = await Astro.glob<ArticleType>("../../../content/articles/**/*.mdx");
|
||||||
return data.map((article) => {
|
return data.map((article) => {
|
||||||
const published_at = new Date(article.frontmatter.published_at).toLocaleDateString("en-CA");
|
const published_at = new Date(article.frontmatter.published_at).toLocaleDateString("en-CA");
|
||||||
const slug = `${published_at}/${article.frontmatter.slug}`;
|
const slug = `${published_at}/${article.frontmatter.slug}`;
|
||||||
const props = { Content: article.Content, frontmatter: article.frontmatter };
|
return { params: { slug }, props: article };
|
||||||
return { params: { slug }, props };
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const { Content, frontmatter: data } = Astro.props as MarkdownInstance<ArticleType>;
|
const article = Astro.props as MarkdownInstance<ArticleType>;
|
||||||
|
const Content = article.default
|
||||||
---
|
---
|
||||||
|
|
||||||
<ArticleLayout content={data}>
|
<ArticleLayout content={article.frontmatter}>
|
||||||
<Content />
|
<Content />
|
||||||
</ArticleLayout>
|
</ArticleLayout>
|
||||||
|
|||||||
@ -5,11 +5,10 @@ import SkillsList from '@components/SkillsList';
|
|||||||
import SkillsBlock from '@components/SkillsBlock';
|
import SkillsBlock from '@components/SkillsBlock';
|
||||||
|
|
||||||
// TODO: import content based on user ui language
|
// TODO: import content based on user ui language
|
||||||
import * as data from '../../content/about/ru/index.md';
|
import { default as Content } from '../../content/about/ru/index.mdx';
|
||||||
import ArticleContent from '@components/ArticleContent';
|
import ArticleContent from '@components/ArticleContent';
|
||||||
|
|
||||||
const { skills } = SITE_METADATA;
|
const { skills } = SITE_METADATA;
|
||||||
const { Content } = data;
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<PageLayout title="Обо мне">
|
<PageLayout title="Обо мне">
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
import PageLayout from '@layouts/default.astro';
|
import PageLayout from "@layouts/default.astro";
|
||||||
import ArticlesList from '@components/ArticlesList';
|
import ArticlesList from "@components/ArticlesList";
|
||||||
import { transformArticles, formatToArticleBlocks } from '@utils/articles';
|
import { transformArticles, formatToArticleBlocks } from "@utils/articles";
|
||||||
|
|
||||||
const articles = await Astro.glob<ArticleType>('../../content/articles/**/*.md');
|
const articles = await Astro.glob<ArticleType>("../../content/articles/**/*.mdx");
|
||||||
const tags = new Set(articles.map((article) => article.frontmatter.tags).flat());
|
const tags = new Set(articles.map((article) => article.frontmatter.tags).flat());
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -14,10 +14,7 @@ const tags = new Set(articles.map((article) => article.frontmatter.tags).flat())
|
|||||||
<section>
|
<section>
|
||||||
<ArticlesList
|
<ArticlesList
|
||||||
client:load
|
client:load
|
||||||
data={{
|
data={{ articles: formatToArticleBlocks(transformArticles(articles)), tags: [...tags] }}
|
||||||
articles: formatToArticleBlocks(transformArticles(articles)),
|
|
||||||
tags: [...tags],
|
|
||||||
}}
|
|
||||||
emptyPlaceholder="Не найдено ни одной статьи..."
|
emptyPlaceholder="Не найдено ни одной статьи..."
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import PageLayout from '@layouts/default.astro';
|
|||||||
import RecentArticles from '@components/RecentArticles';
|
import RecentArticles from '@components/RecentArticles';
|
||||||
import { Splash, SplashHeading, SplashLinks, Link } from '@components/Splash';
|
import { Splash, SplashHeading, SplashLinks, Link } from '@components/Splash';
|
||||||
|
|
||||||
const data = await Astro.glob<ArticleType>('../../content/articles/**/*.md');
|
const data = await Astro.glob<ArticleType>('../../content/articles/**/*.mdx');
|
||||||
const articles = utils.transformArticles(data);
|
const articles = utils.transformArticles(data);
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"types": ["vite/client", "@astrojs/image/client"],
|
"types": ["vite/client", "@astrojs/image/client", "mdx"],
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"jsx": "preserve",
|
"jsx": "preserve",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user