From 673b4bf26b43ad0e0cb383bbecd78b9c11348936 Mon Sep 17 00:00:00 2001 From: tonyrewin Date: Tue, 4 Oct 2022 14:38:57 +0300 Subject: [PATCH] downgraded --- astro.config.ts | 4 +++- mdx.config.ts | 18 +++++++++++++----- package.json | 2 +- tsconfig.json | 21 ++------------------- yarn.lock | 9 +-------- 5 files changed, 20 insertions(+), 34 deletions(-) diff --git a/astro.config.ts b/astro.config.ts index 410398e1..c451dd73 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -9,6 +9,7 @@ import { markdownOptions as markdown } from './mdx.config' import type { CSSOptions } from 'vite' import defaultGenerateScopedName from 'postcss-modules/build/generateScopedName' import { isDev } from './src/utils/config' +import { fileURLToPath, URL } from 'url' const PATH_PREFIX = '/src/' @@ -62,7 +63,8 @@ const astroConfig: AstroUserConfig = { }, resolve: { alias: { - '@': './src' + './runtimeConfig': './runtimeConfig.browser', + '@': fileURLToPath(new URL('src', import.meta.url)) } }, css diff --git a/mdx.config.ts b/mdx.config.ts index 27bf8079..71ef2e8f 100644 --- a/mdx.config.ts +++ b/mdx.config.ts @@ -1,26 +1,34 @@ import type { AstroUserConfig } from 'astro' +import type { RehypePlugin } from '@astrojs/markdown-remark' import { selectAll } from 'hast-util-select' +import rehypeToc from '@jsdevtools/rehype-toc' +import rehypeAutolinkHeadings from 'rehype-autolink-headings' +import rehypeSlug from 'rehype-slug' +import remarkCodeTitles from 'remark-code-titles' const write = (cl) => ({ properties }) => { properties.className = properties.className ? properties.className + ' ' + cl : cl } + const adder = ([selector, className]) => { const writer = write(className) return (node) => selectAll(selector, node).forEach((el) => writer(el as any)) } + const addClasses = (additions) => { const adders = Object.entries(additions).map((entry) => adder(entry)) return (node) => adders.forEach((a) => a(node)) } export const markdownOptions: AstroUserConfig['markdown'] = { - // remarkPlugins: ['remark-code-titles'], + remarkPlugins: [remarkCodeTitles], rehypePlugins: [ - // 'rehype-slug', - // ['rehype-autolink-headings', { behavior: 'prepend' }], - // ['rehype-toc', { headings: ['h2', 'h3'] }], + rehypeSlug, + [rehypeToc as RehypePlugin, { headings: ['h1', 'h2', 'h3'] }], + [rehypeAutolinkHeadings, { behavior: 'prepend' }], [addClasses, { 'h1,h2,h3': 'title' }] - ] + ], + extendDefaultPlugins: true } diff --git a/package.json b/package.json index 60d0dd79..269e4cde 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ }, "dependencies": { "@aws-sdk/client-s3": "^3.178.0", + "@jsdevtools/rehype-toc": "^3.0.2", "@nanostores/persistent": "^0.7.0", "@nanostores/router": "^0.7.0", "@nanostores/solid": "^0.3.0", @@ -40,7 +41,6 @@ "postcss-modules": "^5.0.0", "rehype-autolink-headings": "^6.1.1", "rehype-slug": "^5.0.1", - "rehype-toc": "^3.0.2", "remark-code-titles": "^0.1.2" }, "devDependencies": { diff --git a/tsconfig.json b/tsconfig.json index 473c6aac..9f04f982 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,24 +1,7 @@ { + "extends": "astro/tsconfigs/strict", "compilerOptions": { - "allowSyntheticDefaultImports": true, - "importsNotUsedAsValues": "error", - // Solid specific settings "jsx": "preserve", - "jsxImportSource": "solid-js", - // Enable top-level await and other modern ESM features. - "target": "ESNext", - "module": "ESNext", - // Enable node-style module resolution, for things like npm package imports. - "moduleResolution": "node", - // Enable JSON imports. - "resolveJsonModule": true, - // Enable stricter transpilation for better output. - "isolatedModules": true, - // Astro will directly run your TypeScript code, no transpilation needed. - "noEmit": true, - "skipLibCheck": true - }, - "paths": { - "@": ["./src"] + "jsxImportSource": "solid-js" } } diff --git a/yarn.lock b/yarn.lock index b0e235bb..461f7d4a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2353,7 +2353,7 @@ "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" -"@jsdevtools/rehype-toc@3.0.2": +"@jsdevtools/rehype-toc@^3.0.2": version "3.0.2" resolved "https://registry.yarnpkg.com/@jsdevtools/rehype-toc/-/rehype-toc-3.0.2.tgz#29c32e6b40cd4b5dafd96cb90d5057ac5dab4a51" integrity sha512-n5JEf16Wr4mdkRMZ8wMP/wN9/sHmTjRPbouXjJH371mZ2LEGDl72t8tEsMRNFerQN/QJtivOxqK1frdGa4QK5Q== @@ -9818,13 +9818,6 @@ rehype-stringify@^9.0.0, rehype-stringify@^9.0.3: hast-util-to-html "^8.0.0" unified "^10.0.0" -rehype-toc@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/rehype-toc/-/rehype-toc-3.0.2.tgz#0373e2abafddeb0606ee38229ff6714da6d86d68" - integrity sha512-DMt376+4i1KJGgHJL7Ezd65qKkJ7Eqp6JSB47BJ90ReBrohI9ufrornArM6f4oJjP2E2DVZZHufWucv/9t7GUQ== - dependencies: - "@jsdevtools/rehype-toc" "3.0.2" - rehype@^12.0.1: version "12.0.1" resolved "https://registry.yarnpkg.com/rehype/-/rehype-12.0.1.tgz#68a317662576dcaa2565a3952e149d6900096bf6"