mirror of
https://github.com/web3privacy/news.git
synced 2024-10-15 18:06:26 +02:00
update
This commit is contained in:
parent
5c36cc286f
commit
4de21a8db9
5 changed files with 84 additions and 19 deletions
|
@ -43,23 +43,12 @@ async function build() {
|
||||||
|
|
||||||
// get images
|
// get images
|
||||||
for (const issue of issues) {
|
for (const issue of issues) {
|
||||||
const imgResp = await fetch("https://html2svg.gwei.cz", {
|
await genImage(`https://news.web3privacy.info/image/${issue.week}?${new Date().valueOf()}`, join(imgDir, `${issue.week}.png`))
|
||||||
method: 'POST',
|
|
||||||
body: JSON.stringify({
|
|
||||||
url: `https://news.web3privacy.info/image/${issue.week}?${new Date().valueOf()}`,
|
|
||||||
format: "png",
|
|
||||||
width: 1920,
|
|
||||||
height: 960,
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
const imgFn = join(imgDir, `${issue.week}.png`)
|
|
||||||
if (imgResp.body) {
|
|
||||||
const file = await Deno.open(imgFn, { write: true, create: true });
|
|
||||||
await imgResp.body.pipeTo(file.writable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make cover
|
||||||
|
await genImage(`https://news.web3privacy.info/cover`, join(imgDir, 'cover.png'))
|
||||||
|
|
||||||
const outputFn = join(DEST_DIR, "index.json");
|
const outputFn = join(DEST_DIR, "index.json");
|
||||||
await writeJSONFile(outputFn, issues);
|
await writeJSONFile(outputFn, issues);
|
||||||
}
|
}
|
||||||
|
@ -91,4 +80,21 @@ async function writeJSONFile(fn, data) {
|
||||||
return Deno.writeTextFile(fn, JSON.stringify(data, null, 2));
|
return Deno.writeTextFile(fn, JSON.stringify(data, null, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function genImage(url, fn) {
|
||||||
|
const imgResp = await fetch("https://html2svg.gwei.cz", {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
|
url,
|
||||||
|
format: "png",
|
||||||
|
width: 1920,
|
||||||
|
height: 960,
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
if (imgResp.body) {
|
||||||
|
const file = await Deno.open(fn, { write: true, create: true });
|
||||||
|
await imgResp.body.pipeTo(file.writable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
build();
|
build();
|
25
web/src/components/MetaTags.astro
Normal file
25
web/src/components/MetaTags.astro
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
const { title, description, image } = Astro.props;
|
||||||
|
---
|
||||||
|
|
||||||
|
<meta name="viewport" content="width=device-width" />
|
||||||
|
<meta name="generator" content={Astro.generator} />
|
||||||
|
<title>{title}</title>
|
||||||
|
|
||||||
|
<meta name="title" content={title} />
|
||||||
|
<meta name="description" content={description} />
|
||||||
|
|
||||||
|
<!-- Open Graph / Facebook -->
|
||||||
|
<meta property="og:type" content="website" />
|
||||||
|
<meta property="og:url" content="https://news.web3privacy.info/" />
|
||||||
|
<meta property="og:title" content={title} />
|
||||||
|
<meta property="og:description" content={description} />
|
||||||
|
<meta property="og:image" content={image} />
|
||||||
|
|
||||||
|
<!-- Twitter -->
|
||||||
|
<meta property="twitter:card" content="summary_large_image" />
|
||||||
|
<meta property="twitter:url" content="https://news.web3privacy.info" />
|
||||||
|
<meta property="twitter:title" content={title} />
|
||||||
|
<meta property="twitter:description" content={description} />
|
||||||
|
<meta property="twitter:image" content={image} />
|
|
@ -1,15 +1,23 @@
|
||||||
---
|
---
|
||||||
import '../styles/base.css';
|
import '../styles/base.css';
|
||||||
import config from '../config.yaml';
|
import config from '../config.yaml';
|
||||||
|
import MetaTags from '../components/MetaTags.astro';
|
||||||
|
|
||||||
|
const { title, description, image } = Astro.props;
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
<meta name="viewport" content="width=device-width" />
|
|
||||||
<meta name="generator" content={Astro.generator} />
|
<MetaTags
|
||||||
<title>{config.name} | Web3Privacy Now</title>
|
title={title ? title : config.name}
|
||||||
|
description={description ? description : config.template.preview}
|
||||||
|
{image}
|
||||||
|
/>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="m-4 sm:m-8">
|
<div class="m-4 sm:m-8">
|
||||||
|
|
21
web/src/pages/cover.astro
Normal file
21
web/src/pages/cover.astro
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
---
|
||||||
|
import '../styles/base.css';
|
||||||
|
import config from '../config.yaml';
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head></head>
|
||||||
|
<body class="h-screen">
|
||||||
|
<div class="grid h-full">
|
||||||
|
<div class="mt-48 ml-48">
|
||||||
|
<div class="text-8xl text-white font-bold">{config.name}</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex h-full items-end justify-end">
|
||||||
|
<div class="mr-48 mb-48">
|
||||||
|
<div class="w3pn-logo h-32"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -2,6 +2,7 @@
|
||||||
import BaseLayout from '../../layouts/base.astro';
|
import BaseLayout from '../../layouts/base.astro';
|
||||||
import WeekNews from '../../components/WeekNews.astro';
|
import WeekNews from '../../components/WeekNews.astro';
|
||||||
import issues from '../../issues.json';
|
import issues from '../../issues.json';
|
||||||
|
import config from '../../config.yaml';
|
||||||
|
|
||||||
export function getStaticPaths() {
|
export function getStaticPaths() {
|
||||||
return issues.map(issue => {
|
return issues.map(issue => {
|
||||||
|
@ -16,7 +17,11 @@ const issue = issues.find(item => item.week === week);
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<BaseLayout>
|
<BaseLayout
|
||||||
|
title=`${config.name} - ${issue.week.split('-').reverse().join('/')}`,
|
||||||
|
description=`${config.template.preview}`
|
||||||
|
image=`https://news.web3privacy.info/img/${issue.week}.png`
|
||||||
|
>
|
||||||
<div class="mb-8">
|
<div class="mb-8">
|
||||||
<a href="/">← Show latest edition</a>
|
<a href="/">← Show latest edition</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue