initial environment setup

This commit is contained in:
radishzzz 2025-01-13 02:50:27 +00:00
commit 9d2be2a82e
15 changed files with 13276 additions and 0 deletions

24
.gitignore vendored Normal file
View file

@ -0,0 +1,24 @@
# build output
dist/
# generated types
.astro/
# dependencies
node_modules/
# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# environment variables
.env
.env.production
# macOS-specific files
.DS_Store
# jetbrains setting folder
.idea/

4
.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}

11
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}

77
astro.config.ts Normal file
View file

@ -0,0 +1,77 @@
import mdx from '@astrojs/mdx'
import sitemap from '@astrojs/sitemap'
import swup from '@swup/astro'
import compress from 'astro-compress'
import robotsTxt from 'astro-robots-txt'
import { defineConfig } from 'astro/config'
import rehypeAutolinkHeadings from 'rehype-autolink-headings'
import rehypeKatex from 'rehype-katex'
import rehypeSlug from 'rehype-slug'
import remarkMath from 'remark-math'
import UnoCSS from 'unocss/astro'
import { themeConfig } from './src/config'
export default defineConfig({
site: themeConfig.site.url,
base: '/',
trailingSlash: 'always', // whether the URL ends with a slash
markdown: {
remarkPlugins: [remarkMath],
rehypePlugins: [
rehypeKatex,
rehypeSlug,
[rehypeAutolinkHeadings, {
behavior: 'append',
properties: {
className: ['anchor'],
},
content: {
type: 'element',
tagName: 'span',
properties: {
'className': ['anchor-icon'],
'data-pagefind-ignore': true,
},
children: [
{
type: 'text',
value: '#',
},
],
},
}],
],
shikiConfig: {
theme: 'github-dark',
wrap: true,
},
},
integrations: [
UnoCSS({
injectReset: true,
}),
mdx(),
sitemap(),
robotsTxt(),
compress({
CSS: true,
HTML: true,
Image: true,
JavaScript: true,
SVG: true,
}),
swup({
theme: false,
animationClass: 'transition-swup-',
cache: true,
preload: true,
accessibility: true,
smoothScrolling: true,
updateHead: true,
updateBodyClass: true,
}),
],
devToolbar: {
enabled: false,
},
})

15
eslint.config.mjs Normal file
View file

@ -0,0 +1,15 @@
import antfu from '@antfu/eslint-config'
export default antfu(
{
unocss: true,
typescript: true,
astro: true,
rules: {
'style/max-len': 'off',
'no-console': 'warn',
'unocss/order': 'error',
'unocss/order-attributify': 'error',
},
},
)

66
package.json Normal file
View file

@ -0,0 +1,66 @@
{
"name": "astro-theme-retyprset",
"type": "module",
"version": "0.0.1",
"repository": "https://github.com/radishzzz/astro-theme-retypeset",
"scripts": {
"dev": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"format": "eslint . --fix",
"typecheck": "astro check && tsc --noEmit",
"prepare": "git init && npx husky install"
},
"dependencies": {
"@astrojs/check": "^0.9.4",
"@astrojs/mdx": "^4.0.5",
"@astrojs/rss": "^4.0.11",
"@astrojs/sitemap": "^3.2.1",
"@swup/astro": "^1.5.0",
"astro": "^5.1.5",
"astro-compress": "^2.3.6",
"astro-robots-txt": "^1.0.0",
"astro-seo": "^0.8.4",
"overlayscrollbars": "^2.10.1",
"photoswipe": "^5.4.4",
"reading-time": "^1.5.0",
"rehype-autolink-headings": "^7.1.0",
"rehype-components": "^0.3.0",
"rehype-katex": "^7.0.1",
"rehype-slug": "^6.0.0",
"remark-directive": "^3.0.0",
"remark-directive-rehype": "^0.4.2",
"remark-github-admonitions-to-directives": "^2.1.0",
"remark-math": "^6.0.0",
"remark-sectionize": "^2.1.0",
"sanitize-html": "^2.14.0",
"sharp": "^0.33.5",
"typescript": "~5.7.3",
"unist-util-visit": "^5.0.0",
"vite": "^6.0.7"
},
"devDependencies": {
"@antfu/eslint-config": "^3.14.0",
"@types/markdown-it": "^14.1.2",
"@types/node": "^22.10.5",
"@types/sanitize-html": "^2.13.0",
"@unocss/eslint-plugin": "^65.4.0",
"@unocss/preset-attributify": "^65.4.0",
"@unocss/reset": "^65.4.0",
"@unocss/transformer-directives": "^65.4.0",
"astro-eslint-parser": "^1.1.0",
"consola": "^3.3.3",
"eslint": "^9.18.0",
"eslint-plugin-astro": "^1.3.1",
"esno": "^4.8.0",
"lint-staged": "^15.3.0",
"unocss": "^65.4.0",
"unocss-preset-theme": "^0.14.1"
},
"lint-staged": {
"*.{js,ts,jsx,tsx,astro}": "eslint --fix"
}
}

12818
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
<div id="container"></div>

65
src/config/index.ts Normal file
View file

@ -0,0 +1,65 @@
import type { ThemeConfig } from '@/types'
export const themeConfig: ThemeConfig = {
// SITE INFORMATION ---------------------------------------------------------------------------------------- //
site: {
// Choose One to Fill In
title_EN: 'Retypeset', // support English, Spanish, Russian
title_CN: '重新编排', // supports simplified, traditional Chinese, and Japanese
// Choose One to Fill In
subtitle_EN: '', // support English, Spanish, Russian
subtitle_CN: '再现版式之美', // supports simplified, traditional Chinese, and Japanese
// Site URL
url: 'http://localhost:4321/',
// Author name
author: 'radishzz',
// Site Favicon
favicon: 'https://image.radishzz.cc/image/favicon-round-48px.webp',
// Site Language
language: 'zh', // zh | tw | ja | en | es | ru
},
// THEME SETTING ------------------------------------------------------------------------------------------- //
theme: {
color: 'auto',
// Light Mode
light: {
primary: '#333', // text color
background: '#FFF', // background color
grid: '#F3F3F3', // grid lines color
},
// Dark Mode
dark: {
primary: '#DBDBDB', // text color
background: '#121212', // background color
grid: '#1B1B1B', // grid lines color
},
},
toc: {
enable: true,
depth: '2',
},
rss: {
enabled: true,
follow: {
feedId: '68090849347654656',
userId: '68014765825824768',
},
},
analytics: {
// google:
umami: 'https://analytics.example.com/script.js',
},
comment: {
waline: {
serverURL: 'https://comment.radishzz.cc',
emoji: [
'//unpkg.com/@waline/emojis@1.2.0/bmoji',
'//unpkg.com/@waline/emojis@1.2.0/weibo',
],
search: false,
imageUploader: false,
},
},
}
export default themeConfig

16
src/content/config.ts Normal file
View file

@ -0,0 +1,16 @@
import { defineCollection, z } from 'astro:content'
const postsCollection = defineCollection({
type: 'content',
schema: z.object({
title: z.string(),
pubDate: z.date(),
updatedDate: z.date().optional(),
tags: z.array(z.string()).optional(),
draft: z.boolean().optional().default(false),
}),
})
export const collections = {
posts: postsCollection,
}

13
src/layouts/Layout.astro Normal file
View file

@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="generator" content={Astro.generator} />
<title>Astro Basics</title>
</head>
<body>
<slot />
</body>
</html>

8
src/pages/index.astro Normal file
View file

@ -0,0 +1,8 @@
---
import Welcome from '../components/Welcome.astro'
import Layout from '../layouts/Layout.astro'
---
<Layout>
<Welcome />
</Layout>

48
src/types/index.d.ts vendored Normal file
View file

@ -0,0 +1,48 @@
export interface ThemeConfig {
site: {
title_EN: string
title_CN: string
subtitle_EN: string
subtitle_CN: string
url: string
author: string
favicon: string
language: string
}
theme: {
color: 'light' | 'dark' | 'auto'
light: {
primary: string
background: string
grid: string
}
dark: {
primary: string
background: string
grid: string
}
}
toc: {
enable: boolean
depth: '1' | '2' | '3'
}
rss?: {
enabled: boolean
follow?: {
feedId: string
userId: string
}
}
analytics?: {
google?: string
umami?: string
}
comment?: {
waline?: {
serverURL: string
emoji?: string[]
search?: boolean
imageUploader?: boolean
}
}
}

37
tsconfig.json Normal file
View file

@ -0,0 +1,37 @@
{
"extends": "astro/tsconfigs/strict",
"compilerOptions": {
"target": "ESNext",
"jsx": "preserve",
"jsxImportSource": "astro",
"lib": [
"ESNext",
"DOM",
"DOM.Iterable"
],
"baseUrl": ".",
"module": "ESNext",
"moduleResolution": "Bundler",
"paths": {
"@/*": ["src/*"]
},
"resolveJsonModule": true,
"allowJs": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"isolatedModules": true
},
"skipLibCheck": true,
"include": [
"src/**/*.astro",
"src/**/*.ts",
"src/**/*.md",
"src/**/*.mdx",
".astro/types.d.ts"
],
"exclude": [
"node_modules",
"dist",
"public"
]
}

73
uno.config.js Normal file
View file

@ -0,0 +1,73 @@
import {
defineConfig,
presetAttributify,
presetTypography,
presetUno,
transformerDirectives,
transformerVariantGroup,
} from 'unocss'
import presetTheme from 'unocss-preset-theme'
import { themeConfig } from './src/config'
export default defineConfig({
presets: [
presetUno(),
presetAttributify(),
presetTypography(),
presetTheme({
theme: {
dark: {
colors: { ...themeConfig.theme.dark },
},
},
}),
],
transformers: [
transformerDirectives(),
transformerVariantGroup(),
],
theme: {
colors: { ...themeConfig.theme.light },
fontFamily: {
title: ['Title-EN', 'Title-RU', 'CN', 'ui-serif', 'Georgia', 'Cambria', 'Times New Roman', 'Times', 'serif'],
serif: ['EN', 'RU', 'CN', 'Georgia', 'ui-serif', 'Georgia', 'Cambria', 'Times New Roman', 'Times', 'serif'],
footer: ['Italic-EN', 'Italic-RU', 'ui-serif', 'Georgia', 'Cambria', 'Times New Roman', 'Times', 'serif'],
cust: ['EarlySummerSerif-Cust', 'ui-serif', 'Georgia', 'Cambria', 'Times New Roman', 'Times', 'serif'],
},
},
shortcuts: {
example: 'text-5 font-bold lh-7.5 m-0',
},
rules: [
// grid-[1_2]-[3_4]
[/^grid-(\d+|\[.+?\])-(\d+|\[.+?\])$/, ([, rows, cols]) => {
const isColsBracket = cols.startsWith('[') && cols.endsWith(']')
const isRowsBracket = rows.startsWith('[') && rows.endsWith(']')
return {
'display': 'grid',
'grid-template-rows': isRowsBracket
? rows.slice(1, -1).replace(/_/g, ' ')
: `repeat(${rows}, 1fr)`,
'grid-template-columns': isColsBracket
? cols.slice(1, -1).replace(/_/g, ' ')
: `repeat(${cols}, 1fr)`,
}
}],
// (lg:)area-1-2-3-4
[/^area-(\d+)-(\d+)-(\d+)-(\d+)$/, ([, Xstart, Ystart, Xend, Yend]) => ({
'grid-area': `${Xstart} / ${Ystart} / ${Xend} / ${Yend}`,
})],
],
preflights: [
{
getCSS: () => `
h1 { font-size: 3.6rem; line-height: 1.75; }
h2 { font-size: 3rem; line-height: 1.75; }
h3 { font-size: 2.4rem; line-height: 1.75; }
h4 { font-size: 2rem; line-height: 1.75; }
h5 { font-size: 1.8rem; line-height: 1.75; }
h6 { font-size: 1.6rem; line-height: 1.75; }
`,
},
],
})