@docusaurus/plugin-content-blog 2.0.0-beta.13 → 2.0.0-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/lib/authors.d.ts +5 -8
  2. package/lib/authors.js +15 -53
  3. package/lib/blogFrontMatter.d.ts +1 -34
  4. package/lib/blogFrontMatter.js +3 -3
  5. package/lib/blogUtils.d.ts +3 -3
  6. package/lib/blogUtils.js +28 -22
  7. package/lib/feed.d.ts +3 -8
  8. package/lib/feed.js +46 -35
  9. package/lib/index.d.ts +4 -3
  10. package/lib/index.js +33 -28
  11. package/lib/markdownLoader.d.ts +1 -1
  12. package/lib/markdownLoader.js +1 -2
  13. package/lib/pluginOptionSchema.d.ts +1 -1
  14. package/lib/pluginOptionSchema.js +5 -3
  15. package/lib/translations.d.ts +2 -1
  16. package/lib/translations.js +3 -3
  17. package/lib/types.d.ts +2 -79
  18. package/package.json +11 -12
  19. package/src/authors.ts +22 -69
  20. package/src/blogFrontMatter.ts +5 -50
  21. package/src/blogUtils.ts +38 -34
  22. package/src/feed.ts +80 -37
  23. package/src/index.ts +48 -44
  24. package/src/markdownLoader.ts +2 -3
  25. package/src/plugin-content-blog.d.ts +147 -4
  26. package/src/pluginOptionSchema.ts +7 -5
  27. package/src/translations.ts +5 -4
  28. package/src/types.ts +5 -97
  29. package/lib/.tsbuildinfo +0 -1
  30. package/src/__tests__/__fixtures__/authorsMapFiles/authors.json +0 -29
  31. package/src/__tests__/__fixtures__/authorsMapFiles/authors.yml +0 -27
  32. package/src/__tests__/__fixtures__/authorsMapFiles/authorsBad1.json +0 -5
  33. package/src/__tests__/__fixtures__/authorsMapFiles/authorsBad1.yml +0 -3
  34. package/src/__tests__/__fixtures__/authorsMapFiles/authorsBad2.json +0 -3
  35. package/src/__tests__/__fixtures__/authorsMapFiles/authorsBad2.yml +0 -2
  36. package/src/__tests__/__fixtures__/authorsMapFiles/authorsBad3.json +0 -8
  37. package/src/__tests__/__fixtures__/authorsMapFiles/authorsBad3.yml +0 -3
  38. package/src/__tests__/__fixtures__/component/Typography.tsx +0 -6
  39. package/src/__tests__/__fixtures__/getAuthorsMapFilePath/contentPathEmpty/empty +0 -0
  40. package/src/__tests__/__fixtures__/getAuthorsMapFilePath/contentPathJson1/authors.json +0 -0
  41. package/src/__tests__/__fixtures__/getAuthorsMapFilePath/contentPathJson2/authors.json +0 -0
  42. package/src/__tests__/__fixtures__/getAuthorsMapFilePath/contentPathNestedYml/sub/folder/authors.yml +0 -0
  43. package/src/__tests__/__fixtures__/getAuthorsMapFilePath/contentPathYml1/authors.yml +0 -0
  44. package/src/__tests__/__fixtures__/getAuthorsMapFilePath/contentPathYml2/authors.yml +0 -0
  45. package/src/__tests__/__fixtures__/website/blog/2018-12-14-Happy-First-Birthday-Slash.md +0 -8
  46. package/src/__tests__/__fixtures__/website/blog/_partials/somePartial.md +0 -3
  47. package/src/__tests__/__fixtures__/website/blog/_partials/subfolder/somePartial.md +0 -3
  48. package/src/__tests__/__fixtures__/website/blog/_somePartial.md +0 -3
  49. package/src/__tests__/__fixtures__/website/blog/authors.yml +0 -4
  50. package/src/__tests__/__fixtures__/website/blog/complex-slug.md +0 -7
  51. package/src/__tests__/__fixtures__/website/blog/date-matter.md +0 -5
  52. package/src/__tests__/__fixtures__/website/blog/draft.md +0 -6
  53. package/src/__tests__/__fixtures__/website/blog/heading-as-title.md +0 -5
  54. package/src/__tests__/__fixtures__/website/blog/mdx-blog-post.mdx +0 -36
  55. package/src/__tests__/__fixtures__/website/blog/mdx-require-blog-post.mdx +0 -14
  56. package/src/__tests__/__fixtures__/website/blog/simple-slug.md +0 -11
  57. package/src/__tests__/__fixtures__/website/blog-with-ref/2018-12-14-Happy-First-Birthday-Slash.md +0 -5
  58. package/src/__tests__/__fixtures__/website/blog-with-ref/post-with-broken-links.md +0 -11
  59. package/src/__tests__/__fixtures__/website/blog-with-ref/post.md +0 -5
  60. package/src/__tests__/__fixtures__/website/i18n/en/docusaurus-plugin-content-blog/2018-12-14-Happy-First-Birthday-Slash.md +0 -8
  61. package/src/__tests__/__fixtures__/website/i18n/en/docusaurus-plugin-content-blog/authors.yml +0 -5
  62. package/src/__tests__/__fixtures__/website/static/img/docusaurus.png +0 -0
  63. package/src/__tests__/__fixtures__/website-blog-without-date/blog/no date.md +0 -1
  64. package/src/__tests__/__snapshots__/feed.test.ts.snap +0 -164
  65. package/src/__tests__/__snapshots__/linkify.test.ts.snap +0 -24
  66. package/src/__tests__/__snapshots__/pluginOptionSchema.test.ts.snap +0 -5
  67. package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -64
  68. package/src/__tests__/authors.test.ts +0 -608
  69. package/src/__tests__/blogFrontMatter.test.ts +0 -394
  70. package/src/__tests__/blogUtils.test.ts +0 -94
  71. package/src/__tests__/feed.test.ts +0 -126
  72. package/src/__tests__/index.test.ts +0 -408
  73. package/src/__tests__/linkify.test.ts +0 -93
  74. package/src/__tests__/pluginOptionSchema.test.ts +0 -150
  75. package/src/__tests__/translations.test.ts +0 -92
  76. package/tsconfig.json +0 -9
@@ -1,92 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import {BlogPost, BlogContent, PluginOptions} from '../types';
9
- import {getTranslationFiles, translateContent} from '../translations';
10
- import {DEFAULT_OPTIONS} from '../pluginOptionSchema';
11
- import {updateTranslationFileMessages} from '@docusaurus/utils';
12
-
13
- const sampleBlogOptions: PluginOptions = {
14
- ...DEFAULT_OPTIONS,
15
- blogSidebarTitle: 'All my posts',
16
- blogTitle: 'My blog',
17
- blogDescription: "Someone's random blog",
18
- };
19
-
20
- const sampleBlogPosts: BlogPost[] = [
21
- {
22
- id: 'hello',
23
- metadata: {
24
- permalink: '/blog/2021/06/19/hello',
25
- source: '/blog/2021/06/19/hello',
26
- description: '/blog/2021/06/19/hello',
27
- date: new Date(2021, 6, 19),
28
- formattedDate: 'June 19, 2021',
29
- tags: [],
30
- title: 'Hello',
31
- truncated: true,
32
- },
33
- },
34
- ];
35
-
36
- const sampleBlogContent: BlogContent = {
37
- blogSidebarTitle: sampleBlogOptions.blogSidebarTitle,
38
- blogListPaginated: [
39
- {
40
- items: ['hello'],
41
- metadata: {
42
- permalink: '/',
43
- page: 1,
44
- postsPerPage: 10,
45
- totalPages: 1,
46
- totalCount: 1,
47
- previousPage: null,
48
- nextPage: null,
49
- blogTitle: sampleBlogOptions.blogTitle,
50
- blogDescription: sampleBlogOptions.blogDescription,
51
- },
52
- },
53
- ],
54
- blogPosts: sampleBlogPosts,
55
- blogTags: {},
56
- blogTagsListPath: '/tags',
57
- };
58
-
59
- function getSampleTranslationFiles() {
60
- return getTranslationFiles(sampleBlogOptions);
61
- }
62
- function getSampleTranslationFilesTranslated() {
63
- const translationFiles = getSampleTranslationFiles();
64
- return translationFiles.map((translationFile) =>
65
- updateTranslationFileMessages(
66
- translationFile,
67
- (message) => `${message} (translated)`,
68
- ),
69
- );
70
- }
71
-
72
- describe('getContentTranslationFiles', () => {
73
- test('should return translation files matching snapshot', async () => {
74
- expect(getSampleTranslationFiles()).toMatchSnapshot();
75
- });
76
- });
77
-
78
- describe('translateContent', () => {
79
- test('should not translate anything if translation files are untranslated', () => {
80
- const translationFiles = getSampleTranslationFiles();
81
- expect(translateContent(sampleBlogContent, translationFiles)).toEqual(
82
- sampleBlogContent,
83
- );
84
- });
85
-
86
- test('should return translated loaded content matching snapshot', () => {
87
- const translationFiles = getSampleTranslationFilesTranslated();
88
- expect(
89
- translateContent(sampleBlogContent, translationFiles),
90
- ).toMatchSnapshot();
91
- });
92
- });
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "incremental": true,
5
- "tsBuildInfoFile": "./lib/.tsbuildinfo",
6
- "rootDir": "src",
7
- "outDir": "lib"
8
- }
9
- }