-
Notifications
You must be signed in to change notification settings - Fork 140
Add support for generating other file extensions in MarkBind Sites #2762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d4be18a
Add jsdoc for template property
gerteck 32d6a32
Merge branch 'master' into feat/supportFileExtensions
gerteck 72df4bd
Allow custom file types
gerteck 7294130
Add docs for custom file type feature
gerteck bda46b7
Revert doc change
gerteck 6c2127b
Ensure correct relative paths
gerteck f0f8796
Simplify `fileExtension` property assignment
gerteck 2831838
Revert doc
gerteck 9521cae
Add testcase for site.json
gerteck 84b6b3f
test: Add tests for fileExtension property
gerteck 8681750
test: add unit tests for Page class's generate method and Site's crea…
gerteck 615d1fb
Fix lints
gerteck 3256c4a
Update docs
gerteck efb6643
Add logger warnings
gerteck 30cbc5d
Fix lints
gerteck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,7 @@ | ||
| { | ||
| "title": "globalVariables", | ||
| "description": "This file is served as a .json file, but is sourced from a .md file in the source code.", | ||
| "baseUrl": "{{baseUrl}}", | ||
| "timestamp": "{{timestamp}}", | ||
| "MarkBind": "{{MarkBind}}" | ||
| } |
This file contains hidden or 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,8 @@ | ||
| This file is served as a .txt file, sourced from a .md file. | ||
|
|
||
| The content below demonstrates nunjucks variables usage for custom file types: | ||
|
|
||
|
|
||
| {% raw %} {{ baseUrl }} {% endraw %}: "{{ baseUrl }}" | ||
| {% raw %} {{ timestamp }} {% endraw %}: "{{ timestamp }}" | ||
| {% raw %} {{ MarkBind }} {% endraw %}: ”{{ MarkBind }}“ |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,71 @@ | ||
| import path from 'path'; | ||
| import fs from 'fs-extra'; | ||
| import { Page } from '../../../src/Page'; | ||
| import { VariableProcessor } from '../../../src/variables/VariableProcessor'; | ||
|
|
||
| const mockFs = fs as any; | ||
|
|
||
| jest.mock('fs'); | ||
| jest.mock('walk-sync'); | ||
| jest.mock('../../../src/Page/PageVueServerRenderer'); | ||
| jest.mock('../../../src/html/NodeProcessor'); | ||
| jest.mock('../../../src/variables/VariableProcessor'); | ||
| jest.mock('../../../src/plugins/PluginManager'); | ||
| jest.mock('../../../src/html/SiteLinkManager'); | ||
| jest.mock('../../../src/Layout/LayoutManager'); | ||
| jest.mock('../../../src/Page/PageSources'); | ||
| jest.mock('../../../src/External/ExternalManager'); | ||
|
|
||
| describe('Page', () => { | ||
| const pageConfig = { | ||
| sourcePath: 'test.md', | ||
| resultPath: 'test.json', | ||
| }; | ||
| const siteConfig = { | ||
| baseUrl: '/', | ||
| style: { | ||
| codeLineNumbers: false, | ||
| }, | ||
| ignore: [], | ||
| intrasiteLinkValidation: {}, | ||
| plantumlCheck: false, | ||
| }; | ||
|
|
||
| test('generate writes raw content for non-html files', async () => { | ||
| mockFs.vol.fromJSON({ | ||
| 'test.md': '{"foo": "bar"}', | ||
| }); | ||
|
|
||
| // Mock the VariableProcessor instance to return a specific render method. | ||
| // This is necessary because Page.generate uses VariableProcessor internally. | ||
| (VariableProcessor as unknown as jest.Mock).mockImplementation(() => ({ | ||
| renderWithSiteVariables: jest.fn().mockReturnValue('{"foo": "bar"}'), | ||
| })); | ||
|
|
||
| // Inject the mocked variableProcessor into the Page configuration. | ||
| // The Page constructor assigns this.pageConfig from the passed argument, | ||
| // and subsequent methods use this.pageConfig.variableProcessor. | ||
| const variableProcessor = { | ||
| renderWithSiteVariables: jest.fn().mockReturnValue('{"foo": "bar"}'), | ||
| }; | ||
|
|
||
| const configWithMock = { | ||
| ...pageConfig, | ||
| variableProcessor, | ||
| }; | ||
|
|
||
| const page = new Page(configWithMock as any, siteConfig as any); | ||
|
|
||
| const externalManager = { | ||
| config: { outputPath: '_site' }, | ||
| generateDependencies: jest.fn(), | ||
| }; | ||
|
|
||
| await page.generate(externalManager as any); | ||
gerteck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Verify fs.outputFile was called with correct content | ||
| // Verify file content in mocked filesystem | ||
| const content = fs.readFileSync(path.resolve('test.json'), 'utf8'); | ||
| expect(content).toEqual('{"foo": "bar"}'); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.