Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed assets/icons.woff2
Binary file not shown.
1,179 changes: 13 additions & 1,166 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"sharp": "^0.32.6",
"unist-util-select": "^5.0.0",
"unist-util-visit": "^5.0.0",
"unist-util-visit-parents": "^6.0.1",
"webfonts-generator": "^0.4.0"
"unist-util-visit-parents": "^6.0.1"
},
"imports": {
"#blocks/*": "./src/blocks/*.js",
Expand All @@ -49,7 +48,6 @@
"watch": "NODE_ENV=development node ./src/scripts/watch.js",
"console": "NODE_ENV=production node ./src/scripts/console.js",
"create": "NODE_ENV=production node ./src/scripts/create.js",
"icons": "NODE_ENV=production node ./src/scripts/icons.js",
"manifest": "NODE_ENV=production node ./src/scripts/manifest.js"
},
"license": "MIT",
Expand Down
17 changes: 1 addition & 16 deletions src/blocks/extractor/markdownParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Prism from 'prismjs';
import getLoader from 'prismjs/dependencies.js';
import prismComponents from 'prismjs/components.js';
import { escapeHTML, convertToValidId } from '#utils';
import prefabs from '#prefabs';
import pathSettings from '#settings/paths';

const require = createRequire(import.meta.url);
Expand Down Expand Up @@ -64,18 +63,6 @@ const textTransformers = [
</h${lvl}>`;
},
},
// Convert description code to the appropriate elements (mainly blogs)
{
matcher:
/<pre class="language-([^"]+)" data-code-language="([^"]*)">([\s\S]*?)<\/pre>/g,
replacer:
'<pre class="language-$1 notranslate m-0" data-code-language="$2" translate="no">$3</pre>',
},
// Add a copy to clipboard button after each code block
{
matcher: /<\/pre>/g,
replacer: `</pre><button class="${prefabs.copyCodeButton}" title="Copy code" />`,
},
// Convert blockquotes to the appropriate elements
{
matcher: /<blockquote>\s*\n*\s*<p>([\s\S]*?)<\/p>\s*\n*\s<\/blockquote>/g,
Expand Down Expand Up @@ -219,11 +206,9 @@ export class MarkdownParser {

node.value = isText
? [
`<div class="code-highlight relative mt-4" data-language="${languageName}">`,
`<pre class="language-${languageName}" data-code-language="${languageStringLiteral}">`,
`<pre class="language-${languageName} notranslate" data-code-language="${languageStringLiteral}" translate="no">`,
`${highlightedCode.trim()}`,
`</pre>`,
`</div>`,
].join('')
: `${highlightedCode}`;

Expand Down
34 changes: 30 additions & 4 deletions src/blocks/writers/feedWriter.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
import fs from 'node:fs';
import { writeFile } from 'node:fs/promises';
import handlebars from 'handlebars';
import pathSettings from '#settings/paths';
import globalSettings from '#settings/global';
import { Logger } from '#blocks/utilities/logger';

const { websiteUrl, websiteDescription, websiteName } = globalSettings;
const outPath = `${pathSettings.publicPath}/feed.xml`;
const templatePath = 'src/templates/rssTemplate.hbs';

const template = ({ websiteName, websiteDescription, websiteUrl, nodes }) =>
`<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" version="2.0">
<channel>
<title>${websiteName}</title>
<description>${websiteDescription}</description>
<link>${websiteUrl}</link>
<language>en-us</language>
<image>
<url>${websiteUrl}/assets/logo.png</url>
<title>${websiteName}</title>
<link>${websiteUrl}</link>
</image>
<ttl>1440</ttl>
<atom:link href="${websiteUrl}/feed.xml" rel="self" type="application/rss+xml" />
${nodes
.map(
node =>
` <item>
<title>${node.title}</title>
<link>${node.fullRoute}</link>
<description>${node.description}</description>
<pubDate>${node.pubDate}</pubDate>
</item>`
)
.join('\n')}
</channel>
</rss>`;

/**
* Writes the feed.xml file.
Expand All @@ -21,7 +48,6 @@ export class FeedWriter {
*/
static write = async application => {
const logger = new Logger('FeedWriter.write');
const template = handlebars.compile(fs.readFileSync(templatePath, 'utf-8'));
const { dataset } = application;
const pages = dataset.getModel('Snippet').records.listedByNew.slice(0, 50);
logger.log(`Generating feed for new snippet routes`);
Expand Down
70 changes: 0 additions & 70 deletions src/blocks/writers/iconWriter.js

This file was deleted.

19 changes: 15 additions & 4 deletions src/blocks/writers/sitemapWriter.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import fs from 'node:fs';
import { writeFile } from 'node:fs/promises';
import handlebars from 'handlebars';
import pathSettings from '#settings/paths';
import globalSettings from '#settings/global';
import { Logger } from '#blocks/utilities/logger';

const { websiteUrl } = globalSettings;
const outPath = `${pathSettings.publicPath}/sitemap.xml`;
const templatePath = 'src/templates/sitemapTemplate.hbs';

const template = ({ nodes }) =>
`<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
${nodes
.map(
node =>
` <url>
<loc>${node}</loc>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>`
)
.join('\n')}
</urlset>`;

/**
* Writes the sitemap.xml file.
Expand All @@ -21,7 +33,6 @@ export class SitemapWriter {
*/
static write = async application => {
const logger = new Logger('SitemapWriter.write');
const template = handlebars.compile(fs.readFileSync(templatePath, 'utf-8'));
const { dataset } = application;
const snippetPages = dataset
.getModel('SnippetPage')
Expand Down
2 changes: 0 additions & 2 deletions src/blocks/writers/writers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { SearchIndexWriter } from './searchIndexWriter.js';
import { FeedWriter } from './feedWriter.js';
import { PageWriter } from './pageWriter.js';
import { SitemapWriter } from './sitemapWriter.js';
import { IconWriter } from './iconWriter.js';
import { RedirectsWriter } from './redirectsWriter.js';

export default {
Expand All @@ -14,6 +13,5 @@ export default {
FeedWriter,
PageWriter,
SitemapWriter,
IconWriter,
RedirectsWriter,
};
12 changes: 10 additions & 2 deletions src/components/Omnisearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@ class Omnisearch extends HTMLElement {
this.innerHTML = `
<div class='omnisearch-overlay grid hidden'>
<div class='omnisearch-wrapper srfc-01db br-md'>
<div class='omnisearch-box-wrapper relative a-center flex txt-100 icon icon-search before:fs-sm px-4 py-2'>
<div class='omnisearch-box-wrapper relative a-center flex txt-100 icon px-4 py-2'>
<svg width="20" height="20" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M53.3333 18.6667C34.1875 18.6667 18.6667 34.1875 18.6667 53.3333C18.6667 72.4792 34.1875 88 53.3333 88C72.4792 88 88 72.4792 88 53.3333C88 34.1875 72.4792 18.6667 53.3333 18.6667ZM8 53.3333C8 28.2964 28.2964 8 53.3333 8C78.3702 8 98.6667 28.2964 98.6667 53.3333C98.6667 78.3702 78.3702 98.6667 53.3333 98.6667C28.2964 98.6667 8 78.3702 8 53.3333Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M84.2288 82.3621C86.3116 80.2793 89.6884 80.2793 91.7712 82.3621L115.771 106.362C117.854 108.445 117.854 111.822 115.771 113.905C113.688 115.987 110.312 115.987 108.229 113.905L84.2288 89.9046C82.146 87.8218 82.146 84.4449 84.2288 82.3621Z" fill="currentColor"/>
</svg>
<input
class='omnisearch-box srfc-inset py-1 px-2 box-border'
type='search'
placeholder='Search...'
aria-label='Search snippets and collections'
/>
<button class='omnisearch-close btn icon-btn action-btn icon icon-close m-0 p-0'></button>
<button class='omnisearch-close btn icon-btn action-btn m-0 p-0'>
<svg width="32" height="32" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M90.7523 97.8234C92.7049 99.776 95.8708 99.776 97.8234 97.8234C99.776 95.8708 99.776 92.705 97.8234 90.7523L70.9533 63.8823L97.8234 37.0123C99.776 35.0596 99.776 31.8938 97.8234 29.9412C95.8708 27.9886 92.7049 27.9886 90.7523 29.9412L63.8823 56.8112L37.0122 29.9412C35.0596 27.9885 31.8938 27.9885 29.9411 29.9412C27.9885 31.8938 27.9885 35.0596 29.9411 37.0122L56.8112 63.8823L29.9411 90.7524C27.9885 92.705 27.9885 95.8708 29.9411 97.8234C31.8937 99.7761 35.0596 99.7761 37.0122 97.8234L63.8823 70.9534L90.7523 97.8234Z" fill="currentColor"/>
</svg>
</button>
</div>
<div class='omnisearch-results p-4'>
${this.createEmptyStateHTML()}
Expand Down
12 changes: 9 additions & 3 deletions src/components/Paginator.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ if (!paginator) return null;
const { previous, pages, next } = paginator;

const pageButtonBase = `${prefabs.button} m-0 py-2.5 px-3.5 br-lg box-border f-center`;
const prevNextButtonBase = `${pageButtonBase} ${prefabs.actionLinkButton} gap-1 j-center fs-no md:fs-sm before:fs-md`;
const prevNextButtonBase = `${pageButtonBase} ${prefabs.actionLinkButton} gap-1 j-center fs-no md:fs-sm`;

const previousButtonClass = `${prevNextButtonBase} ${prefabs.iconButton} icon-chevron-left`;
const previousButtonClass = `${prevNextButtonBase} ${prefabs.iconButton}`;
const pageButtonClass = `${pageButtonBase} ${prefabs.actionButton} fs-md`;
const nextButtonClass = `${prevNextButtonBase} ${prefabs.iconReverseButton} icon-chevron-right`;
const nextButtonClass = `${prevNextButtonBase} ${prefabs.iconReverseButton}`;
---

<div class='paginator gap-2 mt-7 mx-auto mb-6 a-center grid j-center'>
{
previous ? (
<a href={previous.url} class={previousButtonClass} rel='prev'>
<svg width="24" height="24" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M83.7712 28.2288C85.854 30.3116 85.854 33.6885 83.7712 35.7713L55.5425 64L83.7712 92.2288C85.854 94.3116 85.854 97.6885 83.7712 99.7713C81.6884 101.854 78.3115 101.854 76.2288 99.7713L44.2288 67.7713C42.146 65.6885 42.146 62.3116 44.2288 60.2288L76.2288 28.2288C78.3115 26.146 81.6884 26.146 83.7712 28.2288Z" fill="currentColor"/>
</svg>
{previous.label}
</a>
) : (
Expand All @@ -43,6 +46,9 @@ const nextButtonClass = `${prevNextButtonBase} ${prefabs.iconReverseButton} icon
{
next ? (
<a href={next.url} class={nextButtonClass} rel='next'>
<svg width="24" height="24" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M44.2288 28.2288C46.3116 26.146 49.6885 26.146 51.7713 28.2288L83.7713 60.2288C85.8541 62.3116 85.8541 65.6885 83.7713 67.7713L51.7713 99.7713C49.6885 101.854 46.3116 101.854 44.2288 99.7713C42.146 97.6885 42.146 94.3116 44.2288 92.2288L72.4576 64L44.2288 35.7713C42.146 33.6885 42.146 30.3116 44.2288 28.2288Z" fill="currentColor"/>
</svg>
{next.label}
</a>
) : (
Expand Down
3 changes: 0 additions & 3 deletions src/icons/check.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/icons/chevron-left.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/icons/chevron-right.svg

This file was deleted.

4 changes: 0 additions & 4 deletions src/icons/clipboard.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/icons/close.svg

This file was deleted.

5 changes: 0 additions & 5 deletions src/icons/home.svg

This file was deleted.

4 changes: 0 additions & 4 deletions src/icons/search.svg

This file was deleted.

8 changes: 5 additions & 3 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ const {
<a class='px-2 lnk-no-animation' href='/collections/p/1'>
<span class='txt-150'>Collections</span>
</a>
<div
class='search-wrapper relative mb-2 flex br-md txt-100 icon icon-search before:fs-sm'
>
<div class='search-wrapper relative mb-2 flex br-md txt-100 icon'>
<svg width="20" height="20" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg" class="py-3 ml-2">
<path fill-rule="evenodd" clip-rule="evenodd" d="M53.3333 18.6667C34.1875 18.6667 18.6667 34.1875 18.6667 53.3333C18.6667 72.4792 34.1875 88 53.3333 88C72.4792 88 88 72.4792 88 53.3333C88 34.1875 72.4792 18.6667 53.3333 18.6667ZM8 53.3333C8 28.2964 28.2964 8 53.3333 8C78.3702 8 98.6667 28.2964 98.6667 53.3333C98.6667 78.3702 78.3702 98.6667 53.3333 98.6667C28.2964 98.6667 8 78.3702 8 53.3333Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M84.2288 82.3621C86.3116 80.2793 89.6884 80.2793 91.7712 82.3621L115.771 106.362C117.854 108.445 117.854 111.822 115.771 113.905C113.688 115.987 110.312 115.987 108.229 113.905L84.2288 89.9046C82.146 87.8218 82.146 84.4449 84.2288 82.3621Z" fill="currentColor"/>
</svg>
<input
class='search-box srfc-inset py-1 px-2 box-border'
type='search'
Expand Down
Loading