Skip to content

Commit

Permalink
feat: automatically detect dark theme
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Nov 27, 2020
1 parent c056ec1 commit a1f33f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion docs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ init({
logo: '<img src="logo.svg" width="60">',
description: 'Simply beautiful documentation.',
highlightLanguages: ['nginx'],
theme: 'dark',
props: {
langs: process.env.PRISM_LANGUAGES,
},
Expand Down
7 changes: 6 additions & 1 deletion src/docup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ export class Docup {
options: InstanceOptions

constructor(options: Options = {}) {
const matchedDarkTheme =
typeof window !== 'undefined' &&
window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)').matches

this.options = {
title: options.title || document.title || 'Docup',
indexFile: 'README.md',
root: '',
base: '/',
highlight: true,
theme: 'default',
theme: matchedDarkTheme ? 'dark' : 'default',
...options,
}
}
Expand Down

1 comment on commit a1f33f1

@vercel
Copy link

@vercel vercel bot commented on a1f33f1 Nov 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.