Code Blocks
Code blocks with titles allow you to label your code snippets with filenames or descriptions.
Basic Example
hello.js
function hello() {
console.log('Hello, World!');
}
hello();
With Line Numbers
config.ts
interface Config {
apiUrl: string;
timeout: number;
debug: boolean;
}
const config: Config = {
apiUrl: 'https://api.example.com',
timeout: 5000,
debug: false,
};
export default config;
Configuration Files
docusaurus.config.js
export default {
title: 'My Site',
url: 'https://example.com',
plugins: ['docusaurus-plugin-gitbook'],
};
Syntax
{% code title="filename.ext" %}
\`\`\`language
Your code here
\`\`\`
{% endcode %}
Attributes
title- The filename or title to displaylineNumbers- Show line numbers (boolean)overflow- How to handle overflow:wraporscroll