-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support the Markdown component in SSR
- Loading branch information
Showing
11 changed files
with
139 additions
and
17 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
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
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
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,13 @@ | ||
import type { AstroConfig } from '../@types/astro'; | ||
|
||
export const flags = { | ||
USER_CONFIG: 1 << 0 | ||
}; | ||
|
||
export function hasFlag(config: AstroConfig, flag: number): boolean { | ||
return !!(config._ctx.projectFlags & flag); | ||
} | ||
|
||
export function hasUserConfig(config: AstroConfig): boolean { | ||
return hasFlag(config, flags.USER_CONFIG); | ||
} |
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,5 @@ | ||
import { defineConfig } from 'astro/config'; | ||
|
||
export default defineConfig({ | ||
|
||
}); |
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,8 @@ | ||
{ | ||
"name": "@test/ssr-markdown", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*" | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/astro/test/fixtures/ssr-markdown/src/layouts/Base.astro
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,8 @@ | ||
<html> | ||
<head>Testing</head> | ||
<body> | ||
<article> | ||
<slot /> | ||
</article> | ||
</body> | ||
</html> |
14 changes: 14 additions & 0 deletions
14
packages/astro/test/fixtures/ssr-markdown/src/pages/page.astro
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,14 @@ | ||
--- | ||
import { Markdown } from 'astro/components'; | ||
--- | ||
|
||
<html> | ||
<head><title>Testing</title></head> | ||
<body> | ||
<Markdown> | ||
# Something | ||
|
||
else here | ||
</Markdown> | ||
</body> | ||
</html> |
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,9 @@ | ||
--- | ||
layout: ../layouts/Base.astro | ||
--- | ||
|
||
# Hello world | ||
|
||
This is some test | ||
|
||
## Subheading |
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,43 @@ | ||
import { expect } from 'chai'; | ||
import { load as cheerioLoad } from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
import testAdapter from './test-adapter.js'; | ||
|
||
// Asset bundling | ||
describe('Markdown pages in SSR', () => { | ||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/ssr-markdown/', | ||
experimental: { | ||
ssr: true, | ||
}, | ||
adapter: testAdapter(), | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
async function fetchHTML(path) { | ||
const app = await fixture.loadTestAdapterApp(); | ||
const request = new Request('http://example.com' + path); | ||
debugger; | ||
const response = await app.render(request); | ||
const html = await response.text(); | ||
return html; | ||
} | ||
|
||
|
||
it('Renders markdown pages correctly', async () => { | ||
const html = await fetchHTML('/post'); | ||
const $ = cheerioLoad(html); | ||
expect($('#subheading').text()).to.equal('Subheading'); | ||
}); | ||
|
||
it.only('Renders the Markdown component correctly', async () => { | ||
const html = await fetchHTML('/page'); | ||
console.log(html); | ||
const $ = cheerioLoad(html); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.