Skip to content

Commit 7218bfa

Browse files
author
Fun117
committed
First commit
1 parent 6240884 commit 7218bfa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+12034
-1
lines changed

.github/dependabot.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "npm"
9+
directory: "/"
10+
schedule:
11+
interval: "daily"

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/node_modules
2+
.next

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# GitHub repository template
1+
```bash
2+
npm login --scope=@scratch-auth
3+
```
4+
5+
```bash
6+
npm publish --access public
7+
```

_config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export const _config = {
2+
repoUrl: "https://github.com/scratch-auth/pkg",
3+
docsRepositoryBase: "https://github.com/scratch-auth/pkg/tree/main",
4+
5+
title: "Scratch Auth",
6+
origin: "https://scratch-auth.vercel.app",
7+
8+
author: {
9+
name: "Scratch Auth",
10+
url: "https://auth.itinerary.eu.org/",
11+
},
12+
};

components/icons/backend-agnostic.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export default function BackendAgnosticIcon() {
2+
return (
3+
<svg
4+
viewBox="0 0 24 24"
5+
width="24"
6+
height="24"
7+
stroke="currentColor"
8+
strokeWidth="2"
9+
strokeLinecap="round"
10+
strokeLinejoin="round"
11+
fill="none"
12+
shapeRendering="geometricPrecision"
13+
>
14+
<path d="M20 17.58A5 5 0 0018 8h-1.26A8 8 0 104 16.25" />
15+
<path d="M8 16h.01" />
16+
<path d="M8 20h.01" />
17+
<path d="M12 18h.01" />
18+
<path d="M12 22h.01" />
19+
<path d="M16 16h.01" />
20+
<path d="M16 20h.01" />
21+
</svg>
22+
);
23+
}

components/icons/lightweight.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export default function LightweightIcon() {
2+
return (
3+
<svg
4+
viewBox="0 0 24 24"
5+
width="24"
6+
height="24"
7+
stroke="currentColor"
8+
strokeWidth="2"
9+
fill="none"
10+
strokeLinecap="round"
11+
strokeLinejoin="round"
12+
>
13+
<path d="M20.24 12.24a6 6 0 0 0-8.49-8.49L5 10.5V19h8.5z" />
14+
<line x1="16" y1="8" x2="2" y2="22" />
15+
<line x1="17.5" y1="15" x2="9" y2="15" />
16+
</svg>
17+
);
18+
}

components/icons/pagination.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export default function PaginationIcon() {
2+
return (
3+
<svg
4+
viewBox="0 0 24 24"
5+
width="24"
6+
height="24"
7+
stroke="currentColor"
8+
strokeWidth="2"
9+
fill="none"
10+
strokeLinecap="round"
11+
strokeLinejoin="round"
12+
>
13+
<circle cx="12" cy="12" r="1" />
14+
<circle cx="12" cy="5" r="1" />
15+
<circle cx="12" cy="19" r="1" />
16+
</svg>
17+
);
18+
}

components/icons/realtime.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export default function RealtimeIcon() {
2+
return (
3+
<svg
4+
width="24"
5+
height="24"
6+
fill="none"
7+
stroke="currentColor"
8+
strokeLinecap="round"
9+
strokeLinejoin="round"
10+
strokeWidth="2"
11+
shapeRendering="geometricPrecision"
12+
viewBox="0 0 24 24"
13+
>
14+
<path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"></path>
15+
</svg>
16+
);
17+
}

components/logo.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default function Logo({ height }) {
2+
return (
3+
<svg height={height} viewBox="0 0 512 512" fill="none">
4+
<polygon fill="currentColor"
5+
points="352.188,0 131.781,290.125 224.172,290.125 148.313,512 380.219,223.438 284.328,223.438" />
6+
</svg>
7+
);
8+
}

components/use-locales-map.js

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { useRouter } from "next/router";
2+
3+
/**
4+
* @typedef {"ja"} DefaultLocale
5+
* @typedef {DefaultLocale | "en-US"} Locale
6+
* @typedef {{locale?: Locale | undefined; locales?: Locale[] | undefined; defaultLocale?: DefaultLocale | undefined}} TypedRouter
7+
* @typedef {Omit<import('next/router').NextRouter, "locale" | "locales" | "defaultLocale"> & TypedRouter} NextRouter
8+
* @template T
9+
* @type {(localesMap: Record<Locale, T>) => T}
10+
*/
11+
export default function useLocalesMap(localesMap) {
12+
/** @type {NextRouter} */
13+
const router = useRouter();
14+
const { locale, defaultLocale } = router;
15+
if (!localesMap) {
16+
throw new Error("Pass a locales map as argument to useLocalesMap");
17+
}
18+
19+
if (!isObject(localesMap)) {
20+
throw new Error("Locales map must be an object");
21+
}
22+
23+
if (!localesMap.hasOwnProperty(defaultLocale)) {
24+
throw new Error(
25+
`Locales map must contain default locale "${defaultLocale}"`
26+
);
27+
}
28+
29+
if (
30+
localesMap.hasOwnProperty(locale) &&
31+
typeof localesMap[locale] !== typeof localesMap[defaultLocale]
32+
) {
33+
throw new Error(
34+
`Invalid locales map: Shape of "${locale}" must be the same as "${defaultLocale}"`
35+
);
36+
}
37+
38+
if (
39+
["string", "number", "symbol"].includes(typeof localesMap[defaultLocale])
40+
) {
41+
return localesMap[locale] || localesMap[defaultLocale];
42+
}
43+
44+
const target = JSON.parse(JSON.stringify(localesMap[defaultLocale]));
45+
return mergeDeep(target, localesMap[locale]);
46+
}
47+
48+
/**
49+
* Simple object check.
50+
* @param {any} item
51+
* @returns {boolean}
52+
*/
53+
function isObject(item) {
54+
return item && typeof item === "object" && !Array.isArray(item);
55+
}
56+
57+
/**
58+
* Deep merge two objects.
59+
* @template T
60+
* @param {Record<string, T>} target
61+
* @param {Record<string, T>} sources
62+
* @returns {Record<string, T>}
63+
*/
64+
function mergeDeep(target, ...sources) {
65+
if (!sources.length) return target;
66+
const source = sources.shift();
67+
68+
if (isObject(target) && isObject(source)) {
69+
for (const key in source) {
70+
if (isObject(source[key])) {
71+
if (!target[key]) Object.assign(target, { [key]: {} });
72+
mergeDeep(target[key], source[key]);
73+
} else {
74+
Object.assign(target, { [key]: source[key] });
75+
}
76+
}
77+
}
78+
79+
return mergeDeep(target, ...sources);
80+
}

components/vercel.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default function Vercel({ height = 20 }) {
2+
return (
3+
<svg height={height} viewBox="0 0 283 64" fill="none">
4+
<path
5+
fill="currentColor"
6+
d="M141.04 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.46 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM248.72 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.45 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM200.24 34c0 6 3.92 10 10 10 4.12 0 7.21-1.87 8.8-4.92l7.68 4.43c-3.18 5.3-9.14 8.49-16.48 8.49-11.05 0-19-7.2-19-18s7.96-18 19-18c7.34 0 13.29 3.19 16.48 8.49l-7.68 4.43c-1.59-3.05-4.68-4.92-8.8-4.92-6.07 0-10 4-10 10zm82.48-29v46h-9V5h9zM36.95 0L73.9 64H0L36.95 0zm92.38 5l-27.71 48L73.91 5H84.3l17.32 30 17.32-30h10.39zm58.91 12v9.69c-1-.29-2.06-.49-3.2-.49-5.81 0-10 4-10 10V51h-9V17h9v9.2c0-5.08 5.91-9.2 13.2-9.2z"
7+
/>
8+
</svg>
9+
);
10+
}

middleware.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { locales as middleware } from 'nextra/locales'

next-sitemap.config.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/** @type {import('next-sitemap').IConfig} */
2+
module.exports = {
3+
siteUrl: "https://scratch-auth.vercel.app",
4+
generateRobotsTxt: true,
5+
sitemapSize: 5000,
6+
exclude: ["*/_meta"],
7+
robotsTxtOptions: {
8+
policies: [
9+
{
10+
userAgent: "*",
11+
allow: "/",
12+
disallow: ["/api"],
13+
},
14+
],
15+
},
16+
};

next.config.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const withNextra = require("nextra")({
2+
theme: "nextra-theme-docs",
3+
themeConfig: "./theme.config.js",
4+
staticImage: true,
5+
flexsearch: {
6+
codeblocks: false,
7+
},
8+
defaultShowCopyCode: true,
9+
});
10+
11+
module.exports = withNextra({
12+
i18n: {
13+
locales: ["ja", "en"],
14+
defaultLocale: "ja",
15+
},
16+
});

0 commit comments

Comments
 (0)