Merge pull request #560 from aluzzardi/docs-syntax-highlight
docs syntax highlight for CUE
This commit is contained in:
commit
fd31afeda0
@ -1,62 +1,61 @@
|
||||
const path = require('path');
|
||||
const path = require("path");
|
||||
|
||||
/** @type {import('@docusaurus/types').DocusaurusConfig} */
|
||||
module.exports = {
|
||||
title: 'Dagger',
|
||||
tagline: 'Dagger is a programmable deployment system',
|
||||
url: 'https://docs.dagger.io',
|
||||
baseUrl: '/',
|
||||
onBrokenLinks: 'throw',
|
||||
onBrokenMarkdownLinks: 'warn',
|
||||
favicon: 'img/favicon.png',
|
||||
organizationName: 'Dagger',
|
||||
projectName: 'Dagger',
|
||||
title: "Dagger",
|
||||
tagline: "Dagger is a programmable deployment system",
|
||||
url: "https://docs.dagger.io",
|
||||
baseUrl: "/",
|
||||
onBrokenLinks: "throw",
|
||||
onBrokenMarkdownLinks: "warn",
|
||||
favicon: "img/favicon.png",
|
||||
organizationName: "Dagger",
|
||||
projectName: "Dagger",
|
||||
stylesheets: [
|
||||
'https://fonts.gstatic.com',
|
||||
'https://fonts.googleapis.com/css2?family=Poppins:wght@700&display=swap',
|
||||
'https://fonts.googleapis.com/css2?family=Karla&family=Poppins:wght@700&display=swap'
|
||||
"https://fonts.gstatic.com",
|
||||
"https://fonts.googleapis.com/css2?family=Poppins:wght@700&display=swap",
|
||||
"https://fonts.googleapis.com/css2?family=Karla&family=Poppins:wght@700&display=swap",
|
||||
],
|
||||
themeConfig: {
|
||||
sidebarCollapsible: false,
|
||||
prism: {
|
||||
defaultLanguage: 'go',
|
||||
theme: require("prism-react-renderer/themes/vsDark"),
|
||||
},
|
||||
navbar: {
|
||||
logo: {
|
||||
alt: 'Dagger Logo',
|
||||
src: 'img/dagger-logo.png',
|
||||
srcDark: 'img/dagger_logo_dark.png',
|
||||
alt: "Dagger Logo",
|
||||
src: "img/dagger-logo.png",
|
||||
srcDark: "img/dagger_logo_dark.png",
|
||||
},
|
||||
},
|
||||
algolia: {
|
||||
apiKey: '66c9f1f7e6ba6617ec4e65194788bacd',
|
||||
indexName: 'docs_dagger'
|
||||
apiKey: "66c9f1f7e6ba6617ec4e65194788bacd",
|
||||
indexName: "docs_dagger",
|
||||
},
|
||||
colorMode: {
|
||||
// "light" | "dark"
|
||||
defaultMode: 'light',
|
||||
defaultMode: "light",
|
||||
|
||||
switchConfig: {
|
||||
darkIcon: "img/Icon_Night-mode.svg",
|
||||
lightIcon: 'img/Icon_Day-mode.svg',
|
||||
lightIcon: "img/Icon_Day-mode.svg",
|
||||
},
|
||||
},
|
||||
},
|
||||
presets: [
|
||||
[
|
||||
'@docusaurus/preset-classic',
|
||||
"@docusaurus/preset-classic",
|
||||
{
|
||||
docs: {
|
||||
sidebarPath: require.resolve('./sidebars.js'),
|
||||
editUrl:
|
||||
'https://github.com/dagger/dagger/blob/main',
|
||||
routeBasePath: '/',
|
||||
sidebarPath: require.resolve("./sidebars.js"),
|
||||
editUrl: "https://github.com/dagger/dagger/blob/main",
|
||||
routeBasePath: "/",
|
||||
},
|
||||
theme: {
|
||||
customCss: require.resolve('./src/css/custom.css'),
|
||||
customCss: require.resolve("./src/css/custom.css"),
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
plugins: [path.resolve(__dirname, './custom_plugins')],
|
||||
};
|
||||
plugins: [path.resolve(__dirname, "./custom_plugins")],
|
||||
};
|
||||
|
24
tools/daggosaurus/src/theme/prism-include-languages.js
Normal file
24
tools/daggosaurus/src/theme/prism-include-languages.js
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
|
||||
import siteConfig from "@generated/docusaurus.config";
|
||||
|
||||
const prismIncludeLanguages = (PrismObject) => {
|
||||
if (ExecutionEnvironment.canUseDOM) {
|
||||
const {
|
||||
themeConfig: { prism: { additionalLanguages = [] } = {} },
|
||||
} = siteConfig;
|
||||
window.Prism = PrismObject;
|
||||
additionalLanguages.forEach((lang) => {
|
||||
require(`prismjs/components/prism-${lang}`); // eslint-disable-line
|
||||
});
|
||||
require("./prism.cue.js");
|
||||
delete window.Prism;
|
||||
}
|
||||
};
|
||||
|
||||
export default prismIncludeLanguages;
|
32
tools/daggosaurus/src/theme/prism.cue.js
Normal file
32
tools/daggosaurus/src/theme/prism.cue.js
Normal file
@ -0,0 +1,32 @@
|
||||
Prism.languages.cue = Prism.languages.extend("clike", {
|
||||
// https://github.com/PrismJS/prism/blob/master/components/prism-swift.js
|
||||
string: {
|
||||
pattern: /(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1/,
|
||||
greedy: true,
|
||||
inside: {
|
||||
interpolation: {
|
||||
pattern: /\\\#*\((?:[^()]|\([^)]+\))+\)/,
|
||||
inside: {
|
||||
delimiter: {
|
||||
pattern: /^\\\#*\(|\)$/,
|
||||
alias: "variable",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// https://cuelang.org/docs/references/spec/#values
|
||||
keyword: /\b(?:package|import|if|else|for|in|let)\b/,
|
||||
boolean: /\b(?:true|false)\b/,
|
||||
constant: /\b(?:_\|_|_)\b/,
|
||||
|
||||
// https://github.com/PrismJS/prism/blob/master/components/prism-go.js
|
||||
number: /(?:\b0x[a-f\d]+|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[-+]?\d+)?)i?/i,
|
||||
operator:
|
||||
/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
|
||||
|
||||
// https://cuelang.org/docs/references/spec/#predeclared-identifiers
|
||||
builtin:
|
||||
/\b(?:len|null|bool|int|float|string|bytes|number|u?int(?:8|16|32|64|128)?|rune|float(?:32|64))\b/,
|
||||
});
|
Reference in New Issue
Block a user