mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-26 13:08:58 +02:00
feat(v2): blog sidebar (#3593)
* blog sidebar POC * polish blog post sidebar * add doc for blogSidebarCount * Update packages/docusaurus-theme-classic/src/theme/BlogSidebar/styles.module.css Co-authored-by: Alexey Pyltsyn <lex61rus@gmail.com> Co-authored-by: Alexey Pyltsyn <lex61rus@gmail.com>
This commit is contained in:
parent
da6268911c
commit
e4c1626106
14 changed files with 226 additions and 14 deletions
|
@ -81,3 +81,42 @@ test('should convert all feed type to array with other feed type', () => {
|
|||
feedOptions: {type: ['rss', 'atom']},
|
||||
});
|
||||
});
|
||||
|
||||
describe('blog sidebar', () => {
|
||||
test('should accept 0 sidebar count', () => {
|
||||
const userOptions = {blogSidebarCount: 0};
|
||||
const {value, error} = PluginOptionSchema.validate(userOptions);
|
||||
expect(value).toEqual({...DEFAULT_OPTIONS, ...userOptions});
|
||||
expect(error).toBe(undefined);
|
||||
});
|
||||
|
||||
test('should accept "ALL" sidebar count', () => {
|
||||
const userOptions = {blogSidebarCount: 'ALL'};
|
||||
const {value, error} = PluginOptionSchema.validate(userOptions);
|
||||
expect(value).toEqual({...DEFAULT_OPTIONS, ...userOptions});
|
||||
expect(error).toBe(undefined);
|
||||
});
|
||||
|
||||
test('should reject "abcdef" sidebar count', () => {
|
||||
const userOptions = {blogSidebarCount: 'abcdef'};
|
||||
const {error} = PluginOptionSchema.validate(userOptions);
|
||||
expect(error).toMatchInlineSnapshot(
|
||||
`[ValidationError: "blogSidebarCount" must be one of [ALL, number]]`,
|
||||
);
|
||||
});
|
||||
|
||||
test('should accept "all posts" sidebar title', () => {
|
||||
const userOptions = {blogSidebarTitle: 'all posts'};
|
||||
const {value, error} = PluginOptionSchema.validate(userOptions);
|
||||
expect(value).toEqual({...DEFAULT_OPTIONS, ...userOptions});
|
||||
expect(error).toBe(undefined);
|
||||
});
|
||||
|
||||
test('should reject 42 sidebar title', () => {
|
||||
const userOptions = {blogSidebarTitle: 42};
|
||||
const {error} = PluginOptionSchema.validate(userOptions);
|
||||
expect(error).toMatchInlineSnapshot(
|
||||
`[ValidationError: "blogSidebarTitle" must be a string]`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue