-
Notifications
You must be signed in to change notification settings - Fork 787
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add robots.txt and Prisma syntax highlighting. (#5758)
- Loading branch information
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import siteConfig from '@generated/docusaurus.config' | ||
import type * as PrismNamespace from 'prismjs' | ||
import type { Optional } from 'utility-types' | ||
|
||
export default function prismIncludeLanguages(PrismObject: typeof PrismNamespace): void { | ||
const { | ||
themeConfig: { prism }, | ||
} = siteConfig | ||
const { additionalLanguages } = prism as { additionalLanguages: string[] } | ||
|
||
// Prism components work on the Prism instance on the window, while prism- | ||
// react-renderer uses its own Prism instance. We temporarily mount the | ||
// instance onto window, import components to enhance it, then remove it to | ||
// avoid polluting global namespace. | ||
// You can mutate PrismObject: registering plugins, deleting languages... As | ||
// long as you don't re-assign it | ||
globalThis.Prism = PrismObject | ||
|
||
additionalLanguages.forEach((lang) => { | ||
if (lang === 'php') { | ||
// eslint-disable-next-line global-require | ||
require('prismjs/components/prism-markup-templating.js') | ||
} | ||
// eslint-disable-next-line global-require, import/no-dynamic-require | ||
require(`prismjs/components/prism-${lang}`) | ||
}) | ||
|
||
require('@site/src/theme/prism-prisma.js') | ||
|
||
// @ts-ignore | ||
delete (globalThis as Optional<typeof globalThis, 'Prism'>).Prism | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Prism.languages.prisma = Prism.languages.extend('clike', { | ||
keyword: /\b(?:datasource|enum|generator|model|type|view)\b/, | ||
'type-class-name': /(\s+)[A-Z]\w+/, ///(\b)(\s+)[A-Z]\w+/ | ||
}) | ||
|
||
Prism.languages.javascript['class-name'][0].pattern = | ||
/(\b(?:model|datasource|enum|generator|type|model|view)\s+)[\w.\\]+/ | ||
|
||
Prism.languages.insertBefore('prisma', 'function', { | ||
annotation: { | ||
pattern: /(^|[^.])@+\w+/, | ||
lookbehind: true, | ||
alias: 'punctuation', | ||
}, | ||
}) | ||
|
||
Prism.languages.insertBefore('prisma', 'punctuation', { | ||
'type-args': /\b(?:references|fields|onDelete|onUpdate):/, | ||
}) | ||
|
||
Prism.languages.insertBefore('prisma', 'type-class-name', { | ||
'not-class': /\n(\s+)[A-Z]\w+/, | ||
}) | ||
|
||
Prism.languages.json5 = Prism.languages.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
User-agent: * | ||
Disallow: / | ||
Disallow: /*?query=* | ||
Disallow: /*?page=* | ||
Disallow: /*&query=* | ||
Disallow: /*&page=* |