  In this paper, we construct a large family of projective linear codes over
${\mathbb F}_{q}$ from the general simplicial complexes of ${\mathbb F}_{q}^m$
via the defining-set construction, which generalizes the results of [IEEE
Trans. Inf. Theory 66(11):6762-6773, 2020]. The parameters and weight
distribution of this class of codes are completely determined. By using the
Griesmer bound, we give a necessary and sufficient condition such that the
codes are Griesmer codes and a sufficient condition such that the codes are
distance-optimal. For a special case, we also present a necessary and
sufficient condition for the codes to be near Griesmer codes. Moreover, by
discussing the cases of simplicial complexes with one, two and three maximal
elements respectively, the parameters and weight distributions of the codes are
given more explicitly, which shows that the codes are at most $2$-weight,
$5$-weight and $19$-weight respectively. By studying the optimality of the
codes for the three cases in detail, many infinite families of optimal linear
codes with few weights over ${\mathbb F}_{q}$ are obtained, including Griesmer
codes, near Griesmer codes and distance-optimal codes.
