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,22 +43,11 @@ async function build() {
|
|||
|
||||
// get images
|
||||
for (const issue of issues) {
|
||||
const imgResp = await fetch("https://html2svg.gwei.cz", {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
url: `https://news.web3privacy.info/image/${issue.week}?${new Date().valueOf()}`,
|
||||
format: "png",
|
||||
width: 1920,
|
||||
height: 960,
|
||||
})
|
||||
});
|
||||
await genImage(`https://news.web3privacy.info/image/${issue.week}?${new Date().valueOf()}`, join(imgDir, `${issue.week}.png`))
|
||||
}
|
||||
|
||||
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");
|
||||
await writeJSONFile(outputFn, issues);
|
||||
|
@ -91,4 +80,21 @@ async function writeJSONFile(fn, data) {
|
|||
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();
|
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 config from '../config.yaml';
|
||||
import MetaTags from '../components/MetaTags.astro';
|
||||
|
||||
const { title, description, image } = Astro.props;
|
||||
|
||||
---
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
<title>{config.name} | Web3Privacy Now</title>
|
||||
|
||||
<MetaTags
|
||||
title={title ? title : config.name}
|
||||
description={description ? description : config.template.preview}
|
||||
{image}
|
||||
/>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<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 WeekNews from '../../components/WeekNews.astro';
|
||||
import issues from '../../issues.json';
|
||||
import config from '../../config.yaml';
|
||||
|
||||
export function getStaticPaths() {
|
||||
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">
|
||||
<a href="/">← Show latest edition</a>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue