Add preview cards #2

Merged
Nikurasu merged 3 commits from share-preview into main 2023-05-14 10:39:53 +01:00
5 changed files with 52 additions and 25 deletions

1
.prettierrc.toml Normal file
View file

@ -0,0 +1 @@
tabWidth = 4

View file

@ -1,6 +1,8 @@
name: "Nikurasu" # The name on the linktree name: "Nikurasu" # The name on the linktree
# summaryText: 'A simple sample text' # A short summary for what you do, will appear if uncommened # summaryText: 'A simple sample text' # A short summary for what you do, will appear if uncommened
# profilePic: # uncomment and set this if your profile pic has a custom name # profilePic: # uncomment and set this if your profile pic has a custom name
url: "https://links.nikurasu.gay" # URL of your SocialTree
siteName: 'NikuHost' # Name of the site visible in embeds, used for Link previews
roundPB: false # Set true if you want a round profile picture roundPB: false # Set true if you want a round profile picture
theme: '98' # Your theme theme: '98' # Your theme
links: # the links to your social accounts links: # the links to your social accounts

View file

@ -1,3 +1,4 @@
cd /app cd /app
yarn yarn
yarn build
yarn dev yarn dev

View file

@ -1,36 +1,48 @@
import express from 'express' import express from "express";
import yaml from 'js-yaml' import yaml from "js-yaml";
import fs from 'node:fs' import fs from "node:fs";
import * as dotenv from 'dotenv' import * as dotenv from "dotenv";
console.log('🔧 Configuring socialtree...') console.log("🔧 Configuring socialtree...");
dotenv.config() dotenv.config();
const app = express() const app = express();
const port = process.env.PORT || 3000 const port = process.env.PORT || 3000;
const engine = 'ejs' const engine = "ejs";
const customMainPartialThemes = [ // Array of themes that require a custom main partial const customMainPartialThemes = [
'98' // Array of themes that require a custom main partial
] "98",
];
app.set('view engine', engine) app.set("view engine", engine);
app.set('views', './src/views') app.set("views", "./src/views");
app.use(express.static('src/dist')) app.use(express.static("src/dist"));
app.use(express.static('assets')) app.use(express.static("assets"));
app.get('/', (req, res) => { app.get("/", (req, res) => {
let config = yaml.load(fs.readFileSync('assets/config/config.yml'), 'utf8') let config = yaml.load(fs.readFileSync("assets/config/config.yml"), "utf8");
res.render('index', { res.render("index", {
name: config.name, name: config.name,
filenameProfilePic: config.profilePic ? config.profilePic : 'profilepic.jpg', url: config.url,
summaryText: config.summaryText ? config.summaryText: '', filenameProfilePic: config.profilePic
? config.profilePic
: "profilepic.jpg",
summaryText: config.summaryText ? config.summaryText : "",
links: config.links, links: config.links,
smallLinks: config.smallLinks, smallLinks: config.smallLinks,
theme: config.theme, theme: config.theme,
roundPB: config.roundPB, roundPB: config.roundPB,
customMainPartialThemes: customMainPartialThemes customMainPartialThemes: customMainPartialThemes,
}) metaDescription: config.summaryText
}) ? config.summaryText
: config.links.map((link) => link.text).join(" | "),
siteName: config.siteName ? config.siteName : "SocialTree",
});
});
app.listen(port, () => console.log(`🚀 Socialtree started on port ${port}, with view engine ${engine}`)) app.listen(port, () =>
console.log(
`🚀 Socialtree started on port ${port}, with view engine ${engine}`
)
);

View file

@ -10,4 +10,15 @@
<% if(roundPB) { %> <% if(roundPB) { %>
<link rel="stylesheet" href="style/round-pb.css"> <link rel="stylesheet" href="style/round-pb.css">
<% } %> <% } %>
<title><%= name %> - SocialTree</title>
<meta property="og:title" content="<%= name %> - SocialTree">
<meta property="og:image" content="img/<%= filenameProfilePic %>">
<meta property="description" content="<%= metaDescription %>">
<meta property="og:description" content="<%= metaDescription %>">
<meta property="og:site_name" content="<%= siteName %>">
<meta property="og:url" content="<%= url %>">
<meta property="twitter:image:src" content="img/<%= filenameProfilePic %>">
<meta property="twitter:card" content="summary">
<meta property="twitter:title" content="<%= name %> - SocialTree">
<meta property="twitter:description" content="<%= metaDescription %>">
</head> </head>