@ -0,0 +1,160 @@ |
|||||
|
const spaceSeparated = require('space-separated-tokens'); |
||||
|
|
||||
|
function escapeRegExp(str) { |
||||
|
return str.replace(new RegExp(`[-[\\]{}()*+?.\\\\^$|/]`, 'g'), '\\$&'); |
||||
|
} |
||||
|
|
||||
|
const C_NEWLINE = '\n'; |
||||
|
const C_FENCE = '|'; |
||||
|
|
||||
|
function compilerFactory(nodeType) { |
||||
|
let text; |
||||
|
let title; |
||||
|
|
||||
|
return { |
||||
|
blockHeading(node) { |
||||
|
title = this.all(node).join(''); |
||||
|
return ''; |
||||
|
}, |
||||
|
blockBody(node) { |
||||
|
text = this.all(node) |
||||
|
.map(s => s.replace(/\n/g, '\n| ')) |
||||
|
.join('\n|\n| '); |
||||
|
return text; |
||||
|
}, |
||||
|
block(node) { |
||||
|
text = ''; |
||||
|
title = ''; |
||||
|
this.all(node); |
||||
|
if (title) { |
||||
|
return `[[${nodeType} | ${title}]]\n| ${text}`; |
||||
|
} else { |
||||
|
return `[[${nodeType}]]\n| ${text}`; |
||||
|
} |
||||
|
}, |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
module.exports = function blockPlugin(availableBlocks = {}) { |
||||
|
const pattern = Object.keys(availableBlocks).map(escapeRegExp).join('|'); |
||||
|
|
||||
|
if (!pattern) { |
||||
|
throw new Error('remark-custom-blocks needs to be passed a configuration object as option'); |
||||
|
} |
||||
|
|
||||
|
const regex = new RegExp(`\\[\@(${pattern})(?: *\\| *(.*))?\]\n`); |
||||
|
|
||||
|
function blockTokenizer(eat, value, silent) { |
||||
|
const now = eat.now(); |
||||
|
const keep = regex.exec(value); |
||||
|
if (!keep) return; |
||||
|
if (keep.index !== 0) return; |
||||
|
const [eaten, blockType, blockTitle] = keep; |
||||
|
|
||||
|
/* istanbul ignore if - never used (yet) */ |
||||
|
if (silent) return true; |
||||
|
|
||||
|
const linesToEat = []; |
||||
|
const content = []; |
||||
|
|
||||
|
let idx = 0; |
||||
|
while ((idx = value.indexOf(C_NEWLINE)) !== -1) { |
||||
|
const next = value.indexOf(C_NEWLINE, idx + 1); |
||||
|
// either slice until next NEWLINE or slice until end of string
|
||||
|
const lineToEat = next !== -1 ? value.slice(idx + 1, next) : value.slice(idx + 1); |
||||
|
if (lineToEat[0] !== C_FENCE) break; |
||||
|
// remove leading `FENCE ` or leading `FENCE`
|
||||
|
const line = lineToEat.slice(lineToEat.startsWith(`${C_FENCE} `) ? 2 : 1); |
||||
|
linesToEat.push(lineToEat); |
||||
|
content.push(line); |
||||
|
value = value.slice(idx + 1); |
||||
|
} |
||||
|
|
||||
|
const contentString = content.join(C_NEWLINE); |
||||
|
|
||||
|
const stringToEat = eaten + linesToEat.join(C_NEWLINE); |
||||
|
|
||||
|
const potentialBlock = availableBlocks[blockType]; |
||||
|
const titleAllowed = |
||||
|
potentialBlock.title && ['optional', 'required'].includes(potentialBlock.title); |
||||
|
const titleRequired = potentialBlock.title && potentialBlock.title === 'required'; |
||||
|
|
||||
|
if (titleRequired && !blockTitle) return; |
||||
|
if (!titleAllowed && blockTitle) return; |
||||
|
|
||||
|
const add = eat(stringToEat); |
||||
|
if (potentialBlock.details) { |
||||
|
potentialBlock.containerElement = 'details'; |
||||
|
potentialBlock.titleElement = 'summary'; |
||||
|
} |
||||
|
|
||||
|
const exit = this.enterBlock(); |
||||
|
const contents = { |
||||
|
type: `${blockType}CustomBlockBody`, |
||||
|
data: { |
||||
|
hName: potentialBlock.contentsElement ? potentialBlock.contentsElement : 'div', |
||||
|
hProperties: { |
||||
|
className: 'custom-block-body', |
||||
|
}, |
||||
|
}, |
||||
|
children: this.tokenizeBlock(contentString, now), |
||||
|
}; |
||||
|
exit(); |
||||
|
|
||||
|
const blockChildren = [contents]; |
||||
|
if (titleAllowed && blockTitle) { |
||||
|
const titleElement = potentialBlock.titleElement ? potentialBlock.titleElement : 'div'; |
||||
|
const titleNode = { |
||||
|
type: `${blockType}CustomBlockHeading`, |
||||
|
data: { |
||||
|
hName: titleElement, |
||||
|
hProperties: { |
||||
|
className: 'custom-block-heading', |
||||
|
}, |
||||
|
}, |
||||
|
children: this.tokenizeInline(blockTitle, now), |
||||
|
}; |
||||
|
|
||||
|
blockChildren.unshift(titleNode); |
||||
|
} |
||||
|
|
||||
|
const classList = spaceSeparated.parse(potentialBlock.classes || ''); |
||||
|
|
||||
|
return add({ |
||||
|
type: `${blockType}CustomBlock`, |
||||
|
children: blockChildren, |
||||
|
data: { |
||||
|
hName: potentialBlock.containerElement ? potentialBlock.containerElement : 'div', |
||||
|
hProperties: { |
||||
|
className: ['custom-block', ...classList], |
||||
|
}, |
||||
|
}, |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
const Parser = this.Parser; |
||||
|
|
||||
|
// Inject blockTokenizer
|
||||
|
const blockTokenizers = Parser.prototype.blockTokenizers; |
||||
|
const blockMethods = Parser.prototype.blockMethods; |
||||
|
blockTokenizers.customBlocks = blockTokenizer; |
||||
|
blockMethods.splice(blockMethods.indexOf('fencedCode') + 1, 0, 'customBlocks'); |
||||
|
const Compiler = this.Compiler; |
||||
|
if (Compiler) { |
||||
|
const visitors = Compiler.prototype.visitors; |
||||
|
if (!visitors) return; |
||||
|
Object.keys(availableBlocks).forEach(key => { |
||||
|
const compiler = compilerFactory(key); |
||||
|
visitors[`${key}CustomBlock`] = compiler.block; |
||||
|
visitors[`${key}CustomBlockHeading`] = compiler.blockHeading; |
||||
|
visitors[`${key}CustomBlockBody`] = compiler.blockBody; |
||||
|
}); |
||||
|
} |
||||
|
// Inject into interrupt rules
|
||||
|
const interruptParagraph = Parser.prototype.interruptParagraph; |
||||
|
const interruptList = Parser.prototype.interruptList; |
||||
|
const interruptBlockquote = Parser.prototype.interruptBlockquote; |
||||
|
interruptParagraph.splice(interruptParagraph.indexOf('fencedCode') + 1, 0, ['customBlocks']); |
||||
|
interruptList.splice(interruptList.indexOf('fencedCode') + 1, 0, ['customBlocks']); |
||||
|
interruptBlockquote.splice(interruptBlockquote.indexOf('fencedCode') + 1, 0, ['customBlocks']); |
||||
|
}; |
After Width: | Height: | Size: 919 B |
After Width: | Height: | Size: 723 B |
After Width: | Height: | Size: 1004 B |
After Width: | Height: | Size: 963 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 907 B |
After Width: | Height: | Size: 674 B |
After Width: | Height: | Size: 414 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 939 B |
After Width: | Height: | Size: 739 B |
After Width: | Height: | Size: 761 B |
After Width: | Height: | Size: 570 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 898 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 2.9 KiB |
@ -1,17 +0,0 @@ |
|||||
export const config = { |
|
||||
title: 'Blockstack', |
|
||||
description: 'Docs', |
|
||||
baseurl: '', |
|
||||
url: 'https://docs.blockstack.org', |
|
||||
repository: 'blockstack/docs.blockstack', |
|
||||
github_editme_path: 'blockstack/docs.blockstack/edit/master', |
|
||||
branch_url: 'master', |
|
||||
twitter: { |
|
||||
username: 'blockstack', |
|
||||
image: '/assets/img/twitter.png', |
|
||||
card: 'summary', |
|
||||
}, |
|
||||
footer: { |
|
||||
copyright: 'Blockstack Public Benefit Corp.', |
|
||||
}, |
|
||||
}; |
|
@ -1,6 +1,7 @@ |
|||||
export const SIDEBAR_WIDTH = 240; |
export const SIDEBAR_WIDTH = 240; |
||||
export const TOC_WIDTH = 240; |
export const TOC_WIDTH = 208; |
||||
export const CONTENT_MAX_WIDTH = 1104; |
export const CONTENT_MAX_WIDTH = 1104; |
||||
|
export const PAGE_WIDTH = 1216; |
||||
|
|
||||
export const SHIKI_THEME = 'Material-Theme-Default'; |
export const SHIKI_THEME = 'Material-Theme-Default'; |
||||
export const THEME_STORAGE_KEY = 'theme'; |
export const THEME_STORAGE_KEY = 'theme'; |
||||
|
@ -1,19 +1,25 @@ |
|||||
import React from 'react'; |
import React from 'react'; |
||||
import { MDXComponents } from '@components/mdx/mdx-components'; |
import { MDXComponents } from '@components/mdx/mdx-components'; |
||||
import { TableOfContents } from '@components/toc'; |
import { TableOfContents } from '@components/toc'; |
||||
import { hydrate } from '@common/hydrate-mdx'; |
import { hydrate } from '@common/data/hydrate-mdx'; |
||||
|
import { space } from '@blockstack/ui'; |
||||
|
|
||||
export const ClarityKeywordReference = ({ content, headings }) => { |
export const ClarityKeywordReference = ({ content, headings }) => { |
||||
return ( |
return ( |
||||
<> |
<> |
||||
<TableOfContents label="Contents" headings={headings} /> |
<TableOfContents mb={space('extra-loose')} label="Contents" headings={headings} /> |
||||
{hydrate(content, MDXComponents)} |
{hydrate(content, MDXComponents)} |
||||
</> |
</> |
||||
); |
); |
||||
}; |
}; |
||||
export const ClarityFunctionReference = ({ content, headings }) => ( |
export const ClarityFunctionReference = ({ content, headings }) => ( |
||||
<> |
<> |
||||
<TableOfContents columns={[2, 2, 3]} label="Contents" headings={headings} /> |
<TableOfContents |
||||
|
mb={space('extra-loose')} |
||||
|
columns={[2, 2, 3]} |
||||
|
label="Contents" |
||||
|
headings={headings} |
||||
|
/> |
||||
{hydrate(content, MDXComponents)} |
{hydrate(content, MDXComponents)} |
||||
</> |
</> |
||||
); |
); |
||||
|
@ -1,6 +1,9 @@ |
|||||
--- |
--- |
||||
title: Mine Stacks Token |
title: Mine Stacks Token |
||||
description: Run a node, earn STX, and learn how Proof of Transfer (PoX) works |
description: Run a node, earn STX, and learn how Proof of Transfer (PoX) works |
||||
|
images: |
||||
|
large: /images/pages/mining.svg |
||||
|
sm: /images/pages/mining-sm.svg |
||||
--- |
--- |
||||
|
|
||||
# Mine Stacks Token |
# Mine Stacks Token |
||||
|
@ -1,5 +1,5 @@ |
|||||
--- |
--- |
||||
title: Blockstack CLI Reference |
title: Blockstack CLI |
||||
--- |
--- |
||||
|
|
||||
export { convertBlockstackCLIUsageToMdx as getStaticProps } from '@common/data/cli-ref' |
export { convertBlockstackCLIUsageToMdx as getStaticProps } from '@common/data/cli-ref' |
@ -1,5 +1,6 @@ |
|||||
--- |
--- |
||||
description: 'See a detailed list of all keywords and functions for the Clarity language.' |
title: Clarity Language |
||||
|
description: See a detailed list of all keywords and functions for the Clarity language. |
||||
--- |
--- |
||||
|
|
||||
export { convertClarityRefToMdx as getStaticProps } from '@common/data/clarity-ref' |
export { convertClarityRefToMdx as getStaticProps } from '@common/data/clarity-ref' |
@ -1,5 +1,5 @@ |
|||||
--- |
--- |
||||
title: 'Stacks Blockchain APIs' |
title: Stacks Blockchain APIs |
||||
description: Interacting with the Stacks 2.0 Blockchain |
description: Interacting with the Stacks 2.0 Blockchain |
||||
--- |
--- |
||||
|
|
@ -1,5 +1,6 @@ |
|||||
--- |
--- |
||||
description: 'Stacks Node RPC API Reference' |
title: Stacks Node RPC API |
||||
|
description: Every running Stacks node exposes an RPC API, which allows you to interact with the underlying blockchain. |
||||
--- |
--- |
||||
|
|
||||
# RPC API Reference |
# RPC API Reference |