Skip to content

Commit

Permalink
Remaining website snags (#1028)
Browse files Browse the repository at this point in the history
* fix: fixed expiration parameter and return associated image

* feat: update text on governance page

* feat: rename insights to articles

* feat: add staked total to statistics

* feat: add suspended markets to markets tile

* feat: reorder home page blocks and update translations

* feat: show 'suspended' in suspended markets

* feat: implement own cache expiry method

* feat: update community page strapline
  • Loading branch information
goslingo authored Oct 24, 2023
1 parent 3c73dcd commit 5602fed
Show file tree
Hide file tree
Showing 145 changed files with 530 additions and 317 deletions.
42 changes: 31 additions & 11 deletions api/latest-tweet.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ exports.default = async (req, res) => {
access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
})

let tweetData = await kv.get('latest-tweet')
let cachedData = await kv.get('latest-tweet-cache')
let isCacheExpired = true

if (!tweetData) {
if (cachedData) {
const currentTime = Date.now()
const ONE_HOUR_IN_MS = 60 * 60 * 1000

if (currentTime - cachedData.timestamp < ONE_HOUR_IN_MS) {
isCacheExpired = false
}
}

if (!cachedData || isCacheExpired) {
const { data, includes } = await client.get(
`users/956831071982800896/tweets`,
{
Expand Down Expand Up @@ -58,19 +68,29 @@ exports.default = async (req, res) => {
}
)

tweetData = {
const tweetMediaKey = data[0]?.attachments?.media_keys[0]

const associatedMedia = tweetMediaKey
? includes?.media.find((media) => media.media_key === tweetMediaKey)
: null

const tweetData = {
id: data[0].id,
tweet_text: data[0].text,
image: data[0]?.attachments
? includes?.media[0].url
? includes?.media[0].url
: includes?.media[0].preview_image_url
image: associatedMedia
? associatedMedia.url || associatedMedia.preview_image_url
: null,
all_tweets: data,
}
await kv.set('latest-tweet', tweetData, { expirationTtl: 60 * 60 })
}
await kv.set('latest-tweet-cache', {
tweetData,
timestamp: Date.now(),
})

res.setHeader('Access-Control-Allow-Origin', '*')
res.status(200).json(tweetData)
res.setHeader('Access-Control-Allow-Origin', '*')
res.status(200).json(tweetData)
} else {
res.setHeader('Access-Control-Allow-Origin', '*')
res.status(200).json(cachedData.tweetData)
}
}
2 changes: 1 addition & 1 deletion createMissingLanguageFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const path = require('path')
const languages = require('./languages.js')

const contentDirectories = [
{ path: 'src/content/insights', isPapers: false },
{ path: 'src/content/articles', isPapers: false },
{ path: 'src/content/faqs', isPapers: false },
{ path: 'src/content/papers', isPapers: true },
]
Expand Down
4 changes: 2 additions & 2 deletions gatsby-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ module.exports = {
{
resolve: `gatsby-source-filesystem`,
options: {
name: `insights`,
path: `${__dirname}/src/content/insights`,
name: `articles`,
path: `${__dirname}/src/content/articles`,
},
},
{
Expand Down
12 changes: 6 additions & 6 deletions gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module.exports.createPages = async ({ graphql, actions }) => {
const result = await graphql(`
query {
allMarkdownRemark(
filter: { collection: { in: ["insights", "talks"] } }
filter: { collection: { in: ["articles", "talks"] } }
sort: { fields: [frontmatter___date], order: DESC }
) {
group(field: fields___locale) {
Expand All @@ -112,8 +112,8 @@ module.exports.createPages = async ({ graphql, actions }) => {
Array.from({ length: numPages }).forEach((_, i) => {
if (language.code === 'en') {
createPage({
path: i === 0 ? `/insights` : `/insights/${i + 1}`,
component: path.resolve('./src/templates/insights.tsx'),
path: i === 0 ? `/articles` : `/articles/${i + 1}`,
component: path.resolve('./src/templates/articles.tsx'),
context: {
language: 'en',
limit: postsPerPage,
Expand All @@ -126,9 +126,9 @@ module.exports.createPages = async ({ graphql, actions }) => {
createPage({
path:
i === 0
? `/${language.code}/insights`
: `/${language.code}/insights/${i + 1}`,
component: path.resolve('./src/templates/insights.tsx'),
? `/${language.code}/articles`
: `/${language.code}/articles/${i + 1}`,
component: path.resolve('./src/templates/articles.tsx'),
context: {
language: language.code,
limit: postsPerPage,
Expand Down
3 changes: 1 addition & 2 deletions locales/cn/component.latest-news.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"Latest News": "最新消息",
"{{minutes}} minute read": "短阅读",
"Read our blog": "阅读我们的博客",
"See all Tweets": "查看所有推文",
"Watch all Talks": "观看所有演讲",
"Read all Insights": "阅读所有见解"
"Read all Articles": ""
}
4 changes: 4 additions & 0 deletions locales/cn/component.latest-news_old.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Read all Insights": "阅读所有见解",
"Latest News": "最新消息"
}
3 changes: 3 additions & 0 deletions locales/cn/component.market-tile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Suspended": ""
}
6 changes: 3 additions & 3 deletions locales/cn/component.navigation.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"About": "关于",
"Blog": "博客",
"FAQs": "常见问题解答",
"Insights": "见解",
"Articles": "",
"Key Concepts": "",
"Rewards": "奖励",
"Vega Papers": "VEGA 论文",
Expand Down Expand Up @@ -47,8 +47,8 @@
"Report a security issue": "报告安全问题",
"Brand assets": "品牌资产",
"Contribute to Vega": "为Vega做出贡献",
"Papers": "论文",
"Insights & Talks": "见解与讲座",
"Papers": "",
"Articles & Talks": "",
"Ambassadors": "大使",
"Fairground": "测试网Fairground",
"Developers": "开发人员",
Expand Down
3 changes: 2 additions & 1 deletion locales/cn/component.navigation_old.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
"Technical overview": "技术概况",
"Talks": "谈话",
"Home": "主页",
"Gitub": "Gitub"
"Gitub": "Gitub",
"Insights": "见解"
}
1 change: 1 addition & 0 deletions locales/cn/component.statistics.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"Total Volume": "总交易量",
"Total Markets": "总市场",
"Total Staked": "",
"TVL": "锁定总量",
"Avg. Block Time": "平均出块时间"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"{{firstItem}} - {{lastItem}} of {{totalItems}}": "",
"Next Page": "下一页",
"Next": "下一个",
"Insights & Talks": "见解与谈话",
"Articles and talks about vega": "关于VEGA的文章和谈话",
"Insights & talks.": "见解与谈话"
"Articles & Talks": "",
"Articles and talks about Vega": "",
"Articles & talks.": ""
}
3 changes: 1 addition & 2 deletions locales/cn/page.community.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"Events": "大事件",
"Upcoming community events, meet-ups, research office hours and community calls.": "即将举行的社区活动、聚会、研究办公时间和社区电话",
"Upcoming events + meetups": "即将举行的活动+聚会",
"Join the Vega community, where a fair finance future is being co-created - starting with derivatives.": "加入 Vega 社区,共同创造公平的金融未来 - 从衍生品开始",
"Earn rewards for contributing to the future of finance.": "通过为金融的未来做出贡献而获得奖励",
"Learn, Test, Govern - where do you fit in the Vega Ecosystem?": "",
"Join us on Discord": "加入我们的 Discord",
"Where we are": "进行到哪里了",
"Hangout, chat, get support, suggest new content and art - we're all here!": "聊天、获得支持、推荐新内容和艺术 - 我们都在这里",
Expand Down
4 changes: 3 additions & 1 deletion locales/cn/page.community_old.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
"Events and meetups": "活动和聚会",
"Incentives": "激励",
"Get rewarded for your efforts testing the network": "因测试网络所做的努力而获得奖励”",
"Earn rewards": "获得奖励"
"Earn rewards": "获得奖励",
"Join the Vega community, where a fair finance future is being co-created - starting with derivatives.": "加入 Vega 社区,共同创造公平的金融未来 - 从衍生品开始",
"Earn rewards for contributing to the future of finance.": "通过为金融的未来做出贡献而获得奖励"
}
4 changes: 2 additions & 2 deletions locales/cn/page.governance.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"Get started voting": "开始投票",
"Get $VEGA tokens": "获取$VEGA代币",
"You can purchase VEGA on various exchanges.": "您可以在各个交易所购买 VEGA",
"Get a Vega Wallet": "获取 Vega 钱包",
"A Vega wallet is used to access and sign transactions and connect to any dApp running on Vega.": "Vega 钱包用于访问和签署交易,并连接到在 Vega 上运行的任何 dApp",
"Stake VEGA": "",
"Stake your VEGA tokens on the governance site to be eligible to vote, note you will need to get a <2>wallet</2> to do this": "",
"Vote on proposals": "对提案进行投票",
"Use our governance tools.": "使用我们的治理工具",
"Note, you'll need some ETH to pay any transaction fees.": "请注意,您需要一些 ETH 来支付交易费用",
Expand Down
4 changes: 3 additions & 1 deletion locales/cn/page.governance_old.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
"And store in an Ethereum wallet. You can purchase VEGA using Ethereum (ETH) on decentralized exchanges.": "并存储在以太坊钱包中。您可以在去中心化交易所使用以太坊 (ETH) 购买 VEGA",
"Governance tools": "治理工具",
"Propose a futures market on any underlying.": "提议建立任何标的物的期货市场",
"Create a new market": "创造新市场"
"Create a new market": "创造新市场",
"Get a Vega Wallet": "获取 Vega 钱包",
"A Vega wallet is used to access and sign transactions and connect to any dApp running on Vega.": "Vega 钱包用于访问和签署交易,并连接到在 Vega 上运行的任何 dApp"
}
14 changes: 7 additions & 7 deletions locales/cn/page.index.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
"Vega Wallet": "Vega钱包",
"Docs": "文件",
"Backed by:": "受支持:",
"Programmatic trading on Vega": "Vega 上的程序化交易",
"Vega's decentralised datanode architecture provides rich CEX-like APIs and full historic price data for everyone.": "Vega 的去中心化数据节点架构为每个人提供了丰富的类似 CEX 的 API 和完整的历史价格数据",
"Explore": "探索",
"Key features": "主要特征",
"Non-custodial and pseudonymous": "非托管和匿名",
"No third party has access to your funds.": "没有第三方可以访问您的资金",
Expand All @@ -29,10 +26,13 @@
"Permissionless market creation": "无需许可的市场创建",
"Create any market on any underlying with on-chain governance": "通过链上治理在任何基础上创建任何市场",
"View all": "查看全部",
"Programmatic trading on Vega": "Vega 上的程序化交易",
"Vega's decentralised datanode architecture provides rich CEX-like APIs and full historic price data for everyone.": "Vega 的去中心化数据节点架构为每个人提供了丰富的类似 CEX 的 API 和完整的历史价格数据",
"Explore": "探索",
"Events": "事件",
"Where next?": "接下来",
"Use the network": "使用网络",
"Join the community": "加入社区",
"Govern the network": "治理网络",
"Develop on Vega": "在Vega上开发"
"Learn about Vega": "",
"Read the docs": "",
"Launch Console": "",
"Staking & Governance": ""
}
4 changes: 4 additions & 0 deletions locales/cn/page.index_old.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"Blockchain derivatives": "区块链衍生品",
"Use the network": "使用网络",
"Join the community": "加入社区",
"Govern the network": "治理网络",
"Develop on Vega": "在Vega上开发",
"Vega Protocol - Perpetuals and Futures DEX": "Vega Protocol - 永续合约和期货 DEX"
}
7 changes: 0 additions & 7 deletions locales/cn/page.insights_old.json

This file was deleted.

4 changes: 2 additions & 2 deletions locales/cn/page.rewards.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"Incentives and Bounties": "奖励和赏金",
"Bounties": "赏金",
"Participate in developer bounties and get rewarded for your commitment.": "参与开发者赏金并因您的承诺而获得奖励",
"Security issues": "安全问题",
"Security Issues": "",
"Report a security issue": "报告安全问题",
"Found a software security issue? Report it to us and earn rewards by finding bugs that affect the Vega Network.": "发现软件安全问题?向我们报告并通过查找影响 Vega 网络的错误来获得奖励",
"Fairground incentives": "Fairground奖励",
"Fairground Incentives": "",
"Fairground": "Fairground",
"Earn rewards for helping to find bugs and battle harden Vega's Testnet.": "通过帮助发现错误并强化 Vega 测试网来获得奖励"
}
4 changes: 3 additions & 1 deletion locales/cn/page.rewards_old.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"Develop": "发展"
"Develop": "发展",
"Security issues": "安全问题",
"Fairground incentives": "Fairground奖励"
}
3 changes: 1 addition & 2 deletions locales/en/component.latest-news.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"Latest News": "Latest News",
"{{minutes}} minute read": "{{minutes}} minute read",
"Read our blog": "Read our blog",
"See all Tweets": "See all Tweets",
"Watch all Talks": "Watch all Talks",
"Read all Insights": "Read all Insights"
"Read all Articles": "Read all Articles"
}
4 changes: 4 additions & 0 deletions locales/en/component.latest-news_old.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Read all Insights": "Read all Insights",
"Latest News": "Latest News"
}
3 changes: 3 additions & 0 deletions locales/en/component.market-tile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Suspended": "Suspended"
}
4 changes: 2 additions & 2 deletions locales/en/component.navigation.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"About": "About",
"Blog": "Blog",
"FAQs": "FAQs",
"Insights": "Insights",
"Articles": "Articles",
"Key Concepts": "Key Concepts",
"Rewards": "Rewards",
"Vega Papers": "Vega Papers",
Expand Down Expand Up @@ -48,7 +48,7 @@
"Brand assets": "Brand assets",
"Contribute to Vega": "Contribute to Vega",
"Papers": "Papers",
"Insights & Talks": "Insights & Talks",
"Articles & Talks": "",
"Ambassadors": "Ambassadors",
"Fairground": "Fairground",
"Developers": "Developers",
Expand Down
4 changes: 3 additions & 1 deletion locales/en/component.navigation_old.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,7 @@
"Technical overview": "Technical overview",
"Talks": "Talks",
"Home": "Home",
"Gitub": ""
"Gitub": "",
"Insights": "Insights",
"Insights & Talks": "Insights & Talks"
}
1 change: 1 addition & 0 deletions locales/en/component.statistics.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"Total Volume": "Total Volume",
"Total Markets": "Total Markets",
"Total Staked": "Total Staked",
"TVL": "TVL",
"Avg. Block Time": "Avg. Block Time"
}
10 changes: 10 additions & 0 deletions locales/en/page.articles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Previous Page": "Previous Page",
"Previous": "Previous",
"{{firstItem}} - {{lastItem}} of {{totalItems}}": "{{firstItem}} - {{lastItem}} of {{totalItems}}",
"Next Page": "Next Page",
"Next": "Next",
"Articles & Talks": "Articles & Talks",
"Articles and talks about Vega": "Articles and talks about Vega",
"Articles & talks.": "Articles & talks."
}
3 changes: 3 additions & 0 deletions locales/en/page.articles_old.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Articles and talks about vega": "Articles and talks about Vega"
}
3 changes: 1 addition & 2 deletions locales/en/page.community.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"Events": "Events",
"Upcoming community events, meet-ups, research office hours and community calls.": "Upcoming community events, meet-ups, research office hours and community calls.",
"Upcoming events + meetups": "Upcoming events + meetups",
"Join the Vega community, where a fair finance future is being co-created - starting with derivatives.": "Join the Vega community, where a fair finance future is being co-created - starting with derivatives.",
"Earn rewards for contributing to the future of finance.": "Earn rewards for contributing to the future of finance.",
"Learn, Test, Govern - where do you fit in the Vega Ecosystem?": "Learn, Test, Govern - where do you fit in the Vega Ecosystem?",
"Join us on Discord": "Join us on Discord",
"Where we are": "Where we are",
"Hangout, chat, get support, suggest new content and art - we're all here!": "Hangout, chat, get support, suggest new content and art - we're all here!",
Expand Down
4 changes: 3 additions & 1 deletion locales/en/page.community_old.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
"Events and meetups": "Events and meetups",
"Incentives": "Incentives",
"Get rewarded for your efforts testing the network": "Get rewarded for your efforts testing the network",
"Earn rewards": "Earn rewards"
"Earn rewards": "Earn rewards",
"Join the Vega community, where a fair finance future is being co-created - starting with derivatives.": "Join the Vega community, where a fair finance future is being co-created - starting with derivatives.",
"Earn rewards for contributing to the future of finance.": "Earn rewards for contributing to the future of finance."
}
4 changes: 2 additions & 2 deletions locales/en/page.governance.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"Get started voting": "Get started voting",
"Get $VEGA tokens": "Get $VEGA tokens",
"You can purchase VEGA on various exchanges.": "You can purchase VEGA on various exchanges.",
"Get a Vega Wallet": "Get a Vega Wallet",
"A Vega wallet is used to access and sign transactions and connect to any dApp running on Vega.": "A Vega wallet is used to access and sign transactions and connect to any dApp running on Vega.",
"Stake VEGA": "Stake VEGA",
"Stake your VEGA tokens on the governance site to be eligible to vote, note you will need to get a <2>wallet</2> to do this": "Stake your VEGA tokens on the governance site to be eligible to vote, note you will need to get a <2>wallet</2> to do this",
"Vote on proposals": "Vote on proposals",
"Use our governance tools.": "Use our governance tools.",
"Note, you'll need some ETH to pay any transaction fees.": "Note, you'll need some ETH to pay any transaction fees.",
Expand Down
4 changes: 3 additions & 1 deletion locales/en/page.governance_old.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
"And store in an Ethereum wallet. You can purchase VEGA using Ethereum (ETH) on decentralized exchanges.": "And store in an Ethereum wallet. You can purchase VEGA using Ethereum (ETH) on decentralized exchanges.",
"Governance tools": "Governance tools",
"Propose a futures market on any underlying.": "Propose a futures market on any underlying.",
"Create a new market": "Create a new market"
"Create a new market": "Create a new market",
"Get a Vega Wallet": "Get a Vega Wallet",
"A Vega wallet is used to access and sign transactions and connect to any dApp running on Vega.": "A Vega wallet is used to access and sign transactions and connect to any dApp running on Vega."
}
Loading

0 comments on commit 5602fed

Please sign in to comment.