@netfoundry/docusaurus-theme 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/layout.css +14 -0
- package/css/legacy.css +2346 -0
- package/css/theme.css +9 -4
- package/css/vars-dark.css +7 -0
- package/css/vars.css +8 -0
- package/package.json +27 -4
- package/src/components/Alert/Alert.module.css +39 -0
- package/src/components/Alert/Alert.tsx +24 -0
- package/src/components/Alert/index.ts +2 -0
- package/src/components/CodeBlock/CodeBlock.module.css +27 -0
- package/src/components/CodeBlock/CodeBlock.tsx +32 -0
- package/src/components/CodeBlock/index.ts +2 -0
- package/src/components/Common/Common.module.css +0 -0
- package/src/components/Common/Common.tsx +53 -0
- package/src/components/Common/index.ts +1 -0
- package/src/components/NetFoundry/Divider/Divider.module.css +23 -0
- package/src/components/NetFoundry/Divider/Divider.tsx +20 -0
- package/src/components/NetFoundry/Divider/index.ts +1 -0
- package/src/components/NetFoundry/index.ts +1 -0
- package/src/components/NetFoundryFooter/NetFoundryFooter.tsx +164 -0
- package/src/components/NetFoundryFooter/index.ts +1 -0
- package/src/components/NetFoundryFooter/styles.module.css +99 -0
- package/src/components/NetFoundryHighlight/NetFoundryHighlight.tsx +15 -0
- package/src/components/NetFoundryHighlight/index.ts +2 -0
- package/src/components/NetFoundryHighlight/styles.module.css +26 -0
- package/src/components/NetFoundryHorizontalSection/NetFoundryHorizontalSection.tsx +23 -0
- package/src/components/NetFoundryHorizontalSection/index.ts +2 -0
- package/src/components/NetFoundryHorizontalSection/styles.module.css +23 -0
- package/src/components/NetFoundryLayout/NetFoundryLayout.module.css +6 -0
- package/src/components/NetFoundryLayout/NetFoundryLayout.tsx +110 -0
- package/src/components/NetFoundryLayout/index.ts +1 -0
- package/src/components/NetFoundryNavbarItems/NetFoundryNavbarItems.tsx +22 -0
- package/src/components/NetFoundryNavbarItems/index.ts +2 -0
- package/src/components/OsTabs/OsTabs.tsx +30 -0
- package/src/components/OsTabs/index.ts +2 -0
- package/src/components/StarUs/StarUs.tsx +19 -0
- package/src/components/StarUs/index.ts +2 -0
- package/src/components/StarUs/styles.module.css +6 -0
- package/src/components/index.ts +11 -0
- package/src/docusaurus-envhelper.ts +105 -0
- package/src/docusaurus-plugins/index.ts +7 -0
- package/src/docusaurus-plugins/logger.ts +38 -0
- package/src/docusaurus-plugins/remarkCodeSections.ts +115 -0
- package/src/docusaurus-plugins/remarkReplaceMetaUrl.ts +35 -0
- package/src/docusaurus-plugins/remarkScopedPath.ts +70 -0
- package/src/docusaurus-plugins/remarkYamlTable.ts +83 -0
- package/src/docusaurus-plugins/remarkYouTube.ts +56 -0
- package/src/docusaurus-plugins/timedPlugin.ts +22 -0
- package/src/node.ts +6 -0
- package/src/plugins.ts +6 -0
- package/src/ui.ts +7 -0
- package/src/version.ts +1 -0
- package/theme/Layout/index.tsx +1 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Plugin } from 'unified'
|
|
2
|
+
import { visit } from 'unist-util-visit'
|
|
3
|
+
import yaml from 'js-yaml'
|
|
4
|
+
import { Parent } from 'unist'
|
|
5
|
+
import { Literal } from 'unist'
|
|
6
|
+
import {Logger, LogLevel, resolveLogLevel} from './logger'
|
|
7
|
+
|
|
8
|
+
console.log("🦖 remarkYamlTable plugin module loaded")
|
|
9
|
+
|
|
10
|
+
interface Code extends Literal {
|
|
11
|
+
type: 'code'
|
|
12
|
+
lang?: string
|
|
13
|
+
value: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface TableCell {
|
|
17
|
+
type: 'tableCell'
|
|
18
|
+
children: { type: 'text'; value: string }[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface TableRow {
|
|
22
|
+
type: 'tableRow'
|
|
23
|
+
children: TableCell[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface Table {
|
|
27
|
+
type: 'table'
|
|
28
|
+
align: (null | 'left' | 'right' | 'center')[]
|
|
29
|
+
children: TableRow[]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface Options {
|
|
33
|
+
logLevel?: LogLevel
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const remarkYamlTable: Plugin<[Options]> = (options?: Options) => {
|
|
37
|
+
const { logLevel = LogLevel.Silent } = options ?? {}
|
|
38
|
+
const logger = new Logger(resolveLogLevel(options?.logLevel), 'remarkYamlTable')
|
|
39
|
+
|
|
40
|
+
logger.log('initialized')
|
|
41
|
+
|
|
42
|
+
return (tree) => {
|
|
43
|
+
visit(tree, 'code', (node: Code, index: number | undefined, parent: Parent | undefined) => {
|
|
44
|
+
if (!parent || index === undefined) return
|
|
45
|
+
if (node.lang === 'yaml-table') {
|
|
46
|
+
try {
|
|
47
|
+
const data = yaml.load(node.value)
|
|
48
|
+
if (Array.isArray(data) && data.length > 0 && typeof data[0] === 'object') {
|
|
49
|
+
const headers = Object.keys(data[0] as Record<string, unknown>)
|
|
50
|
+
|
|
51
|
+
const tableRows: TableRow[] = (data as Record<string, unknown>[]).map((row) => ({
|
|
52
|
+
type: 'tableRow',
|
|
53
|
+
children: headers.map<TableCell>((header) => ({
|
|
54
|
+
type: 'tableCell',
|
|
55
|
+
children: [{ type: 'text', value: String(row[header] ?? '') }],
|
|
56
|
+
})),
|
|
57
|
+
}))
|
|
58
|
+
|
|
59
|
+
const tableNode: Table = {
|
|
60
|
+
type: 'table',
|
|
61
|
+
align: headers.map(() => null),
|
|
62
|
+
children: [
|
|
63
|
+
{
|
|
64
|
+
type: 'tableRow',
|
|
65
|
+
children: headers.map<TableCell>((header) => ({
|
|
66
|
+
type: 'tableCell',
|
|
67
|
+
children: [{ type: 'text', value: header }],
|
|
68
|
+
})),
|
|
69
|
+
},
|
|
70
|
+
...tableRows,
|
|
71
|
+
],
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
parent.children[index] = tableNode
|
|
75
|
+
logger.log(`generated table with ${headers.length} columns and ${data.length} rows`, LogLevel.Info)
|
|
76
|
+
}
|
|
77
|
+
} catch (error) {
|
|
78
|
+
logger.log(`YAML parsing error: ${(error as Error).message}`, LogLevel.Info)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Plugin } from 'unified'
|
|
2
|
+
import { visit } from 'unist-util-visit'
|
|
3
|
+
import type { Node } from 'unist'
|
|
4
|
+
import {Logger, LogLevel, resolveLogLevel} from './logger'
|
|
5
|
+
|
|
6
|
+
console.log("🦖 remarkYouTube plugin module loaded")
|
|
7
|
+
|
|
8
|
+
interface YouTubeOptions {
|
|
9
|
+
logLevel?: LogLevel
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const remarkYouTube: Plugin<[YouTubeOptions]> = (options?: YouTubeOptions) => {
|
|
13
|
+
const { logLevel = LogLevel.Silent } = options ?? {}
|
|
14
|
+
const logger = new Logger(resolveLogLevel(options?.logLevel), 'remarkYouTube')
|
|
15
|
+
|
|
16
|
+
logger.log('initialized')
|
|
17
|
+
|
|
18
|
+
return (tree: Node) => {
|
|
19
|
+
visit(tree, ['link', 'text'], (node: any, index: number | undefined, parent: any) => {
|
|
20
|
+
if (!parent || typeof index !== 'number') return
|
|
21
|
+
let raw = node.url || node.value || ''
|
|
22
|
+
let ytUrl = raw.trim()
|
|
23
|
+
|
|
24
|
+
const hashnodeMatch = ytUrl.match(/^%\[(.+)\]$/)
|
|
25
|
+
if (hashnodeMatch) {
|
|
26
|
+
ytUrl = hashnodeMatch[1]
|
|
27
|
+
logger.log(`hashnode-style embed detected: ${ytUrl}`, LogLevel.Info)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const m =
|
|
31
|
+
ytUrl.match(/youtube\.com\/watch\?v=([A-Za-z0-9_-]+)/) ||
|
|
32
|
+
ytUrl.match(/youtu\.be\/([A-Za-z0-9_-]+)/) ||
|
|
33
|
+
ytUrl.match(/youtube-nocookie\.com\/watch\?v=([A-Za-z0-9_-]+)/)
|
|
34
|
+
|
|
35
|
+
if (m) {
|
|
36
|
+
logger.log(`rewriting YouTube URL: ${ytUrl} → videoId=${m[1]}`, LogLevel.Debug)
|
|
37
|
+
parent.children.splice(index, 1, {
|
|
38
|
+
type: 'mdxJsxFlowElement',
|
|
39
|
+
name: 'LiteYouTubeEmbed',
|
|
40
|
+
attributes: [
|
|
41
|
+
{ type: 'mdxJsxAttribute', name: 'id', value: m[1] },
|
|
42
|
+
{ type: 'mdxJsxAttribute', name: 'title', value: 'YouTube video' },
|
|
43
|
+
],
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
visit(tree, 'text', (node: any, index: number | undefined, parent: any) => {
|
|
49
|
+
if (!parent || typeof index !== 'number') return
|
|
50
|
+
if (node.value.trim() === '%[' || node.value.trim() === ']') {
|
|
51
|
+
logger.log(`stripping hashnode bracket artifact: ${node.value}`, LogLevel.Debug)
|
|
52
|
+
parent.children.splice(index, 1)
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Plugin } from "unified"
|
|
2
|
+
import {Logger, LogLevel, resolveLogLevel} from './logger'
|
|
3
|
+
|
|
4
|
+
export function timedPlugin<T extends Plugin>(
|
|
5
|
+
name: string,
|
|
6
|
+
plugin: T,
|
|
7
|
+
opts: { logLevel?: LogLevel } = {}
|
|
8
|
+
): T {
|
|
9
|
+
const { logLevel = LogLevel.Info } = opts
|
|
10
|
+
const logger = new Logger(resolveLogLevel(opts?.logLevel), name)
|
|
11
|
+
|
|
12
|
+
return ((...args: any[]) => {
|
|
13
|
+
const instance = (plugin as any)(...args)
|
|
14
|
+
return (tree: any, file: any) => {
|
|
15
|
+
const start = Date.now()
|
|
16
|
+
const res = instance(tree, file)
|
|
17
|
+
const dur = Date.now() - start
|
|
18
|
+
logger.log(`⏱ finished in ${dur}ms`)
|
|
19
|
+
return res
|
|
20
|
+
}
|
|
21
|
+
}) as any
|
|
22
|
+
}
|
package/src/node.ts
ADDED
package/src/plugins.ts
ADDED
package/src/ui.ts
ADDED
package/src/version.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const version = '0.1.1';
|
package/theme/Layout/index.tsx
CHANGED