-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
1,516 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@rspress/plugin-rss": patch | ||
--- | ||
|
||
Introduce the RSS plugin for rspress |
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 @@ | ||
--- | ||
title: Bar but Frontmatter | ||
date: 2024-01-02 08:00:00 | ||
category: development | ||
slug: bar | ||
author: | ||
name: Lamperouge | ||
email: [email protected] | ||
--- | ||
|
||
# Bar but Markdown | ||
|
||
This is content |
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,11 @@ | ||
--- | ||
date: 2024-01-01 08:00:00 | ||
id: foo | ||
summary: | | ||
This is summary | ||
Second line of summary | ||
--- | ||
|
||
# Foo | ||
|
||
This is content |
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 @@ | ||
--- | ||
link-rss: blog | ||
--- | ||
|
||
Nothing but should have rss <link> |
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,12 @@ | ||
--- | ||
date: 2024-01-01 08:00:00 | ||
author: | ||
- Lelouch | ||
- Lamperouge | ||
- name: Geass | ||
link: /author/geass | ||
--- | ||
|
||
# Release 1.0.0 | ||
|
||
Nothing Happened |
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 @@ | ||
{ | ||
"base": "/sub/", | ||
"siteUrl": "http://localhost:4173/sub/", | ||
"title": "FooBar" | ||
} |
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,17 @@ | ||
{ | ||
"name": "@rspress-fixture/doc-plugin-rss", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "rspress dev", | ||
"build": "rspress build", | ||
"preview": "rspress preview" | ||
}, | ||
"dependencies": { | ||
"@rspress/plugin-rss": "workspace:*", | ||
"rspress": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^14" | ||
} | ||
} |
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,32 @@ | ||
import * as NodePath from 'path'; | ||
import { pluginRss } from '@rspress/plugin-rss'; | ||
import { defineConfig } from 'rspress/config'; | ||
import fixture from './fixture.json'; | ||
|
||
export default defineConfig({ | ||
root: NodePath.resolve(__dirname, 'doc'), | ||
title: fixture.title, | ||
base: fixture.base, | ||
plugins: [ | ||
pluginRss({ | ||
siteUrl: fixture.siteUrl, | ||
feed: [ | ||
{ | ||
id: 'blog', | ||
test: '/blog/', | ||
output: { | ||
type: 'rss', | ||
/* use .xml for preview server */ | ||
filename: 'blog.xml', | ||
}, | ||
}, | ||
{ | ||
id: 'releases', | ||
test: '/releases/', | ||
title: 'FooBar Releases', | ||
output: { filename: 'feed.xml', dir: 'releases' }, | ||
}, | ||
], | ||
}), | ||
], | ||
}); |
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 @@ | ||
{ | ||
"compilerOptions": { | ||
"esModuleInterop": true, | ||
"jsx": "react-jsx", | ||
"moduleResolution": "Bundler", | ||
"module": "Node16" | ||
} | ||
} |
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,99 @@ | ||
import path from 'path'; | ||
import { expect, test } from '@playwright/test'; | ||
import fixture from '../fixtures/plugin-rss/fixture.json'; | ||
import { | ||
getPort, | ||
killProcess, | ||
runBuildCommand, | ||
runPreviewCommand, | ||
} from '../utils/runCommands'; | ||
|
||
const appDir = path.resolve(__dirname, '../fixtures/plugin-rss'); | ||
const { siteUrl } = fixture; | ||
|
||
test.describe('plugin rss test', async () => { | ||
let appPort: number; | ||
let app: unknown; | ||
let prefix: string; | ||
test.beforeAll(async () => { | ||
appPort = await getPort(); | ||
await runBuildCommand(appDir); | ||
app = await runPreviewCommand(appDir, appPort); | ||
prefix = `http://localhost:${appPort}${fixture.base}`; | ||
}); | ||
|
||
test.afterAll(async () => { | ||
if (app) { | ||
await killProcess(app); | ||
} | ||
}); | ||
|
||
test('`link-rss` should add rss <link> to this page', async ({ page }) => { | ||
await page.goto(`${prefix}`, { waitUntil: 'networkidle' }); | ||
|
||
const link = page.locator('link[rel="alternative"]', {}); | ||
|
||
await expect(link.getAttribute('href')).resolves.toBe( | ||
`${siteUrl}rss/blog.xml`, | ||
); | ||
}); | ||
|
||
test('should add rss <link> to pages matched', async ({ page }) => { | ||
await page.goto(`${prefix}blog/foo`, { waitUntil: 'networkidle' }); | ||
|
||
const link = page.locator('link[rel="alternative"]', {}); | ||
|
||
await expect(link.getAttribute('href')).resolves.toBe( | ||
`${siteUrl}rss/blog.xml`, | ||
); | ||
}); | ||
|
||
test('should change output dir if dir is given', async ({ page }) => { | ||
// for: output.dir, output.type | ||
await page.goto(`${prefix}releases/feed.xml`, { waitUntil: 'networkidle' }); | ||
|
||
const feed = page.locator('feed>id'); | ||
|
||
await expect(feed.textContent()).resolves.toBe('releases'); | ||
}); | ||
|
||
test.describe('rss content', async () => { | ||
// todo: add more tests for rss content | ||
test('should has expected content', async ({ page }) => { | ||
await page.goto(`${prefix}rss/blog.xml`, { waitUntil: 'networkidle' }); | ||
|
||
await expect( | ||
page.locator('rss>channel>title').textContent(), | ||
).resolves.toBe(fixture.title); | ||
|
||
await expect( | ||
page.locator('rss>channel>link').textContent(), | ||
).resolves.toBe(fixture.siteUrl); | ||
|
||
const foo = page | ||
.locator('rss>channel>item') | ||
// frontmatter.id first | ||
.filter({ has: page.locator('guid:text-is("foo")') }); | ||
|
||
// frontmatter.summary first | ||
await expect( | ||
foo.locator("xpath=/*[name()='content:encoded']").textContent(), | ||
).resolves.toBe('This is summary\nSecond line of summary\n'); | ||
|
||
const bar = page | ||
.locator('rss>channel>item') | ||
// frontmatter.slug first | ||
.filter({ has: page.locator('guid:text-is("bar")') }); | ||
|
||
// frontmatter.category first | ||
await expect(bar.locator('>category').textContent()).resolves.toBe( | ||
'development', | ||
); | ||
|
||
// frontmatter.author | ||
await expect(bar.locator('>author').textContent()).resolves.toBe( | ||
'[email protected] (Lamperouge)', | ||
); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -6,5 +6,6 @@ | |
"typedoc", | ||
"preview", | ||
"playground", | ||
"rss", | ||
"shiki" | ||
] |
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
Oops, something went wrong.