Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1ea7a1c
Documentation UI Implementation
zzq0826 Jul 19, 2023
b9e1954
add delay for hidden search modal
zzq0826 Jul 31, 2023
57743f1
update subscribe style
zzq0826 Jul 31, 2023
1e98ba7
update style
zzq0826 Aug 2, 2023
3f0b709
update logo
zzq0826 Aug 2, 2023
7f57cac
update language-selector
zzq0826 Aug 2, 2023
af21b7b
update language-selector
zzq0826 Aug 2, 2023
b095f6d
update nav a style
zzq0826 Aug 2, 2023
f4e5deb
update info icon style
zzq0826 Aug 2, 2023
996c8f2
update components style
zzq0826 Aug 3, 2023
6e07323
change base font size
zzq0826 Aug 3, 2023
59e9322
update style
zzq0826 Aug 3, 2023
f445a9e
update style
zzq0826 Aug 4, 2023
c697b41
add whatsnext
zzq0826 Aug 4, 2023
533364c
update docsCollection
zzq0826 Aug 4, 2023
ba05160
update docsCollection
zzq0826 Aug 4, 2023
513ed67
change base font to 16px
zzq0826 Aug 4, 2023
0ddeded
fix callouts
zzq0826 Aug 4, 2023
477c0b1
feat: add landing page
Holybasil Aug 4, 2023
092d9e1
fix: adjustment
Holybasil Aug 5, 2023
089b1a4
fix: scroll logo
Holybasil Aug 5, 2023
6d8eea7
fix: default page
Holybasil Aug 5, 2023
f2949ac
update style from vivian
zzq0826 Aug 5, 2023
9ed4208
update fonts config
zzq0826 Aug 5, 2023
d29fe16
fix multi remix-callout style
zzq0826 Aug 5, 2023
fd36d2e
create markmap component
zzq0826 Aug 5, 2023
9eaf233
remove test code
zzq0826 Aug 5, 2023
4d12257
change component priority
zzq0826 Aug 5, 2023
9ddaebd
fix: home maxWidth 1400px
Holybasil Aug 6, 2023
608b9d0
update edit page url
zzq0826 Aug 5, 2023
e28b774
update style and change code font-family
zzq0826 Aug 6, 2023
a8c13ed
update font-family
zzq0826 Aug 6, 2023
0803a53
update font-family
zzq0826 Aug 6, 2023
d3db099
update recommended articles
zzq0826 Aug 6, 2023
1754d54
update heading style
zzq0826 Aug 6, 2023
1b6b7e8
update MarkmapaView preview
zzq0826 Aug 6, 2023
5b5b318
update MarkmapaView
zzq0826 Aug 7, 2023
6b3f960
update MarkmapaView
zzq0826 Aug 7, 2023
ebb3276
update MarkmapaView
zzq0826 Aug 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { defineConfig } from "astro/config"
import preact from "@astrojs/preact"
import react from "@astrojs/react"
import astroI18next from "astro-i18next"
import { astroCallouts } from "./integrations/astro-callouts"
import { solidityRemixCode } from "./integrations/solidity-remix"
import { astroCallouts, asideAutoImport } from "./integrations/astro-callouts"
import { solidityRemixCode, codeSampleAutoImport } from "./integrations/solidity-remix"
import { youtubeEmbed } from "./integrations/youtube-embed"
import mdx from "@astrojs/mdx"
import rehypeSlug from "rehype-slug"
Expand All @@ -12,6 +12,7 @@ import rehypeKatex from "rehype-katex"
import remarkGfm from "remark-gfm"
import remarkMath from "remark-math"
import image from "@astrojs/image"
import AutoImport from "astro-auto-import"

import sitemap from "@astrojs/sitemap"

Expand All @@ -24,6 +25,9 @@ export default defineConfig({
astroFlavoredMarkdown: true,
},
integrations: [
AutoImport({
imports: [asideAutoImport, codeSampleAutoImport],
}),
preact({
compat: true,
}),
Expand Down
32 changes: 12 additions & 20 deletions integrations/astro-callouts.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/**
* Astro's implementation of callouts
* https://github.com/withastro/docs/blob/main/integrations/astro-asides.ts
*/

import type { AstroIntegration } from "astro"
import type * as mdast from "mdast"
import type * as unified from "unified"
import { h } from "hastscript"
import remarkDirective from "remark-directive"
import { visit } from "unist-util-visit"
import type * as unified from "unified"
import { remove } from "unist-util-remove"
import { visit } from "unist-util-visit"
import { makeComponentNode } from "./utils/makeComponentNode"

const AsideTagname = "AutoImportedAside"

export const asideAutoImport: Record<string, [string, string][]> = {
"~/components/Aside.astro": [["default", AsideTagname]],
}
/**
* remark plugin that converts blocks delimited with `:::` into instances of
* the `<Aside>` component. Depends on the `remark-directive` module for the
Expand All @@ -38,8 +36,9 @@ function remarkAsides(): unified.Plugin<[], mdast.Root> {
const variants = new Set(["note", "tip", "caution", "danger"])

const transformer: unified.Transformer<mdast.Root> = (tree) => {
visit(tree, (node) => {
if (node.type !== "containerDirective") return
// @ts-expect-error Possibly infinite type instantiation we can’t do anything about.
visit(tree, (node, index, parent) => {
if (!parent || index === null || node.type !== "containerDirective") return
const type = node.name
if (!variants.has(type)) return

Expand All @@ -57,9 +56,8 @@ function remarkAsides(): unified.Plugin<[], mdast.Root> {
}
})

const data = node.data || (node.data = {})
data.hName = AsideTagname
data.hProperties = h(AsideTagname, { type, title }).properties
// Replace this node with the aside component it represents.
parent.children[index] = makeComponentNode(AsideTagname, { attributes: { type, title } }, ...node.children)
})
}

Expand All @@ -75,18 +73,12 @@ export function astroCallouts(): AstroIntegration {
return {
name: "@astrojs/callouts",
hooks: {
"astro:config:setup": ({ injectScript, updateConfig }) => {
"astro:config:setup": ({ updateConfig }) => {
updateConfig({
markdown: {
remarkPlugins: [remarkDirective, remarkAsides()],
},
})

// Auto-import the Aside component and attach it to the global scope
injectScript(
"page-ssr",
`import ${AsideTagname} from "~/components/Aside.astro"; global.${AsideTagname} = ${AsideTagname};`
)
},
},
}
Expand Down
25 changes: 18 additions & 7 deletions integrations/solidity-remix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ import { h } from "hastscript"
import remarkDirective from "remark-directive"
import { visit } from "unist-util-visit"
import { remove } from "unist-util-remove"
import { makeComponentNode } from "./utils/makeComponentNode"

const CodeSampleTagName = "AutoImportedCodeSample"

export const codeSampleAutoImport: Record<string, [string, string][]> = {
"~/components/CodeSample/CodeSample.astro": [["default", CodeSampleTagName]],
}

/**
* remark plugin that converts blocks delimited with `:::` into instances of
* the `<CodeSample>` component. Depends on the `remark-directive` module for the
Expand Down Expand Up @@ -52,6 +57,18 @@ function remarkSolidityRemix(): unified.Plugin<[], mdast.Root> {

if (!src) throw Error("No source was provided for the solidity example")

// const codeSnippetWrapper = makeComponentNode(
// CodeSnippetTagname,
// { mdx: isMDX, attributes },
// code
// );

// parent.children[index] = makeComponentNode(
// AsideTagname,
// { mdx: isMDXFile(file), attributes: { type, title } },
// ...node.children
// );

const data = node.data || (node.data = {})
data.hName = CodeSampleTagName
data.hProperties = h(CodeSampleTagName, {
Expand All @@ -73,18 +90,12 @@ export function solidityRemixCode(): AstroIntegration {
return {
name: "@smart-contract/solidity-remix",
hooks: {
"astro:config:setup": ({ injectScript, updateConfig }) => {
"astro:config:setup": ({ updateConfig }) => {
updateConfig({
markdown: {
remarkPlugins: [remarkDirective, remarkSolidityRemix()],
},
})

// Auto-import the Aside component and attach it to the global scope
injectScript(
"page-ssr",
`import ${CodeSampleTagName} from "~/components/CodeSample/CodeSample.astro"; global.${CodeSampleTagName} = ${CodeSampleTagName};`
)
},
},
}
Expand Down
33 changes: 33 additions & 0 deletions integrations/utils/makeComponentNode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { BlockContent } from "mdast"
import type { MdxJsxAttribute, MdxJsxFlowElement } from "mdast-util-mdx-jsx"

interface NodeProps {
attributes?: Record<string, string | boolean | number | undefined | null>
}

/**
* Create AST node for a custom component injection.
*
* @example
* makeComponentNode('MyComponent', { prop: 'val' }, h('p', 'Paragraph inside component'))
*
*/
export function makeComponentNode(
name: string,
{ attributes = {} }: NodeProps = {},
...children: BlockContent[]
): MdxJsxFlowElement {
return {
type: "mdxJsxFlowElement",
name,
attributes: Object.entries(attributes)
// Filter out non-truthy attributes to avoid empty attrs being parsed as `true`.
.filter(([_k, v]) => v !== false && Boolean(v))
.map(([name, value]) => ({
type: "mdxJsxAttribute",
name,
value: value as MdxJsxAttribute["value"],
})),
children,
}
}
Loading