Skip to content

Commit

Permalink
Merge pull request #46 from yunu7067/develop
Browse files Browse the repository at this point in the history
v1.0.11
  • Loading branch information
yunu7067 authored Oct 18, 2022
2 parents ecf9cda + d059b2f commit bf1d3ac
Show file tree
Hide file tree
Showing 15 changed files with 213 additions and 96 deletions.
19 changes: 11 additions & 8 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ import tailwind from '@astrojs/tailwind';
import image from '@astrojs/image';
import sitemap from '@astrojs/sitemap';
import mdx from '@astrojs/mdx';
import {remarkMath, remarkReadingTime, rehypeKatex, rehypeFigure} from './plugins';
import {
remarkMath,
remarkReadingTime,
remarkCodeTitle,
rehypeKatex,
rehypeFigure,
rehypeAutolinkHeading,
} from './plugins';

// https://astro.build/config
export default defineConfig({
vite: {
ssr: {
external: ['http-cache-semantics', 'image-size', 'mime'],
},
},
vite: {},
site: 'https://yunu7067.example.com', // sitemap
markdown: {
// Applied to .md and .mdx files
extendDefaultPlugins: true,
remarkPlugins: [remarkReadingTime, remarkMath],
rehypePlugins: [rehypeKatex, rehypeFigure],
remarkPlugins: [remarkReadingTime, remarkMath, remarkCodeTitle],
rehypePlugins: [rehypeAutolinkHeading, rehypeKatex, rehypeFigure],
syntaxHighlight: 'shiki',
shikiConfig: {
// https://github.com/shikijs/shiki/blob/main/docs/themes.md#theming-with-css-variables
Expand Down
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,24 @@
"astro": "astro"
},
"devDependencies": {
"@astrojs/image": "0.9.2",
"@astrojs/image": "0.10.0",
"@astrojs/mdx": "^0.11.4",
"@astrojs/rss": "^1.0.2",
"@astrojs/sitemap": "1.0.0",
"@astrojs/solid-js": "1.1.1",
"@astrojs/tailwind": "2.0.2",
"@astrojs/solid-js": "1.2.0",
"@astrojs/tailwind": "2.1.0",
"@tailwindcss/line-clamp": "0.4.2",
"@types/eslint": "^8.4.6",
"@types/flexsearch": "^0.7.3",
"@types/node": "^18.8.1",
"@types/prettier": "^2.7.1",
"astro": "1.4.6",
"astro": "1.5.0",
"flexsearch": "^0.7.21",
"hastscript": "^7.0.2",
"http-cache-semantics": "^4.1.0",
"image-size": "^1.0.2",
"mdast-util-to-string": "^3.1.0",
"mime": "^3.0.0",
"node-html-parser": "6.1.1",
"reading-time": "1.5.0",
"rehype-autolink-headings": "^6.1.1",
"rehype-katex": "^6.0.2",
"remark-math": "^5.1.1",
"sass": "1.55.0",
Expand Down
3 changes: 3 additions & 0 deletions plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* Remark Plugins */
export {default as remarkMath} from 'remark-math';
export * from './remark-reading-time.mjs';
export {remarkCodeTitle} from './remark-code-title.mjs';

/* Rehype Plugins */
export {default as rehypeKatex} from 'rehype-katex';
export * from './rehype-figure.mjs';
export * from './rehype-autolink-heading.mjs';
15 changes: 15 additions & 0 deletions plugins/rehype-autolink-heading.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {s} from 'hastscript';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';

export const rehypeAutolinkHeading = [
rehypeAutolinkHeadings,
{
behavior: 'prepend',
content: s(
`svg`,
{width: '0.875em', height: '0.875em', viewBox: `0 0 24 24`},
s(`path`, {fill: `none`, d: 'M0 0h24v24H0z'}),
s(`path`, {fill: `currentColor`, d: 'M17 11V4h2v17h-2v-8H7v8H5V4h2v7z'}),
),
},
];
32 changes: 32 additions & 0 deletions plugins/remark-code-title.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {visit} from 'unist-util-visit';

/**
* @author https://www.npmjs.com/package/remark-code-titles
*/
export function remarkCodeTitle() {
return tree =>
visit(tree, 'code', (node, index) => {
const nodeLang = node.lang || '';
let language = '',
title = '';

if (nodeLang.includes(':')) {
language = nodeLang.slice(0, nodeLang.search(':'));
title = nodeLang.slice(nodeLang.search(':') + 1, nodeLang.length);
}

if (!title) {
return;
}

const className = 'remark-code-title';

const titleNode = {
type: 'html',
value: `<div class="${className}">${title}</div>`.trim(),
};

tree.children.splice(index, 0, titleNode);
node.lang = language;
});
}
76 changes: 51 additions & 25 deletions pnpm-lock.yaml

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

1 change: 1 addition & 0 deletions public/heading.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export default function Search({keys}: {keys: string[]}) {
>
<SearchLine width='20' height='20' />
</label>
<p class='mb-5'>(검색 필드: title, description, tags)</p>
</div>

<output>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/p/markdown-syntax/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Tables aren't part of the core Markdown spec, but Hugo supports supports them ou

#### Code block with backticks

```html
```html:Example.html
<!DOCTYPE html>
<html lang="en">
<head>
Expand Down
25 changes: 14 additions & 11 deletions src/pages/page/[...page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import BlogPostPreview from '$coms/PostPreview.astro';
import Pagination from '$coms/Pagination.astro';
import config from '$config';
import MainLayout from '$lays/MainLayout.astro';
import BlogPreview from '$coms/BlogPreview.astro';
export async function getStaticPaths({paginate}: GetStaticPathsOptions) {
const allPosts = await Astro.glob('../p/**/*.{md,mdx}');
Expand Down Expand Up @@ -44,18 +45,20 @@ const props = {
wide={props.wide}
>
<main class='w-full'>
<div class='max-w-3xl w-full mx-auto'>
<main class=''>
<h2 class='mt-8 mb-1 text-5xl tracking-tight text-center'>All Posts</h2>
<small class='block text-base text-center mb-6'
>{page.start + 1}{page.end + 1} of {page.total}
</small>
{page.data.map(post => <BlogPostPreview post={post} />)}
</main>
{/* Hero */}
<div class='pt-[88px] flex flex-col'>
<div class='max-w-3xl w-full mx-auto px-5 pt-8 pb-24'>
<span class='text-lg text-gray-600'></span>
<h1 class='text-6xl font-bold leading-relaxed'>All Posts</h1>
<h2 class='text-2xl leading-normal text-gray-600'>
{page.start + 1}{page.end + 1} of {page.total}
</h2>
</div>
</div>
<div class='max-w-3xl w-full mx-auto px-5 py-4'>
<BlogPreview posts={page.data} />

<footer>
<Pagination prevUrl={page.url.prev} nextUrl={page.url.next} />
</footer>
<Pagination prevUrl={page.url.prev} nextUrl={page.url.next} />
</div>
</main>
</MainLayout>
Loading

0 comments on commit bf1d3ac

Please sign in to comment.