-
Notifications
You must be signed in to change notification settings - Fork 147
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
900 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: Bar but Frontmatter | ||
date: 2024-01-02 08:00:00 | ||
--- | ||
|
||
# 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,10 @@ | ||
--- | ||
date: 2024-01-01 08:00:00 | ||
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 @@ | ||
--- | ||
show-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,7 @@ | ||
--- | ||
date: 2024-01-01 08:00:00 | ||
--- | ||
|
||
# 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": "https://example.com/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,31 @@ | ||
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: { | ||
/* use .xml for preview server */ | ||
filename: 'blog.xml', | ||
}, | ||
}, | ||
{ | ||
id: 'releases', | ||
test: /^\/releases\//, | ||
title: 'FooBar Releases', | ||
output: { type: 'atom', 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,70 @@ | ||
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('`show-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); | ||
}); | ||
}); | ||
}); |
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
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 @@ | ||
# @rspress/plugin-rss | ||
|
||
import { SourceCode, PackageManagerTabs } from 'rspress/theme'; | ||
|
||
<SourceCode href="https://github.com/web-infra-dev/rspress/tree/main/packages/plugin-rss" /> | ||
|
||
todo(xc2) | ||
|
||
## Installation | ||
|
||
<PackageManagerTabs command="add @rspress/plugin-rss -D" /> |
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
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 @@ | ||
# @rspress/plugin-rss | ||
|
||
import { SourceCode, PackageManagerTabs } from 'rspress/theme'; | ||
|
||
<SourceCode href="https://github.com/web-infra-dev/rspress/tree/main/packages/plugin-rss" /> | ||
|
||
todo(xc2) | ||
|
||
## Installation | ||
|
||
<PackageManagerTabs command="add @rspress/plugin-rss -D" /> |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023-present Bytedance, Inc. and its affiliates. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 | ||
|
||
> RSS plugin for rspress | ||
[Documentation](https://rspress.dev/plugin/official-plugins/rss) |
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,34 @@ | ||
import { | ||
PartialBaseBuildConfig, | ||
defineConfig, | ||
moduleTools, | ||
} from '@modern-js/module-tools'; | ||
|
||
const base = { | ||
buildType: 'bundle', | ||
format: 'cjs', | ||
sourceMap: true, | ||
target: 'es2020', | ||
} satisfies PartialBaseBuildConfig; | ||
|
||
// https://modernjs.dev/module-tools/en/api | ||
export default defineConfig({ | ||
buildConfig: [ | ||
{ | ||
...base, | ||
format: 'cjs', | ||
dts: false, | ||
esbuildOptions: options => ({ | ||
...options, | ||
outExtension: { '.js': '.cjs' }, | ||
}), | ||
}, | ||
{ ...base, format: 'esm', dts: false, autoExtension: true }, | ||
{ | ||
...base, | ||
format: 'esm', | ||
dts: { respectExternal: false, only: true }, | ||
}, | ||
], | ||
plugins: [moduleTools()], | ||
}); |
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,67 @@ | ||
{ | ||
"name": "@rspress/plugin-rss", | ||
"version": "1.16.1", | ||
"description": "A plugin for rss generation for rspress", | ||
"bugs": "https://github.com/web-infra-dev/rspress/issues", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/web-infra-dev/rspress", | ||
"directory": "packages/plugin-rss" | ||
}, | ||
"license": "MIT", | ||
"jsnext:source": "./src/index.ts", | ||
"types": "./dist/index.d.ts", | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.mjs", | ||
"exports": { | ||
".": { | ||
"import": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.cjs" | ||
}, | ||
"./FeedsAnnotations": "./static/global-components/FeedsAnnotations" | ||
}, | ||
"scripts": { | ||
"dev": "modern build -w", | ||
"build": "modern build", | ||
"reset": "rimraf ./**/node_modules", | ||
"lint": "modern lint", | ||
"change": "modern change", | ||
"bump": "modern bump", | ||
"pre": "modern pre", | ||
"change-status": "modern change-status", | ||
"gen-release-note": "modern gen-release-note", | ||
"release": "modern release", | ||
"new": "modern new", | ||
"test": "vitest run --passWithNoTests", | ||
"upgrade": "modern upgrade" | ||
}, | ||
"engines": { | ||
"node": ">=14.17.6" | ||
}, | ||
"dependencies": { | ||
"feed": "^4.2.2" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.11.17", | ||
"@types/react": "^18", | ||
"@rspress/shared": "workspace:*", | ||
"@rspress/runtime": "workspace:*", | ||
"react": "^18", | ||
"typescript": "^5" | ||
}, | ||
"peerDependencies": { | ||
"react": ">=17.0.0", | ||
"@types/react": ">=17.0.0", | ||
"@rspress/runtime": "^1.0.0" | ||
}, | ||
"files": [ | ||
"dist", | ||
"static" | ||
], | ||
"publishConfig": { | ||
"access": "public", | ||
"provenance": true, | ||
"registry": "https://registry.npmjs.org/" | ||
} | ||
} |
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 @@ | ||
export const PluginName = '@rspress/plugin-rss'; | ||
|
||
export const PluginComponents = { | ||
FeedsAnnotations: '@rspress/plugin-rss/FeedsAnnotations', | ||
} as const; |
Oops, something went wrong.