Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #74 from jiyuujin/chore/monorepo
Browse files Browse the repository at this point in the history
chore: monorepo
  • Loading branch information
jiyuujin authored Apr 29, 2023
2 parents 26c52a7 + 14decaf commit aa5eaa2
Show file tree
Hide file tree
Showing 281 changed files with 8,584 additions and 128 deletions.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,19 @@ coverage
.env

.vite-ssg-temp

.astro

# turbo
.turbo

.idea

apps/ai-app/public/feeds.xml
apps/general-app/public/feeds.xml

#apps/ai-app/public/og/*.png
#apps/general-app/public/og/*.png

#!apps/ai-app/public/og/top.png
#!apps/general-app/public/og/top.png
27 changes: 27 additions & 0 deletions apps/ai-app/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
env: { node: true, es2022: true, browser: true },
extends: ['plugin:astro/recommended'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
overrides: [
{
files: ['*.astro'],
parser: 'astro-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
extraFileExtensions: ['.astro'],
},
},
{
files: ['*.ts'],
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/recommended'],
},
{
files: ['**/*.astro/*.js', '*.astro/*.js'],
parser: '@typescript-eslint/parser',
},
],
rules: {
'@typescript-eslint/triple-slash-reference': 0,
},
}
7 changes: 7 additions & 0 deletions apps/ai-app/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
semi: false,
trailingComma: 'all',
singleQuote: true,
printWidth: 100,
tabWidth: 2,
}
20 changes: 20 additions & 0 deletions apps/ai-app/.textlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"filters": {},
"rules": {
"preset-nekohack-inc": true,
"preset-ja-technical-writing": {
"sentence-length": {
"max": 180
},
"max-comma": {
"max": 8
}
},
"ja-technical-writing/max-kanji-continuous-len": {
max: 8
},
"ja-technical-writing/no-exclamation-question-mark": false,
"ja-technical-writing/ja-no-weak-phrase": false,
"spellcheck-tech-word": true
}
}
42 changes: 42 additions & 0 deletions apps/ai-app/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { defineConfig } from 'astro/config'
import remarkToc from 'remark-toc'
import rehypeToc from 'rehype-toc'
import image from '@astrojs/image'
import react from '@astrojs/react'
import svelte from '@astrojs/svelte'
import vue from '@astrojs/vue'
import vanillaExtract from 'astro-vanilla-extract'

// https://astro.build/config
export default defineConfig({
remarkPlugins: [
[
remarkToc,
{
tight: true,
ordered: true,
},
],
],
rehypePlugins: [
[
rehypeToc,
{
headings: ['h1', 'h2', 'h3'],
cssClasses: {
toc: 'toc-post',
link: 'toc-link',
},
},
],
],
integrations: [
react(),
svelte(),
vue(),
vanillaExtract(),
image({
serviceEntryPoint: '@astrojs/image/sharp',
}),
],
})
46 changes: 46 additions & 0 deletions apps/ai-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "@nekohack/ai-app",
"description": "",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "astro dev",
"build": "npm run build:feeds && npm run build:front",
"build:front": "astro build",
"build:feeds": "node --loader ts-node/esm scripts/feeds.mjs",
"build:og-gen": "node --loader ts-node/esm scripts/generate.mjs",
"format": "prettier --write \"**/*.{js,jsx,json,ts,tsx,md,mdx,css,html,yml,yaml,scss,sass}\" --ignore-path .gitignore",
"lint": "npm run eslint && npm run textlint",
"lint:fix": "npm run eslint:fix && npm run textlint:fix",
"eslint": "eslint . --ext js,jsx,ts,tsx,astro",
"eslint:fix": "eslint . --ext js,jsx,ts,tsx,astro --fix",
"textlint": "textlint ./src/pages/posts/**",
"textlint:fix": "textlint ./src/pages/posts/** --fix"
},
"dependencies": {
"svelte": "3.56.0",
"vue": "3.2.47"
},
"devDependencies": {
"@astrojs/image": "0.16.6",
"@astrojs/react": "2.1.1",
"@astrojs/svelte": "2.1.0",
"@astrojs/vue": "2.1.1",
"astro-vanilla-extract": "2.0.0",
"astro": "2.3.0",
"feed": "4.2.2",
"front-matter": "4.0.2",
"fs-extra": "11.1.1",
"puppeteer": "19.10.1",
"rehype-toc": "3.0.2",
"remark-frontmatter": "4.0.1",
"remark-parse": "10.0.1",
"remark-stringify": "10.0.2",
"remark-toc": "8.0.1",
"sass": "1.62.0",
"sharp": "0.31.3",
"to-vfile": "7.2.4",
"ts-node": "10.9.1",
"unified": "10.1.2"
}
}
Binary file added apps/ai-app/public/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/ai-app/public/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/ai-app/public/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
137 changes: 137 additions & 0 deletions apps/ai-app/public/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
9 changes: 9 additions & 0 deletions apps/ai-app/public/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/mstile-150x150.png"/>
<TileColor>#da532c</TileColor>
</tile>
</msapplication>
</browserconfig>
Binary file added apps/ai-app/public/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/ai-app/public/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
137 changes: 137 additions & 0 deletions apps/ai-app/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions apps/ai-app/public/feeds.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>AIer.info</title>
<link>undefined</link>
<description>週刊でAI界隈の最新情報を記録しています</description>
<lastBuildDate>Sat, 29 Apr 2023 10:33:07 GMT</lastBuildDate>
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
<generator>https://github.com/jpmonette/feed</generator>
<language>ja</language>
<copyright>nekohack</copyright>
</channel>
</rss>
Binary file added apps/ai-app/public/mstile-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/ai-app/public/og/2023-03-03-weekly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/ai-app/public/og/2023-03-10-weekly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/ai-app/public/og/2023-03-16-weekly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/ai-app/public/og/2023-03-24-weekly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/ai-app/public/og/2023-03-31-weekly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/ai-app/public/og/2023-04-07-weekly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/ai-app/public/og/2023-04-14-weekly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/ai-app/public/og/2023-04-21-weekly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/ai-app/public/og/2023-04-28-weekly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/ai-app/public/og/top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions apps/ai-app/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow: /
137 changes: 137 additions & 0 deletions apps/ai-app/public/safari-pinned-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions apps/ai-app/public/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "",
"short_name": "",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
63 changes: 63 additions & 0 deletions apps/ai-app/scripts/feeds.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'use strict'

import { read } from 'to-vfile'
import { unified } from 'unified'
import remarkStringify from 'remark-stringify'
import remarkParse from 'remark-parse'
import remarkFrontmatter from 'remark-frontmatter'

import { Feed } from 'feed'
import { promisify } from 'util'

import fs from 'fs'
import path from 'path'

const currentDir = './src/pages/posts'

let feed = new Feed({
title: 'AIer.info',
description: '週刊でAI界隈の最新情報を記録しています',
feed_url: 'https://ohayo-ai.nekohack.me/feeds.xml',
site_url: 'https://ohayo-ai.nekohack.me/',
copyright: 'nekohack',
language: 'ja',
})

fs.readdir(currentDir, function (err, files) {
if (err) throw err
files.forEach(async (file) => {
await unified()
.use(remarkParse)
.use(remarkStringify)
.use(remarkFrontmatter, ['yaml'])
.use(() => async (tree) => {
tree.children.forEach((yaml) => {
if (yaml.type === 'yaml') {
if (/title: .*\n/.test(yaml.value)) {
const title = /title: .*\n/g
.exec(yaml.value)[0]
.replace('title: ', '')
.replace('\n', '')
feed.items.push({
title: title,
id: `https://ohayo-ai.nekohack.me/posts/${file.replace('.md', '')}`,
link: `https://ohayo-ai.nekohack.me/posts/${file.replace('.md', '')}`,
author: [
{
name: 'jiyuujin',
},
],
description: `${title}について書かせていただきました。`,
body: '',
date: new Date(file.slice(0, 10)),
})
}
}
})
await promisify(fs.writeFile)('./public/feeds.xml', feed.rss2())
})
.process(await read(path.join(currentDir, file)))
})
})

export default function () {}
66 changes: 66 additions & 0 deletions apps/ai-app/scripts/generate.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import path from 'path'
import fs from 'fs'
import puppeteer from 'puppeteer'
import frontMatter from 'front-matter'

const postsDirectory = path.join(process.cwd(), 'src/content/posts')

async function getPostReaction(filename) {
let result = ''

const res = await fs.readFileSync(path.join(postsDirectory, `${filename}`), 'utf8')
const _data = frontMatter(res)
const data = _data.attributes
result = data.reaction
return result
}

async function main() {
const postFiles = fs.readdirSync(postsDirectory)

for (const mdFilename of postFiles) {
const title = await getPostReaction(mdFilename)
const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox'],
})
const page = await browser.newPage()
await page.setExtraHTTPHeaders({
'Accept-Language': 'ja-JP',
})

try {
await page.evaluate(() => {
const style = document.createElement('style')
style.textContent = `
@import url('//fonts.googleapis.com/css?family=M+PLUS+Rounded+1c|Roboto:300,400,500,700|Material+Icons');
div, input, a, p{ font-family: "M PLUS Rounded 1c", sans-serif; };`
document.head.appendChild(style)
document.body.style.fontFamily = '\'M PLUS Rounded 1c\', sans-serif'
})

await page.goto('file:///' + path.join(process.cwd(), 'scripts/reaction-preview.html'), {
waitUntil: 'networkidle0',
})

await page.$eval(
'h1',
(el, title) => {
el.innerHTML = title
},
title,
)

await page.screenshot({
path: `public/og/${mdFilename.replace('.md', '')}.png`,
clip: { x: 0, y: 0, width: 840, height: 840 },
})
} catch (e) {
console.error(e)
}

await browser.close()
}
}

main()
Loading

1 comment on commit aa5eaa2

@vercel
Copy link

@vercel vercel bot commented on aa5eaa2 Apr 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.