Skip to content

Commit

Permalink
chore: mastodon webfinger for vercel next.js
Browse files Browse the repository at this point in the history
  • Loading branch information
eallion committed Aug 4, 2023
1 parent 9981e88 commit 0be5eb6
Show file tree
Hide file tree
Showing 13 changed files with 236 additions and 46 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,27 @@ jobs:
git clone https://github.com/eallion/hugo-theme-doit.git themes/DoIt --single-branch
hugo --cleanDestinationDir --forceSyncStatic --gc --ignoreCache --minify --enableGitInfo
- name: Ready for Next.js
run: |
mkdir next
cp public next/public -rf
cp pages next/pages -rf
cp vercel.json next/
cp next.config.js next/
cp package.json next/
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.personal_token }}
external_repository: eallion/eallion.com
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./public
publish_branch: vercel
publish_dir: ./next
# destination_dir: public
allow_empty_commit: true
# commit_message: ${{ GitHub.event.head_commit.message }}
full_commit_message: ${{ github.event.head_commit.message }}
cname: eallion.com
#cname: eallion.com
force_orphan: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ resources/_gen/
package-lock.json

.hintrc
static/.next
static/node_modules
.next
7 changes: 7 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"paths": {
"@/*": ["./*"]
}
}
}
27 changes: 27 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/** @type {import('next').NextConfig} */
const nextConfig = {}

module.exports = {

exportPathMap: async function (defaultPathMap) {
return {
'/': { page: '/' }
}
},
async rewrites() {
return [
{
source: '/.well-known/webfinger',
destination: '/api/.well-known/webfinger'
},
{
source: '/.well-known/nodeinfo',
destination: '/api/.well-known/nodeinfo'
},
{
source: '/.well-known/host-meta',
destination: '/api/.well-known/host-meta'
}
];
},
}
8 changes: 7 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 41 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
{
"name": "eallion.com",
"version": "v2.0.2",
"description": "eallion.com hugo blog",
"private": true,
"scripts": {
"build": "hugo --cleanDestinationDir --forceSyncStatic --gc --ignoreCache --minify --enableGitInfo",
"server": "start http://192.168.0.5:1313 && hugo server -w -D -p 1313 --bind 0.0.0.0 --contentDir example --forceSyncStatic --ignoreCache --noHTTPCache --disableFastRender -e production --enableGitInfo",
"new": "node scripts/post_title_prompt.js && bash scripts/format_filename.sh",
"preview": "start http://192.168.0.5:1313 && hugo server -w -D -p 1313 --bind 0.0.0.0 --contentDir content --forceSyncStatic --ignoreCache --noHTTPCache --disableFastRender -e production --enableGitInfo",
"update": "git submodule update --remote --merge",
"start": "start http://192.168.0.5:1313 && hugo server -w -D -p 1313 --bind 0.0.0.0 --contentDir example --forceSyncStatic --ignoreCache --noHTTPCache --disableFastRender -e production --enableGitInfo",
"vercel": "node scripts/hugo_version.js && hugo --cleanDestinationDir --forceSyncStatic --gc --ignoreCache --minify --enableGitInfo"
},
"repository": {
"type": "git",
"url": "git+https://github.com/eallion/eallion.com"
},
"keywords": [
"hugo",
"theme",
"blog",
"eallion"
],
"author": "Charles Chin",
"license": "GLWTPL",
"bugs": {
"url": "https://github.com/eallion/eallion.com/issues"
},
"homepage": "https://github.com/eallion/eallion.com#readme",
"dependencies": {
"axios": "^1.4.0",
"fs": "^0.0.1-security",
"generate-changelog": "^1.8.0"
}
"name": "eallion.com",
"version": "v2.0.2",
"description": "eallion.com hugo blog",
"private": true,
"scripts": {
"hugo": "hugo --cleanDestinationDir --forceSyncStatic --gc --ignoreCache --minify --enableGitInfo",
"server": "start http://192.168.0.5:1313 && hugo server -w -D -p 1313 --bind 0.0.0.0 --contentDir example --forceSyncStatic --ignoreCache --noHTTPCache --disableFastRender -e production --enableGitInfo",
"new": "node scripts/post_title_prompt.js && bash scripts/format_filename.sh",
"preview": "start http://192.168.0.5:1313 && hugo server -w -D -p 1313 --bind 0.0.0.0 --contentDir content --forceSyncStatic --ignoreCache --noHTTPCache --disableFastRender -e production --enableGitInfo",
"update": "git submodule update --remote --merge",
"start": "next start",
"dev": "next dev",
"lint": "next lint",
"build": "next build",
"vercel": "node scripts/hugo_version.js && hugo --cleanDestinationDir --forceSyncStatic --gc --ignoreCache --minify --enableGitInfo && next build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/eallion/eallion.com"
},
"keywords": [
"hugo",
"theme",
"blog",
"eallion"
],
"author": "Charles Chin",
"license": "GLWTPL",
"bugs": {
"url": "https://github.com/eallion/eallion.com/issues"
},
"homepage": "https://github.com/eallion/eallion.com#readme",
"dependencies": {
"axios": "^1.4.0",
"fs": "^0.0.1-security",
"generate-changelog": "^1.8.0",
"next": "13.4.12",
"next.js": "^1.0.3",
"react": "18.2.0",
"react-dom": "18.2.0"
}
}
15 changes: 15 additions & 0 deletions pages/api/.well-known/host-meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// api/host-meta.js

export default (req, res) => {

const hostMeta = `
<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Link rel="lrdd" type="application/xrd+xml" template="https://example.com/api/webfinger?resource={uri}"/>
</XRD>
`;

res.setHeader('Content-Type', 'application/xrd+xml');
res.status(200).send(hostMeta);

}
10 changes: 10 additions & 0 deletions pages/api/.well-known/nodeinfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default function handler(req, res) {
res.send(`{
"links": [
{
"rel": "http://nodeinfo.diaspora.software/ns/schema/2.0",
"href": "https://m.eallion.com/nodeinfo/2.0"
}
]
}`);
}
21 changes: 21 additions & 0 deletions pages/api/.well-known/webfinger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default function handler(req, res) {
res.send(`{
"subject": "acct:[email protected]",
"aliases": [
"https://m.eallion.com/users/eallion",
"https://m.eallion.com/@eallion"
],
"links": [
{
"rel": "http://webfinger.net/rel/profile-page",
"type": "text/html",
"href": "https://m.eallion.com/@eallion"
},
{
"rel": "self",
"type": "application/activity+json",
"href": "https://m.eallion.com/users/eallion"
}
]
}`);
}
2 changes: 2 additions & 0 deletions static/.well-known/host-meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"><Link rel="lrdd" type="application/xrd+xml" template="https://m.eallion.com/.well-known/webfinger?resource={uri}"></Link></XRD>
8 changes: 8 additions & 0 deletions static/.well-known/nodeinfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"links": [
{
"rel": "http://nodeinfo.diaspora.software/ns/schema/2.0",
"href": "https://m.eallion.com/nodeinfo/2.0"
}
]
}
19 changes: 19 additions & 0 deletions static/.well-known/webfinger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"subject": "acct:[email protected]",
"aliases": [
"https://m.eallion.com/users/eallion",
"https://m.eallion.com/@eallion"
],
"links": [
{
"rel": "http://webfinger.net/rel/profile-page",
"type": "text/html",
"href": "https://m.eallion.com/@eallion"
},
{
"rel": "self",
"type": "application/activity+json",
"href": "https://m.eallion.com/users/eallion"
}
]
}
71 changes: 63 additions & 8 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,70 @@
{
"github": {
"silent": false
"github": {
"silent": true
},
"build": {
"env": {
"HUGO_VERSION": "0.116.1"
}
},
"git": {
"deploymentEnabled": {
"main": false
}
},
"headers": [
{
"source": "/.well-known/webfinger",
"headers": [
{
"key": "Access-Control-Allow-Origin",
"value": "*"
},
{
"key": "Content-Type",
"value": "application/jrd+json"
}
]
},
"build": {
"env": {
"HUGO_VERSION": "0.116.1"
{
"source": "/.well-known/nodeinfo",
"headers": [
{
"key": "Access-Control-Allow-Origin",
"value": "*"
},
{
"key": "Content-Type",
"value": "application/jrd+json"
}
]
},
"git": {
"deploymentEnabled": {
"main": false
{
"source": "/.well-known/host-meta",
"headers": [
{
"key": "Access-Control-Allow-Origin",
"value": "*"
},
{
"key": "Content-Type",
"value": "application/xrd+xml"
}
]
}
],
"rewrites": [
{
"source": "/.well-known/webfinger",
"destination": "/api/.well-known/webfinger"
},
{
"source": "/.well-known/nodeinfo",
"destination": "/api/.well-known/nodeinfo"
},
{
"source": "/.well-known/host-meta",
"destination": "/api/.well-known/host-meta"
}
]
}

0 comments on commit 0be5eb6

Please sign in to comment.