diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a4fe8a3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# root configuration file identifier +root = true + +# apply to all files +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +# special handling for Markdown files +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore index 016b59e..2721c78 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ # build output dist/ - -# generated types +.output/ .astro/ # dependencies @@ -20,5 +19,8 @@ pnpm-debug.log* # macOS-specific files .DS_Store -# jetbrains setting folder -.idea/ +# IDE +.idea +.vscode/* +!.vscode/extensions.json +!.vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1195bc4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,19 @@ +{ + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit" + }, + "eslint.validate": [ + "javascript", + "typescript", + "astro" + ], + "prettier.documentSelectors": ["**/*.astro"], + "typescript.tsdk": "node_modules/typescript/lib", + "files.associations": { + "*.mdx": "markdown" + }, + "[astro]": { + "editor.defaultFormatter": "astro-build.astro-vscode" + } +} diff --git a/eslint.config.mjs b/eslint.config.mjs index 0f02661..44c18a9 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,15 +1,7 @@ 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', - }, - }, -) +export default antfu({ + unocss: true, + typescript: true, + astro: true, +}) diff --git a/package.json b/package.json index d9145a0..242e9e3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,6 @@ "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", @@ -29,7 +28,9 @@ "reading-time": "^1.5.0", "rehype-autolink-headings": "^7.1.0", "rehype-components": "^0.3.0", + "rehype-external-links": "^3.0.0", "rehype-katex": "^7.0.1", + "rehype-pretty-code": "^0.14.0", "rehype-slug": "^6.0.0", "remark-directive": "^3.0.0", "remark-directive-rehype": "^0.4.2", @@ -38,6 +39,7 @@ "remark-sectionize": "^2.1.0", "sanitize-html": "^2.14.0", "sharp": "^0.33.5", + "shiki": "^1.26.1", "typescript": "~5.7.3", "unist-util-visit": "^5.0.0", "vite": "^6.0.7" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 845a44f..e5147a0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -50,9 +50,15 @@ importers: rehype-components: specifier: ^0.3.0 version: 0.3.0 + rehype-external-links: + specifier: ^3.0.0 + version: 3.0.0 rehype-katex: specifier: ^7.0.1 version: 7.0.1 + rehype-pretty-code: + specifier: ^0.14.0 + version: 0.14.0(shiki@1.26.1) rehype-slug: specifier: ^6.0.0 version: 6.0.0 @@ -77,6 +83,9 @@ importers: sharp: specifier: ^0.33.5 version: 0.33.5 + shiki: + specifier: ^1.26.1 + version: 1.26.1 typescript: specifier: ~5.7.3 version: 5.7.3 @@ -3428,6 +3437,10 @@ packages: iron-webcrypto@1.2.1: resolution: {integrity: sha512-feOM6FaSr6rEABp/eDfVseKyTMDt+KGpeB35SkVn9Tyn0CqvVsY3EwI0v5i8nMHyJnzCIQf7nsy3p41TPkJZhg==} + is-absolute-url@4.0.1: + resolution: {integrity: sha512-/51/TKE88Lmm7Gc4/8btclNXWS+g50wXhYJq8HWIBAGUBnoAdRu1aXeh364t/O7wXDAcTJDP8PNuNKWUDWie+A==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + is-alphabetical@2.0.1: resolution: {integrity: sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==} @@ -4307,6 +4320,9 @@ packages: parse-latin@7.0.0: resolution: {integrity: sha512-mhHgobPPua5kZ98EF4HWiH167JWBfl4pvAIXXdbaVohtK7a6YBOy56kvhCqduqyo/f3yrHFWmqmiMg/BkBkYYQ==} + parse-numeric-range@1.3.0: + resolution: {integrity: sha512-twN+njEipszzlMJd4ONUYgSfZPDxgHhT9Ahed5uTigpQn90FggW4SA/AIPq/6a149fTbE9qBEcSwE3FAEp6wQQ==} + parse-srcset@1.0.2: resolution: {integrity: sha512-/2qh0lav6CmI15FzA3i/2Bzk2zCgQhGMkvhOhKNcBVQ1ldgpbfiNTVslmooUmWJcADi1f1kIeynbDRVzNlfR6Q==} @@ -4766,12 +4782,21 @@ packages: rehype-components@0.3.0: resolution: {integrity: sha512-yl2bUkZi+sU0gxwVCun7IkjiDLPczSs1SKMKHmjlSLkk4mMryBd/aYba5J8suhJdquBEKSw6ZNxU3MvVQ9xqoQ==} + rehype-external-links@3.0.0: + resolution: {integrity: sha512-yp+e5N9V3C6bwBeAC4n796kc86M4gJCdlVhiMTxIrJG5UHDMh+PJANf9heqORJbt1nrCbDwIlAZKjANIaVBbvw==} + rehype-katex@7.0.1: resolution: {integrity: sha512-OiM2wrZ/wuhKkigASodFoo8wimG3H12LWQaH8qSPVJn9apWKFSH3YOCtbKpBorTVw/eI7cuT21XBbvwEswbIOA==} rehype-parse@9.0.1: resolution: {integrity: sha512-ksCzCD0Fgfh7trPDxr2rSylbwq9iYDkSn8TCDmEJ49ljEUBxDVCzCHv7QNzZOfODanX4+bWQ4WZqLCRWYLfhag==} + rehype-pretty-code@0.14.0: + resolution: {integrity: sha512-hBeKF/Wkkf3zyUS8lal9RCUuhypDWLQc+h9UrP9Pav25FUm/AQAVh4m5gdvJxh4Oz+U+xKvdsV01p1LdvsZTiQ==} + engines: {node: '>=18'} + peerDependencies: + shiki: ^1.3.0 + rehype-raw@7.0.0: resolution: {integrity: sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==} @@ -9900,6 +9925,8 @@ snapshots: iron-webcrypto@1.2.1: {} + is-absolute-url@4.0.1: {} + is-alphabetical@2.0.1: {} is-alphanumerical@2.0.1: @@ -11096,6 +11123,8 @@ snapshots: unist-util-visit-children: 3.0.0 vfile: 6.0.3 + parse-numeric-range@1.3.0: {} + parse-srcset@1.0.2: {} parse5@7.2.1: @@ -11545,6 +11574,15 @@ snapshots: hast-util-is-element: 3.0.0 unist-util-visit: 5.0.0 + rehype-external-links@3.0.0: + dependencies: + '@types/hast': 3.0.4 + '@ungap/structured-clone': 1.2.1 + hast-util-is-element: 3.0.0 + is-absolute-url: 4.0.1 + space-separated-tokens: 2.0.2 + unist-util-visit: 5.0.0 + rehype-katex@7.0.1: dependencies: '@types/hast': 3.0.4 @@ -11561,6 +11599,16 @@ snapshots: hast-util-from-html: 2.0.3 unified: 11.0.5 + rehype-pretty-code@0.14.0(shiki@1.26.1): + dependencies: + '@types/hast': 3.0.4 + hast-util-to-string: 3.0.1 + parse-numeric-range: 1.3.0 + rehype-parse: 9.0.1 + shiki: 1.26.1 + unified: 11.0.5 + unist-util-visit: 5.0.0 + rehype-raw@7.0.0: dependencies: '@types/hast': 3.0.4 diff --git a/tsconfig.json b/tsconfig.json index 8ed738a..52157b6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,37 +1,16 @@ { "extends": "astro/tsconfigs/strict", "compilerOptions": { - "target": "ESNext", - "jsx": "preserve", - "jsxImportSource": "astro", - "lib": [ - "ESNext", - "DOM", - "DOM.Iterable" - ], + "lib": ["esnext", "dom"], "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" - ] + "exclude": ["dist"] } diff --git a/uno.config.js b/uno.config.js index 506ae90..ab26fc7 100644 --- a/uno.config.js +++ b/uno.config.js @@ -9,11 +9,32 @@ import { import presetTheme from 'unocss-preset-theme' import { themeConfig } from './src/config' +const cssExtend = { + h1: { + 'font-size': '3.6rem', + }, + h2: { + 'font-size': '3rem', + }, + h3: { + 'font-size': '2.4rem', + }, + h4: { + 'font-size': '2rem', + }, + h5: { + 'font-size': '1.8rem', + }, + h6: { + 'font-size': '1.6rem', + }, +} + export default defineConfig({ presets: [ presetUno(), presetAttributify(), - presetTypography(), + presetTypography({ cssExtend }), presetTheme({ theme: { dark: { @@ -36,7 +57,7 @@ export default defineConfig({ }, }, shortcuts: { - example: 'text-5 font-bold lh-7.5 m-0', + 'blog-container': 'max-w-3xl mx-auto px-4', }, rules: [ // grid-[1_2]-[3_4] @@ -58,16 +79,4 @@ export default defineConfig({ '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; } - `, - }, - ], })