Skip to content
Draft
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ _site/*

# Database #
######################
.AFileIcon/
.package_control_channel/
channel.json
logs.json
Expand Down
7 changes: 0 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ build-emoji:
curl -L https://raw.githubusercontent.com/github/gemoji/master/db/emoji.json -o emoji-source.json
npm run build:emoji

build-label-icons:
[ -d .AFileIcon ] || git clone --depth 1 https://github.com/SublimeText/AFileIcon.git .AFileIcon
npm run build:label-icons

lint:
npx eslint

Expand All @@ -50,9 +46,6 @@ test:
clean:
rm -rf _site/*

clean-a-fileicon:
rm -rf .AFileIcon

serve:
open http://localhost:8080/
npx @11ty/eleventy --serve --quiet
Expand Down
13 changes: 3 additions & 10 deletions _includes/packages/macros.njk
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
</p>
{% endif %}

{{ labels(pkg, true) }}
{{ labels(pkg) }}
</div>
{% endmacro %}

Expand All @@ -102,7 +102,7 @@
{% if pkg.platform_statement %}
<div class="platform-statement">{{ pkg.platform_statement }}</div>
{% endif %}
{{ labels(pkg, true) }}
{{ labels(pkg) }}
</div>
{% endif %}
{% endmacro %}
Expand Down Expand Up @@ -150,7 +150,7 @@
{% endif %}
{% endmacro %}

{% macro labels(pkg, with_icons=false) %}
{% macro labels(pkg) %}
{% set label_buttons -%}
{%- for label in pkg.labels %}
{% set q = searchQueryFor('label', label) %}
Expand Down Expand Up @@ -181,13 +181,6 @@
</a>
{% else %}
<a class="button label" href="/?q={{ q }}">
{% set icon_id = (label | label_icon_id) if with_icons else '' %}
{% if icon_id %}
{% set tint = (label | label_icon_tint) if with_icons else '' %}
<svg class="label-icon{{ (' label-icon--' ~ tint) if tint }}" aria-hidden="true">
<use href="/{{ 'static/label-icons.svg' | bust }}#{{ icon_id }}"></use>
</svg>
{% endif %}
{{ label }}
</a>
{% endif %}
Expand Down
1 change: 0 additions & 1 deletion eleventy.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ export default async function (eleventyConfig) {
bundleCss(path.join(outputDir, `static_${util.gitHash}`, 'styles.css'))
})

eleventyConfig.ignores.add('.AFileIcon')
eleventyConfig.ignores.add('util')
eleventyConfig.ignores.add('README.md')
eleventyConfig.ignores.add('**/*.test.js')
Expand Down
69 changes: 0 additions & 69 deletions eleventy.filters.mjs
Original file line number Diff line number Diff line change
@@ -1,42 +1,12 @@
import * as util from './eleventy.util.mjs'
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'

// Compute prod mode locally so filters remain self-contained
const isProd = process.env.NODE_ENV === 'production' || process.env.ELEVENTY_ENV === 'production'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const sourcesPath = path.join(__dirname, 'label-icons.json')
const configPath = path.join(__dirname, 'label-icons-config.json')

let labelIconSourceSet = new Set()
let labelIconAliases = {}
let labelIconTints = {}

const longDateFormatter = new Intl.DateTimeFormat('en-US', { dateStyle: 'long' })
const compactNumberFormatter = new Intl.NumberFormat('en', { notation: 'compact' })
const groupedNumberFormatter = new Intl.NumberFormat('en', { useGrouping: true })
const labelSortCollator = new Intl.Collator('en', { numeric: true, sensitivity: 'base' })
{
const rawSources = fs.readFileSync(sourcesPath, 'utf8')
const sourcesData = JSON.parse(rawSources)
if (!sourcesData || typeof sourcesData !== 'object') {
throw new Error(`Unexpected data format in ${sourcesPath}; expected object mapping labels to tints`)
}
const labelIconSources = Object.keys(sourcesData)
labelIconSourceSet = new Set(labelIconSources)
labelIconTints = sourcesData

const rawConfig = fs.readFileSync(configPath, 'utf8')
const configData = JSON.parse(rawConfig)
if (!configData || typeof configData.aliases !== 'object') {
throw new Error(`Missing or invalid "aliases" object in ${configPath}`)
}

labelIconAliases = configData.aliases
}

// Filters as normal functions
// simple to date string for some dates without times
Expand All @@ -62,14 +32,6 @@ export function compact(count) {
return compactNumberFormatter.format(count)
}

export function label_icon_aliases_json() {
return JSON.stringify(labelIconAliases)
}

export function label_icon_tints_json() {
return JSON.stringify(labelIconTints)
}

export function label_normalization_note(changes) {
const sortedChanges = changes
.map(change => ({ from: String(change.from), to: String(change.to) }))
Expand Down Expand Up @@ -101,8 +63,6 @@ export function label_normalization_note(changes) {
export function search_index_json(packages) {
return JSON.stringify({
packages: packages.map(compactSearchPackage),
label_icon_aliases: labelIconAliases,
label_icon_tints: labelIconTints,
})
}

Expand Down Expand Up @@ -187,35 +147,6 @@ function joinAsSentenceList(parts) {
return `${parts.slice(0, -1).join(', ')}, and ${parts.at(-1)}`
}

function canonicalLabel(label) {
if (typeof label !== 'string') return ''
const normalized = label.trim().toLowerCase()
if (!normalized) return ''

const alias = labelIconAliases[normalized]
if (alias && labelIconSourceSet.has(alias)) {
return alias
}

if (labelIconSourceSet.has(normalized)) {
return normalized
}

return ''
}

export function label_icon_id(label) {
const canonical = canonicalLabel(label)
if (!canonical) return ''
return `label-icon-${canonical}`
}

export function label_icon_tint(label) {
const canonical = canonicalLabel(label)
if (!canonical) return ''
return labelIconTints[canonical] ?? ''
}

// number formatting with grouping (e.g. 10,000)
export function grouping(count) {
return groupedNumberFormatter.format(count)
Expand Down
9 changes: 0 additions & 9 deletions label-icons-config.json

This file was deleted.

143 changes: 0 additions & 143 deletions label-icons.json

This file was deleted.

7 changes: 0 additions & 7 deletions labels.njk
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ page_type: labels
<li{% if omitted_by_default %} style="display:none"{% endif %}>
{% set q = pack.searchQueryFor('label', item.key) %}
<a {{ "id=main-content" if loop.index0 == 0 }} data-name="{{ item.key }}" data-usage="{{ item.count }}" class="button label" href="/?q={{ q }}">
{% set icon_id = item.key | label_icon_id %}
{% if icon_id %}
{% set tint = item.key | label_icon_tint %}
<svg class="label-icon{{ (' label-icon--' ~ tint) if tint }}" aria-hidden="true">
<use href="/{{ 'static/label-icons.svg' | bust }}#{{ icon_id }}"></use>
</svg>
{% endif %}
{{ item.key }}
<span class="count">{{ item.count }}</span>
</a>
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"test:build": "eleventy --quiet && http-server _site -o",
"test": "vitest run",
"test:watch": "vitest --watch",
"build:emoji": "node util/build-emoji-json.mjs",
"build:label-icons": "node util/build-label-icons.mjs"
"build:emoji": "node util/build-emoji-json.mjs"
},
"dependencies": {
"@11ty/eleventy": "^3.1.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/package.njk
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ page_type: package

{% if (pkg.labels and pkg.labels | length) or (pkg.normalized_labels and pkg.normalized_labels | length) %}
<div class="package-labels">
{{ pack.labels(pkg, true) }}
{{ pack.labels(pkg) }}

{% if pkg.normalized_labels and pkg.normalized_labels | length %}
<aside class="label-normalization-note">
Expand Down
Loading