Skip to content

Commit

Permalink
chore: format fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Kozlov committed Mar 29, 2023
1 parent ad77c44 commit 48aed5a
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 120 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# cms
# cms
6 changes: 0 additions & 6 deletions content/scorecard.md

This file was deleted.

4 changes: 2 additions & 2 deletions globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { CMS } from 'netlify-cms-core'
import type { CMS } from "netlify-cms-core";

declare global {
var CMS: CMS
var CMS: CMS;
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "netlifycms-test",
"version": "0.1.0",
"name": "cms",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
10 changes: 5 additions & 5 deletions pages/admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { initializeCMS, registerTable } from "widgets/cms";
export default function Tmp() {
useEffect(() => {
(async () => {
const CMS = (await import('netlify-cms-app')).default
globalThis.CMS = CMS
const CMS = (await import("netlify-cms-app")).default;
globalThis.CMS = CMS;

initializeCMS()
registerTable()
})()
initializeCMS();
registerTable();
})();
}, []);

return <></>;
Expand Down
2 changes: 1 addition & 1 deletion pages/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function Auth() {

export const getServerSideProps = () => {
const authorizationUri = oauth2.authorizationCode.authorizeURL({
redirect_uri: publicRuntimeConfig.baseUrl + '/callback',
redirect_uri: publicRuntimeConfig.baseUrl + "/callback",
state: nanoid(32),
});
return {
Expand Down
8 changes: 4 additions & 4 deletions pages/callback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ interface CallbackProps {

const Callback: FC<CallbackProps> = ({ message, content }) => {
useEffect(() => {
const oauthProvider = 'github';
const oauthProvider = "github";
function recieveMessage(e: MessageEvent) {
console.log("recieveMessage %o", e);
const originHost = new URL(e.origin).host;
const baseUrlHost = new URL(publicRuntimeConfig.baseUrl).host
const baseUrlHost = new URL(publicRuntimeConfig.baseUrl).host;
if (originHost !== baseUrlHost) {
console.log("Invalid origin: %s", e.origin);
return;
Expand Down Expand Up @@ -53,7 +53,7 @@ const getAccessToken = (options: Record<string, string>) =>
message: "success",
content: {
token: token.token.access_token,
provider: 'github'
provider: "github",
},
});
}
Expand All @@ -65,7 +65,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
throw new Error("code wasn't specified");
}
const { message, content } = await getAccessToken({
code: context.query.code
code: context.query.code,
});
return {
props: {
Expand Down
6 changes: 3 additions & 3 deletions widgets/auth/oauth2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export const oauth2 = simpleOauthModule.create({
secret: serverRuntimeConfig.oauthClientSecret,
},
auth: {
tokenHost: 'https://github.com',
tokenPath: '/login/oauth/access_token',
authorizePath: '/login/oauth/authorize',
tokenHost: "https://github.com",
tokenPath: "/login/oauth/access_token",
authorizePath: "/login/oauth/authorize",
},
});
4 changes: 2 additions & 2 deletions widgets/cms/customDirectiveUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import jsyaml from 'js-yaml'
import jsyaml from "js-yaml";

declare var CMS: any
declare var CMS: any;

export const renderCustomDirective = (name: string, options: any) =>
`:::${name}\n` + (options ? jsyaml.dump(options) : "") + ":::";
Expand Down
6 changes: 3 additions & 3 deletions widgets/cms/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './customDirectiveUtils';
export * from './initialize';
export * from './table';
export * from "./customDirectiveUtils";
export * from "./initialize";
export * from "./table";
84 changes: 42 additions & 42 deletions widgets/cms/initialize.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import getConfig from 'next/config'
import getConfig from "next/config";

const { publicRuntimeConfig } = getConfig()
const { publicRuntimeConfig } = getConfig();

export const initializeCMS = () => {
CMS.init({
config: {
backend: {
name: "github",
repo: publicRuntimeConfig.githubRepo,
branch: publicRuntimeConfig.githubBranch,
base_url: publicRuntimeConfig.baseUrl,
},
publish_mode: "editorial_workflow",
show_preview_links: false,
media_folder: "public/img",
public_folder: "img",
collections: [
{
name: "pages",
label: "Pages",
files: [
{
name: "scorecard",
label: "Scorecard",
description: "Scorecard page",
file: "content/scorecard.md",
fields: [
{ label: "Title", name: "title", widget: "string" },
{ label: "Description", name: "description", widget: "text" },
{
label: "Body",
name: "body",
widget: "markdown",
buttons: ["heading-two", "link"],
editor_components: ["table"],
modes: ["rich_text"],
},
],
},
],
},
],
CMS.init({
config: {
backend: {
name: "github",
repo: publicRuntimeConfig.githubRepo,
branch: publicRuntimeConfig.githubBranch,
base_url: publicRuntimeConfig.baseUrl,
},
});
}
publish_mode: "editorial_workflow",
show_preview_links: false,
media_folder: "public/img",
public_folder: "img",
collections: [
{
name: "pages",
label: "Pages",
files: [
{
name: "scorecard",
label: "Scorecard",
description: "Scorecard page",
file: "content/scorecard.md",
fields: [
{ label: "Title", name: "title", widget: "string" },
{ label: "Description", name: "description", widget: "text" },
{
label: "Body",
name: "body",
widget: "markdown",
buttons: ["heading-two", "link"],
editor_components: ["table"],
modes: ["rich_text"],
},
],
},
],
},
],
},
});
};
99 changes: 50 additions & 49 deletions widgets/cms/table.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
import { registerCustomDirective } from "./customDirectiveUtils";

export const registerTable = () => registerCustomDirective("table", {
fields: [
{
name: "rows",
label: "Rows",
widget: "list",
label_singular: "row",
fields: [
{
label: "Scorecard Attribute",
name: "scorecard-attribute",
widget: "string",
},
{
name: "categories",
label: "Categories",
widget: "select",
options: [
"Governance",
"Validator market",
"Security",
"Validator set",
],
},
{
label: "Self-Assessment",
name: "self-assessment",
widget: "select",
options: ["Good", "Okay", "Needs improvement"],
},
{
label: "Comments",
name: "comments",
widget: "markdown",
buttons: ["link"],
editor_components: [],
modes: ["rich_text"],
},
],
},
],
toPreview: ({ rows = [] }) => {
let rowsString = "";
rows.forEach((row) => {
rowsString = `
export const registerTable = () =>
registerCustomDirective("table", {
fields: [
{
name: "rows",
label: "Rows",
widget: "list",
label_singular: "row",
fields: [
{
label: "Scorecard Attribute",
name: "scorecard-attribute",
widget: "string",
},
{
name: "categories",
label: "Categories",
widget: "select",
options: [
"Governance",
"Validator market",
"Security",
"Validator set",
],
},
{
label: "Self-Assessment",
name: "self-assessment",
widget: "select",
options: ["Good", "Okay", "Needs improvement"],
},
{
label: "Comments",
name: "comments",
widget: "markdown",
buttons: ["link"],
editor_components: [],
modes: ["rich_text"],
},
],
},
],
toPreview: ({ rows = [] }) => {
let rowsString = "";
rows.forEach((row) => {
rowsString = `
${rowsString}
${`
<tr>
Expand All @@ -55,9 +56,9 @@ export const registerTable = () => registerCustomDirective("table", {
</tr>
`}
`;
});
});

return `
return `
<table>
<thead>
<tr>
Expand All @@ -72,5 +73,5 @@ export const registerTable = () => registerCustomDirective("table", {
</tbody>
</table>
`;
},
});
},
});

0 comments on commit 48aed5a

Please sign in to comment.