Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions .env
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
NEXT_PUBLIC_SITE_NAME = wiki
NEXT_PUBLIC_SITE_SUMMARY = Lark project scaffold based on TypeScript, React, Next.js, Bootstrap & Workbox.
NEXT_PUBLIC_LOGO = https://github.com/open-source-bazaar.png

NEXT_PUBLIC_SENTRY_DSN =
SENTRY_ORG =
SENTRY_PROJECT =
NEXT_PUBLIC_SITE_NAME = 开源市集 wiki
NEXT_PUBLIC_SITE_SUMMARY =
NEXT_PUBLIC_LOGO = https://github.com/Open-Source-Bazaar.png

NEXT_PUBLIC_LARK_API_HOST = https://open.feishu.cn/open-apis/
NEXT_PUBLIC_LARK_APP_ID = cli_a2c7771153f8900c
NEXT_PUBLIC_LARK_WIKI_URL = https://open-source-bazaar.feishu.cn/wiki/space/7318346900506181660

NEXT_PUBLIC_CACHE_HOST = https://cache.example.com
CACHE_REPOSITORY = your-namespace/Web-file-cache
NEXT_PUBLIC_LARK_APP_ID = cli_a8094a652022900d
NEXT_PUBLIC_LARK_WIKI_URL = https://open-source-bazaar.feishu.cn/wiki/space/7052192153363054596
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ WORKDIR /app

FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm i --frozen-lockfile
RUN CI=true pnpm build
RUN pnpm build

FROM base
COPY --from=build /app/public ./public
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# wiki
# Open Source Bazaar wiki

[Lark][0] project scaffold based on [TypeScript][2], [React][1], [Next.js][3], [Bootstrap][4] & [Workbox][5]. And this project bootstrapped with [`create-next-app`][6].

Expand All @@ -22,10 +22,9 @@

1. [Markdown articles](pages/article/)
2. [Lark wiki](pages/wiki/)
3. [Editor components](pages/component.tsx)
4. [Pagination table](pages/pagination.tsx)
5. [Scroll list](pages/scroll-list.tsx)
6. [Not Found page (NGO)](pages/_error.tsx)
3. [Pagination table](pages/pagination.tsx)
4. [Scroll list](pages/scroll-list.tsx)
5. [Not Found page (NGO)](pages/_error.tsx)
- Global: https://notfound.org/
- Chinese: https://www.dnpw.org/cn/pa-notfound.html

Expand Down
26 changes: 0 additions & 26 deletions babel.config.js

This file was deleted.

37 changes: 0 additions & 37 deletions components/Form/BlockEditor.tsx

This file was deleted.

24 changes: 0 additions & 24 deletions components/Form/HTMLEditor.tsx

This file was deleted.

50 changes: 50 additions & 0 deletions components/Layout/ContentTree.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import Link from 'next/link';
import { FC } from 'react';
import { Badge } from 'react-bootstrap';

import { XContent } from '../../models/Wiki';

export interface ContentTreeProps {
nodes: XContent[];
basePath: string;
level?: number;
metaKey?: string;
}

export const ContentTree: FC<ContentTreeProps> = ({
nodes,
basePath,
level = 0,
metaKey = 'category',
}) => (
<ol className={level === 0 ? 'list-unstyled' : ''}>
{nodes.map(({ path, name, type, meta, children }) => (
<li key={path} className={level > 0 ? 'ms-3' : ''}>
{type !== 'dir' ? (
<Link className="h4 d-flex align-items-center py-1" href={`${basePath}/${path}`}>
{name}

{meta?.[metaKey] && (
<Badge bg="secondary" className="ms-2 small">
{meta[metaKey]}
</Badge>
)}
</Link>
) : (
children?.[0] && (
<details>
<summary className="h4">{name}</summary>

<ContentTree
nodes={children}
basePath={basePath}
level={level + 1}
metaKey={metaKey}
/>
</details>
)
)}
</li>
))}
</ol>
);
4 changes: 3 additions & 1 deletion components/Navigator/MainNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export const MainNavigator: FC = observer(() => {

<Nav.Link href="/wiki">{t('wiki')}</Nav.Link>

<Nav.Link href="/component">{t('component')}</Nav.Link>
<Nav.Link href="/recipe">{t('recipe')}</Nav.Link>

<Nav.Link href="/policy">{t('policy')}</Nav.Link>

<Nav.Link href="/pagination">{t('pagination')}</Nav.Link>

Expand Down
10 changes: 0 additions & 10 deletions models/Document.ts

This file was deleted.

28 changes: 26 additions & 2 deletions models/Wiki.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
import { WikiNodeModel } from 'mobx-lark';
import './Base';

import { Content, ContentModel, TreeModel } from 'mobx-github';
import { DocumentModel, WikiNodeModel } from 'mobx-lark';
import { DataObject } from 'mobx-restful';

import { lark } from '../pages/api/Lark/core';
import { LarkWikiDomain, LarkWikiId } from './configuration';

export interface XContent extends Content {
meta?: DataObject;
// eslint-disable-next-line no-restricted-syntax
children?: XContent[];
}

export const policyTreeStore = new TreeModel('fpsig', 'open-source-policy');

export const policyContentStore = new ContentModel(
'fpsig',
'open-source-policy',
);
export const recipeTreeStore = new TreeModel('Gar-b-age', 'CookLikeHOC');

export const recipeContentStore = new ContentModel('Gar-b-age', 'CookLikeHOC');

export class MyWikiNodeModel extends WikiNodeModel {
client = lark.client;
}
export const wikiStore = new MyWikiNodeModel(LarkWikiDomain, LarkWikiId);

export default new MyWikiNodeModel(LarkWikiDomain, LarkWikiId);
export class MyDocumentModel extends DocumentModel {
client = lark.client;
}
export const documentStore = new MyDocumentModel(LarkWikiDomain);
Comment thread
TechQuery marked this conversation as resolved.
3 changes: 1 addition & 2 deletions models/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ export const Name = process.env.NEXT_PUBLIC_SITE_NAME,
Summary = process.env.NEXT_PUBLIC_SITE_SUMMARY,
DefaultImage = process.env.NEXT_PUBLIC_LOGO!;

export const { VERCEL_URL, JWT_SECRET, GITHUB_TOKEN, CACHE_REPOSITORY } =
process.env;
export const { CI, VERCEL_URL, JWT_SECRET, GITHUB_TOKEN } = process.env;

export const API_Host = isServer()
? VERCEL_URL
Expand Down
107 changes: 63 additions & 44 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import NextMDX from '@next/mdx';
import { withSentryConfig } from '@sentry/nextjs';
import CopyPlugin from 'copy-webpack-plugin';
import { readdirSync, statSync } from 'fs';
import { NextConfig } from 'next';
import setPWA from 'next-pwa';
// @ts-expect-error no official types
import withLess from 'next-with-less';
import RemarkFrontMatter from 'remark-frontmatter';
import RemarkGfm from 'remark-gfm';
import RemarkMdxFrontMatter from 'remark-mdx-frontmatter';
import webpack from 'webpack';
import { NormalModuleReplacementPlugin } from 'webpack';

const { NODE_ENV, CI, SENTRY_AUTH_TOKEN, SENTRY_ORG, SENTRY_PROJECT } =
process.env;
Expand All @@ -28,55 +29,73 @@ const withPWA = setPWA({
disable: isDev,
});

const webpack: NextConfig['webpack'] = config => {
config.plugins.push(
new NormalModuleReplacementPlugin(/^node:/, resource => {
resource.request = resource.request.replace(/^node:/, '');
}),
);

if (
statSync('pages/article', {
throwIfNoEntry: false,
})?.isDirectory() &&
readdirSync('pages/article')[0]
)
config.plugins.push(
new CopyPlugin({
patterns: [
{
from: 'pages/article',
to: 'static/article',
},
],
}),
);

return config;
};

const rewrites: NextConfig['rewrites'] = async () => ({
beforeFiles: [
{
source: '/proxy/github.com/:path*',
destination: 'https://github.com/:path*',
},
{
source: '/proxy/raw.githubusercontent.com/:path*',
destination: 'https://raw.githubusercontent.com/:path*',
},
{
source: '/recipe/images/:path*',
destination:
'https://raw.githubusercontent.com/Gar-b-age/CookLikeHOC/main/images/:path*',
},
],
afterFiles: [],
fallback: [
{
source: '/article/:path*',
destination: `/_next/static/article/:path*`,
has: [
{
type: 'header',
key: 'Accept',
value: '.*(image|audio|video|application)/.*',
},
],
},
],
});

const nextConfig = withPWA(
withLess(
withMDX({
output: CI ? 'standalone' : undefined,
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
transpilePackages: ['@sentry/browser'],

webpack: config => {
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(/^node:/, resource => {
resource.request = resource.request.replace(/^node:/, '');
}),
);

if (
statSync('pages/article', {
throwIfNoEntry: false,
})?.isDirectory() &&
readdirSync('pages/article')[0]
)
config.plugins.push(
new CopyPlugin({
patterns: [
{
from: 'pages/article',
to: 'static/article',
},
],
}),
);
return config;
},
rewrites: async () => ({
beforeFiles: [],
afterFiles: [],
fallback: [
{
source: '/article/:path*',
destination: `/_next/static/article/:path*`,
has: [
{
type: 'header',
key: 'Accept',
value: '.*(image|audio|video|application)/.*',
},
],
},
],
}),
webpack,
rewrites,
}),
),
);
Expand Down
Loading
Loading