Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ablula/egg-yuque-viewer

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ablula/egg-yuque-viewer - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

24

lib/index.js

@@ -24,3 +24,2 @@ 'use strict';

ctx.body = result;
next();
});

@@ -58,24 +57,3 @@ }

router.get(`GetDocumentView-${view}`, `${view}`, async (ctx, next) => {
const directories = await yuqueClient.getDirectories();
ctx.body = `<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<link rel="icon" href="https://img.alicdn.com/tps/TB1kBU7NpXXXXXLXXXXXXXXXXXX-160-160.png" type="image/x-icon">
<link rel="shortcut icon" href="https://img.alicdn.com/tps/TB1kBU7NpXXXXXLXXXXXXXXXXXX-160-160.png">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>${_config.title || 'Ablula-Yuque'}</title>
<link href="https://cdn.jsdelivr.net/npm/${_config.npm}/build/index.css" rel="stylesheet"></head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="mountNode"></div>
<script>window.__INITIAL_STATE__ = ${JSON.stringify(Object.assign({
api: _config.prefix,
searchAPI: _config.search,
directories,
}, _config))}</script>
<script src="https://cdn.jsdelivr.net/npm/${_config.npm}/build/index.js"></script>
</html>`;
ctx.body = await yuqueClient.getDocumentView();
next();

@@ -82,0 +60,0 @@ });

36

lib/YuqueClient.js

@@ -68,5 +68,39 @@ 'use strict';

async getDocumentView() {
const { config } = this;
let directories = await this.getDirectories();
if (directories.length <= 20) {
directories = await Promise.all(directories.map(async directory => {
directory.document = await this.getDocument(directory.locator);
return directory;
}));
}
const themeStyleTag = config.themeStyle && `<link href="${config.themeStyle}" rel="stylesheet">` || null;
return `<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<link rel="icon" href="https://img.alicdn.com/tps/TB1kBU7NpXXXXXLXXXXXXXXXXXX-160-160.png" type="image/x-icon">
<link rel="shortcut icon" href="https://img.alicdn.com/tps/TB1kBU7NpXXXXXLXXXXXXXXXXXX-160-160.png">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>${config.title || 'Ablula-Yuque'}</title>
<link href="https://cdn.jsdelivr.net/npm/${config.npm}/build/index.css" rel="stylesheet">
${themeStyleTag || ''}
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="mountNode"></div>
<script>window.__INITIAL_STATE__ = ${JSON.stringify(Object.assign({
api: config.prefix,
searchAPI: config.search,
directories,
}, config))}</script>
<script src="https://cdn.jsdelivr.net/npm/${config.npm}/build/index.js"></script>
</html>`;
}
async getDirectories() {
const { app, config } = this;
console.log('config: ', config);
const namespace = config.namespace;

@@ -73,0 +107,0 @@ const dirs = await this.request(`${this.baseUrl}/repos/${namespace}/toc`);

{
"name": "@ablula/egg-yuque-viewer",
"author": "mark.ck",
"version": "0.1.3",
"version": "0.1.4",
"description": "egg plugin for yuque viewer",

@@ -6,0 +6,0 @@ "eggPlugin": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc