feat: add community publishing and news syndication
This commit is contained in:
@@ -6,35 +6,47 @@ import sharp from 'sharp';
|
||||
|
||||
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const outputDirectory = path.join(root, 'static', 'brand');
|
||||
const fontDirectory = path.join(root, 'node_modules', '@fontsource', 'barlow', 'files');
|
||||
const heavy = opentype.parse(fs.readFileSync(path.join(fontDirectory, 'barlow-latin-900-normal.woff')).buffer);
|
||||
const medium = opentype.parse(fs.readFileSync(path.join(fontDirectory, 'barlow-latin-700-normal.woff')).buffer);
|
||||
const fontDirectory = path.join(
|
||||
root,
|
||||
'node_modules',
|
||||
'@fontsource',
|
||||
'barlow',
|
||||
'files',
|
||||
);
|
||||
const heavy = opentype.parse(
|
||||
fs.readFileSync(path.join(fontDirectory, 'barlow-latin-900-normal.woff'))
|
||||
.buffer,
|
||||
);
|
||||
const medium = opentype.parse(
|
||||
fs.readFileSync(path.join(fontDirectory, 'barlow-latin-700-normal.woff'))
|
||||
.buffer,
|
||||
);
|
||||
|
||||
fs.mkdirSync(outputDirectory, { recursive: true });
|
||||
|
||||
const colors = {
|
||||
background: '#0a0c0d',
|
||||
surface: '#111415',
|
||||
border: '#303536',
|
||||
grid: '#2a3031',
|
||||
orange: '#f6a821',
|
||||
white: '#ecebe5'
|
||||
background: '#0a0c0d',
|
||||
surface: '#111415',
|
||||
border: '#303536',
|
||||
grid: '#2a3031',
|
||||
orange: '#f6a821',
|
||||
white: '#ecebe5',
|
||||
};
|
||||
|
||||
function trackedPath(font, value, x, baseline, size, tracking = 0) {
|
||||
let cursor = x;
|
||||
let data = '';
|
||||
for (const character of value) {
|
||||
const glyph = font.charToGlyph(character);
|
||||
data += glyph.getPath(cursor, baseline, size).toPathData(2);
|
||||
cursor += glyph.advanceWidth * size / font.unitsPerEm + tracking;
|
||||
}
|
||||
return { data, width: cursor - x - tracking };
|
||||
let cursor = x;
|
||||
let data = '';
|
||||
for (const character of value) {
|
||||
const glyph = font.charToGlyph(character);
|
||||
data += glyph.getPath(cursor, baseline, size).toPathData(2);
|
||||
cursor += (glyph.advanceWidth * size) / font.unitsPerEm + tracking;
|
||||
}
|
||||
return { data, width: cursor - x - tracking };
|
||||
}
|
||||
|
||||
function emblem(x, y, size) {
|
||||
const scale = size / 100;
|
||||
return `
|
||||
const scale = size / 100;
|
||||
return `
|
||||
<g transform="translate(${x} ${y}) scale(${scale})">
|
||||
<g fill="none" stroke="${colors.orange}" stroke-width="12" stroke-linecap="butt">
|
||||
<path d="M73 20A38 38 0 0 0 15 63"/>
|
||||
@@ -47,10 +59,10 @@ function emblem(x, y, size) {
|
||||
}
|
||||
|
||||
async function writePng(svg, filename, width, height) {
|
||||
await sharp(Buffer.from(svg))
|
||||
.resize(width, height, { fit: 'fill' })
|
||||
.png({ compressionLevel: 9, adaptiveFiltering: true })
|
||||
.toFile(path.join(outputDirectory, filename));
|
||||
await sharp(Buffer.from(svg))
|
||||
.resize(width, height, { fit: 'fill' })
|
||||
.png({ compressionLevel: 9, adaptiveFiltering: true })
|
||||
.toFile(path.join(outputDirectory, filename));
|
||||
}
|
||||
|
||||
const transparentLogo = `
|
||||
@@ -154,10 +166,17 @@ const inviteSplash = `
|
||||
await writePng(transparentLogo, 'shd-core-segments.png', 1024, 1024);
|
||||
await writePng(serverIcon, 'shd-build-discord-icon.png', 1024, 1024);
|
||||
await writePng(banner, 'shd-build-discord-banner-1920x1080.png', 1920, 1080);
|
||||
await writePng(inviteSplash, 'shd-build-discord-invite-background-1920x1080.png', 1920, 1080);
|
||||
await sharp(path.join(outputDirectory, 'shd-build-discord-banner-1920x1080.png'))
|
||||
.resize(960, 540)
|
||||
.png({ compressionLevel: 9, adaptiveFiltering: true })
|
||||
.toFile(path.join(outputDirectory, 'shd-build-discord-banner-960x540.png'));
|
||||
await writePng(
|
||||
inviteSplash,
|
||||
'shd-build-discord-invite-background-1920x1080.png',
|
||||
1920,
|
||||
1080,
|
||||
);
|
||||
await sharp(
|
||||
path.join(outputDirectory, 'shd-build-discord-banner-1920x1080.png'),
|
||||
)
|
||||
.resize(960, 540)
|
||||
.png({ compressionLevel: 9, adaptiveFiltering: true })
|
||||
.toFile(path.join(outputDirectory, 'shd-build-discord-banner-960x540.png'));
|
||||
|
||||
console.log(`Rendered brand assets to ${outputDirectory}`);
|
||||
|
||||
Reference in New Issue
Block a user